DCSync
Introduction
DCSync is a technique used by attackers to replicate credentials from an Active Directory (AD) domain controller by impersonating a Domain Controller using the Directory Replication Service (DRS) Remote Protocol. This attack does not require code execution on the domain controller itself but instead abuses the replication permissions within AD.
DCSync is a stealthy and highly effective technique for extracting sensitive credentials, including password hashes for user accounts, service accounts, and even privileged accounts like krbtgt, which can be used to generate Golden Tickets. It is categorised under the Credential Access tactic in the MITRE ATT&CK Framework (ID: T1003.006).
How DCSync Works
Understanding Directory Replication:
In an Active Directory environment, domain controllers replicate information using the DRS Remote Protocol to keep the directory consistent across the domain.
The replication process includes account credentials (e.g., NTLM hashes, Kerberos keys) as part of the directory data.
Abusing Replication Permissions:
An attacker gains access to an account with replication privileges (e.g., Domain Admin, Enterprise Admin, or accounts with the Replicating Directory Changes permissions).
Using tools like Mimikatz, attackers query the domain controller and request the replication of credential-related data.
Key Targets:
krbtgt Account: Used to forge Kerberos tickets (e.g., Golden Tickets).
Privileged Accounts: NTLM hashes or Kerberos keys for domain admins or service accounts.
All User Accounts: Complete credential database for lateral movement or data theft.
Execution:
Attackers use tools like Mimikatz, Impacket (secretsdump.py), or PowerShell scripts to perform the DCSync attack.
Why DCSync is Dangerous
No Code Execution on the DC:
The attacker does not need to run malicious code on the domain controller itself, reducing the chances of detection.
Full Credential Access:
Provides access to sensitive credentials for all users in the domain.
Privilege Escalation:
Allows attackers to escalate privileges by extracting credentials for domain administrators or the krbtgt account.
Persistence:
Extracted hashes can be reused to access the domain or forge tickets at a later time.
Stealth:
DCSync mimics legitimate domain controller replication requests, making it harder to detect.
Indicators of DCSync
Unusual Account Activity:
Non-DC accounts performing replication-related operations.
Suspicious LDAP Operations:
LDAP calls involving
GetNCChanges
orReplicate Directory Changes
.
Event Logs:
Windows Security Event Logs:
4662: An operation was performed on an object (indicates directory replication permissions).
4672: Special privileges assigned to a new logon.
Directory Service Event Logs:
1644: Domain controller logs a replication request.
Detection Techniques
Event that detects a DCSync:
Event ID 4662: This event is generated when an operation is performed on an object. When DCSync is executed, this event is generated on the targeted Domain Controller, and the event properties contain the following values:
1131f6ad-9c07-11d1-f79f-00c04fc2dcd2 (DS-Replication-Get-Changes-All)
19195a5b-6da0-11d0-afd3-00c04fd930c9 (Domain-DNS class WRITE_DAC)
89e95b76-444d-4c62-991a-0facbeda640c (DS-Replication-Get-Changes-In-Filtered-Set)
If this event is not generated by a Domain Controller, it may indicate a DCSync has occurred.
Monitor for Replication Permissions:
Identify accounts with Replicating Directory Changes permissions.
Detect Suspicious LDAP Operations:
Monitor for replication-related API calls, such as
GetNCChanges
.
Log Analysis:
Review logs for unexpected replication requests or access to the krbtgt account.
Unusual Network Activity:
Monitor traffic between non-DC hosts and domain controllers.
Mitigation Strategies
Restrict Replication Permissions:
Limit accounts with Replicating Directory Changes and Replicating Directory Changes All permissions.
Enable Advanced Auditing:
Configure auditing for sensitive actions like directory replication.
Monitor Account Activity:
Regularly review accounts with elevated permissions and disable unused accounts.
Protect the krbtgt Account:
Regularly rotate the krbtgt account password to invalidate stolen tickets.
The following security controls should be implemented to mitigate DCSync:
Minimise the number of user objects with DCSync permissions. By default, members of the Enterprise Admins, Domain Admins and Administrators security group have permissions to perform DCSync. Therefore, the number of user objects in these security groups should be minimised and direct assignment of these permissions to other user objects should be limited.
Ensure user objects that are configured with a SPN do not have DCSync permissions. This is to reduce the risk of a user object with a SPN being compromised as the result of a successful Kerberoasting and then being used by malicious actors to execute DCSync.
Ensure user objects with DCSync permissions cannot log on to unprivileged operating environments. Lower privileged operating environments, such as those used by internet-facing systems and user workstations, are often exploited by malicious actors to gain initial access and to pivot to higher privileged operating environments. Preventing privileged user objects from logging into these lower privileged operating environments reduces the risk of these user objects being compromised and subsequently used to pivot to higher privileged operating environments. This is a key protection in the tiered administrative model.
Review user objects with DCSync permissions every 12 months to determine if these permissions are still required. Regularly reviewing permissions, and removing them when no longer required, reduces the attack surface that malicious actors can target.
Disable the NTLMv1 protocol. This prevents NTLM password hashes from being retrieved by DCSync and then being either cracked or used as part of PtH.
Ensure LAN Manager (LM) password hashes are not used. This can be enforced by requiring and updating passwords to be a minimum of 15-characters. LM only supports passwords up to 14-characters in length and passwords that are 15-characters or more will not be stored as a LM hash. LM password hashes can be quickly cracked to reveal cleartext passwords and are not considered secure.
Segment Network Access:
Restrict network access to domain controllers to prevent unauthorised replication.
Tools Commonly Used for DCSync
Mimikatz:
Command:
lsadump::dcsync /user:<target user>
to replicate credentials for a specific user.
Impacket (secretsdump.py):
Extracts hashes from domain controllers using replication permissions.
PowerShell Scripts:
Scripts that leverage LDAP and DRSUAPI functions to perform DCSync.
DCSync is one of the most powerful and stealthy techniques attackers use to compromise Active Directory environments. By abusing legitimate replication mechanisms, it enables attackers to extract credentials for the entire domain without needing direct access to domain controllers. Effective detection and mitigation require a combination of logging, auditing, and restricting replication permissions.
KQL Detection Queries:
Detecting DCSync attacks requires monitoring specific Active Directory events for suspicious replication requests and activity. DCSync typically involves abusing Replicating Directory Changes permissions to request credential data from domain controllers using the DRSUAPI or LDAP protocols.
Query to detect potential DCSync attacks:
Query performs the following steps:
Defines the time range for the query to look back over the past 7 days.
Identifies suspicious replication requests by looking for Event ID 4662, which indicates an operation was performed on an object.
Filters events to include only those related to replication access.
Aggregates the data to count the number of replication requests and unique IPs per account.
Filters the results to include only those with more than 5 requests (adjust the threshold based on your environment).
Displays the results in a table format, sorted by the number of requests.
Splunk Detection Queries
To detect DCSync attacks in Splunk, focus on identifying unusual directory replication requests and suspicious access to replication-related objects. This involves monitoring Windows Security Event Logs for specific events that indicate abuse of Replicating Directory Changes permissions or unauthorized access to sensitive objects.
Splunk Query to Detect DCSync
Query Breakdown
Targeted Event Codes:
4662: Logs access to sensitive AD objects, including replication-related permissions like
Replicating Directory Changes
orReplicating Directory Changes All
.4672: Logs special privileges assigned to accounts, such as
SeSyncAgentPrivilege
(often required for DCSync).
Extract Key Fields:
ObjectAccessed: The object targeted by the replication request.
PermissionsGranted: Specific permissions used in the operation.
PrivilegesAssigned: Privileges assigned to the account.
Filter for Suspicious Activity:
Focuses on:
Access to replication-related objects or permissions (
4662
).Accounts assigned replication privileges (
4672
).
Aggregate and Score:
Groups events by
ComputerName
andEventCode
.Assigns a SuspiciousScore based on activity:
High: Access to
Replicating Directory Changes All
.Medium: Accounts with
SeSyncAgentPrivilege
.
Output:
Displays key information, including accessed objects, suspicious accounts, and permissions used.
Reference
Last updated