Hunting for NTDS Database Dumping
The Ntds.dit database is a critical component of Active Directory, containing sensitive information such as user credentials, password hashes, and other domain data. If attackers dump this database, they gain the keys to the entire Active Directory environment, potentially compromising all systems within the domain.
Attack Overview
Attackers can exploit legitimate utilities like ntdsutil to dump the Ntds.dit database. This blending with legitimate operations makes detection challenging. Here's a typical attack workflow:
Command Execution:
The attacker runs
ntdsutil
with parameters to create a backup of the Ntds.dit database, e.g.:
Output:
The database is dumped, along with critical registry hives like
SYSTEM
andSECURITY
.
Exfiltration:
The dumped files are then transferred to the attacker's machine for offline analysis.
Detection Techniques
Key Event IDs to Monitor
The activity of dumping Ntds.dit triggers several notable events in the Application Event Logs with the ESENT event source. Focus on the following:
Event ID 325:
Indicates the creation of a new database.
Look for abnormal paths in the File Path field (anything other than
C:\Windows\NTDS\
).
Event ID 327:
Indicates that a database instance was detached.
Again, check the File Path for irregularities.
Event ID 216:
Logged when the Ntds.dit file is written outside its default location.
The path should be analyzed to detect anomalies.
Example Detection Steps:
Filter for Events:
Use Event Viewer to filter Application Logs by ESENT event source.
Focus on Event IDs 325, 327, and 216.
Correlate Timestamps:
The events often occur in quick succession (milliseconds apart).
Keyword Search:
Use the Find function in Event Viewer to search for
ntds
.
Sample Event Analysis
Event ID 325:
Event ID 327:
Event ID 216:
These correlated events signal potential malicious activity.
Mitigation Strategies
Restrict Administrative Privileges:
Limit the number of users with access to Domain Controllers (DCs).
Audit Administrative Access:
Continuously monitor logins and administrative actions on DCs.
Enable and Monitor Logging:
Ensure Event ID 325, 327, and 216 are captured and regularly reviewed.
Alert on Anomalous Paths:
Configure alerts for file operations outside
C:\Windows\NTDS\
.
Conduct Regular Audits:
Periodically audit backup locations and ensure they align with operational policies.
Key Points
By closely monitoring key ESENT events and correlating timestamps, defenders can effectively identify and respond to attempts at dumping the Ntds.dit database. These proactive measures reduce the risk of complete Active Directory compromise.
Last updated