19. DCSync
Overview
DCSync is a powerful attack technique used to extract password hashes from Active Directory (AD) by impersonating a domain controller. This method exploits the Directory Replication Service Remote Protocol to request replication of user credentials, allowing attackers to retrieve NTLM password hashes.
Scenario Setup
This section outlines how to leverage DCSync for full domain compromise using both Linux and Windows attack hosts. The following hosts will be used:
Windows Attack Host (MS01): Accessible via RDP with
htb-student:Academy_student_AD!
Linux Attack Host: Accessible via SSH from MS01 with
htb-student:HTB_@cademy_stdnt!
Target Domain Controller:
INLANEFREIGHT.LOCAL
Understanding DCSync
DCSync requires control over an account with domain replication privileges, specifically DS-Replication-Get-Changes-All
. Typically, Domain Admins and Enterprise Admins have these privileges by default. However, other accounts may be granted these rights, making them valuable targets.
Checking User Privileges
We first verify if our compromised user adunn
has the necessary permissions.
Viewing adunn
's Group Membership
adunn
's Group MembershipChecking Replication Rights
If DS-Replication-Get-Changes-All
appears in the output, adunn
has the required privileges.
Executing the DCSync Attack
DCSync can be executed using Impacket’s secretsdump.py or Mimikatz.
Using secretsdump.py
(Linux)
secretsdump.py
(Linux)Example Output:
To target a specific user:
Using Mimikatz (Windows)
Run as adunn
:
Execute DCSync:
Example Output:
Additional Enumeration
If password history is needed:
To check password last set dates:
Mitigation Strategies
Restrict Replication Privileges: Limit
DS-Replication-Get-Changes-All
to only domain controllers.Enable Monitoring & Logging:
Use Event ID 4662 (Audit Directory Service Access) to detect abnormal replication requests.
Monitor Event ID 4742 (user account changes) for privilege escalation attempts.
Implement the Principle of Least Privilege (PoLP): Ensure only necessary users have replication rights.
Use Managed Service Accounts: Replace regular user accounts for sensitive operations.
Enable LAPS (Local Administrator Password Solution): Prevent local admin credential reuse.
Conclusion
DCSync is a critical attack vector that can lead to full domain compromise. Understanding detection and mitigation strategies is essential to securing Active Directory environments. By proactively auditing privileges and monitoring replication requests, organizations can significantly reduce their risk exposure.
Last updated