DCSync
Last updated
Last updated
DCSync
is an attack that threat agents utilize to impersonate a Domain Controller and perform replication with a targeted Domain Controller to extract password hashes from Active Directory. The attack can be performed both from the perspective of a user account or a computer, as long as they have the necessary permissions assigned, which are:
Replicating Directory Changes
Replicating Directory Changes All
We will utilize the user Rocky
(whose password is Slavi123
) to showcase the DCSync
attack. When we check the permissions for Rocky, we see that he has Replicating Directory Changes
and Replicating Directory Changes All
assigned:
First, we need to start a new command shell running as Rocky:
Subsequently, we need to use Mimikatz
, one of the tools with an implementation for performing DCSync. We can run it by specifying the username whose password hash we want to obtain if the attack is successful, in this case, the user 'Administrator':
It is possible to specify the /all
parameter instead of a specific username, which will dump the hashes of the entire AD environment. We can perform pass-the-hash
with the obtained hash and authenticate against any Domain Controller.
What DCSync abuses is a common operation in Active Directory environments, as replications happen between Domain Controllers all the time; therefore, preventing DCSync out of the box is not an option. The only prevention technique against this attack is using solutions such as the RPC Firewall, a third-party product that can block or allow specific RPC calls with robust granularity. For example, using RPC Firewall
, we can only allow replications from Domain Controllers.
Detecting DCSync is easy because each Domain Controller replication generates an event with the ID 4662
. We can pick up abnormal requests immediately by monitoring for this event ID and checking whether the initiator account is a Domain Controller. Here's the event generated from earlier when we ran Mimikatz
; it serves as a flag that a user account is performing this replication attempt:
Since replications occur constantly, we can avoid false positives by ensuring the followings:
Either the property 1131f6aa-9c07-11d1-f79f-00c04fc2dcd2
or 1131f6ad-9c07-11d1-f79f-00c04fc2dcd2
is present in the event.
Whitelisting systems/accounts with a (valid) business reason for replicating, such as Azure AD Connect
(this service constantly replicates Domain Controllers and sends the obtained password hashes to Azure AD).
1) Connect to the target and perform a DCSync attack as the user rocky (password:Slavi123). What is the NTLM hash of the Administrator user?
To begin, let's open a new command shell with Rocky’s credentials.
Next, we should utilize Mimikatz, a tool that supports DCSync implementation.
Answer: fcdc65703dd2b0bd789977f1f3eeaecf
2) After performing the DCSync attack, connect to DC1 as 'htb-student:HTB_@cademy_stdnt!' and look at the logs in Event Viewer. What is the Task Category of the events generated by the attack?
Let’s connect to DC1 (172.16.18.3) from our Windows machine using Remote Desktop.
Next, open Event Viewer and filter by Event ID 4662.
Answer: Directory Service Access