Dumping ntds.dit
Introduction
The NTDS.dit file is the Active Directory (AD) database that stores all directory information, including user account data, group memberships, and most critically, password hashes. Dumping the NTDS.dit file is a technique used by attackers to extract this sensitive information and gain unauthorised access to an organisation's domain.
Dumping the NTDS.dit file is categorised under the Credential Access tactic in the MITRE ATT&CK Framework (ID: T1003.003). This technique provides attackers with a wealth of information for lateral movement, privilege escalation, and persistence within a compromised network.
How NTDS.dit Dumping Works
Understanding NTDS.dit:
Located in
C:\Windows\NTDS\
, this file contains:Password Hashes: NTLM and Kerberos hashes for all domain users.
Account Metadata: Group memberships, account states, and other attributes.
Challenges for Attackers:
Locked Access: The NTDS.dit file is locked by the Local Security Authority Subsystem Service (LSASS) and cannot be directly copied while the domain controller is running.
Encryption: Certain sections of the file are encrypted.
Common Methods to Dump NTDS.dit:
VSS (Volume Shadow Copy Service):
Attackers create a shadow copy of the system and extract NTDS.dit from the backup.
NTDSUtil Tool:
Native Windows tool abused to export AD data, including password hashes.
DSRM (Directory Services Restore Mode):
Reboots the domain controller into Directory Services Restore Mode to directly access NTDS.dit.
Mimikatz and Impacket:
Tools like Mimikatz and secretsdump.py allow attackers to extract hashes remotely via the
DRSUAPI
protocol.
Decryption of Password Hashes:
To decrypt password hashes, attackers extract the SYSTEM hive from the registry (e.g.,
HKLM\SYSTEM
) to retrieve the boot key used to decrypt the NTDS.dit file.
Risks of NTDS.dit Dumping
Complete Credential Access:
Provides NTLM and Kerberos hashes for all accounts in the domain, including privileged accounts like Domain Admins.
Stealthy Attacks:
Once dumped, hashes can be used offline, making detection difficult.
Lateral Movement and Escalation:
Enables attackers to move laterally and escalate privileges by impersonating any user.
Persistence:
Hashes can be reused to create Golden Tickets or pass-the-hash attacks for long-term access.
Indicators of NTDS.dit Dumping
Shadow Copy Creation:
Unauthorised use of Volume Shadow Copy Service (VSS) commands (e.g.,
vssadmin
,diskshadow
).
Export Operations:
Use of ntdsutil to export directory data.
Registry Access:
Access to
HKLM\SYSTEM
hive for boot key extraction.
Unusual Logon Patterns:
Logons using NTLM hashes, often seen after hash extraction.
Directory Access Events:
Access to
C:\Windows\NTDS\NTDS.dit
.
Detection Techniques
Tools such as Volume Shadow Copy Service and Ntdsutil are commonly used by malicious actors to dump the ntds.dit file and the SYSTEM hive from Domain Controllers. These tools can be executed using PowerShell. If PowerShell logging is enabled, these tool names and their parameters are recorded, which can help identify if an attempt was made to compromise the ntds.dit file. Additionally, monitoring for signs of compromise by analysing events for unusual authentication events, such as objects that do not normally authenticate or authenticate during unusual times of the day, can assist in identifying malicious activity.
Monitor Shadow Copy Creation:
Look for commands like:
vssadmin create shadow /for=C:
diskshadow
.
Detect NTDSUtil Abuse:
Monitor command-line usage of
ntdsutil
with suspicious parameters:ntdsutil "ac i ntds" "ifm"
Registry Monitoring:
Track access to
HKLM\SYSTEM
hive for potential key extraction.
Events that Detect Dumping ntds.dit:
Event ID 1102: Event generated when the ‘Security’ audit log is cleared. To avoid detection, malicious actors may clear this audit log to remove any evidence of their activities. Analysing this event can assist in identifying if a Domain Controller has been compromised.
Event ID 4103: Event generated when PowerShell executes and logs pipeline execution details. Malicious actors commonly leverage PowerShell in their compromises. Analysing this event for PowerShell execution relating to the ntds.dit file may indicate dumping of the ntds.dit file.
Event ID 4104: Event generated when PowerShell executes code to capture scripts and commands. Malicious actors commonly leverage PowerShell in their compromises. Analysing this event for PowerShell execution relating to the ntds.dit file may indicate dumping of the ntds.dit file.
Event ID 4656: Event generated when a handle to an object has been requested, such as a file: for example, when malicious actors attempt to access the ntds.dit file in any way (e.g., read, write or delete). If the ‘Object Name’ value in the event matches the ntds.dit file, this may indicate the ntds.dit file has been compromised.
Event ID 4663: Event generated when the System Access Control List (SACL) is enabled for the ntds.dit file and an attempt is made to access, read, write, or modify an object, such as a file. If the ‘Object Name’ value in the event matches the ntds.dit file, this may indicate the ntds.dit file has been compromised.
Event ID 4688: Event generated when a new process has been created. This event provides context of the commands and parameters that are executed when a new process is created. Malicious actors are likely to create a new process when dumping the ntds.dit file, such as via PowerShell, Volume Shadow Copy Service or Ntdsutil.
Event ID 8222: Event generated when a shadow copy is made. Making a shadow copy of the ntds.dit file is a common way to bypass file lock restrictions. This event can be analysed to determine if the shadow copy was legitimate or not.
Audit File Access:
Monitor file access to
C:\Windows\NTDS\NTDS.dit
.
Analyse Network Traffic:
Detect the use of tools like secretsdump.py, which leverage the
DRSUAPI
protocol.
Mitigation Strategies
Mitigating dumping ntds.dit
Mitigating techniques targeting the ntds.dit file begins with hardening Domain Controllers by restricting privileged access pathways, disabling unused services and ports, not installing additional features or applications, using antivirus and endpoint detection and response solutions, and monitoring for signs of compromise. These mitigations reduce the attack surface of Domain Controllers and increase the likelihood of detecting malicious activity.
The following security controls should be implemented to mitigate dumping ntds.dit:
Limit access to Domain Controllers to only privileged users that require access. This reduces the number of opportunities for malicious actors to gain access to Domain Controllers.
Restrict privileged access pathways to Domain Controllers to jump servers and secure admin workstations using only the ports and services that are required for administration. Domain Controllers are classified as ‘Tier 0’ assets within Microsoft’s ‘Enterprise Access Model’.
Encrypt and securely store backups of Domain Controllers and limit access to only Backup Administrators. Backups of Domain Controllers need to be afforded the same security as the actual Domain Controllers. Malicious actors may target backup systems to gain access to critical and sensitive computer objects, such as Domain Controllers.
Only use Domain Controllers for AD DS and do not install any non-security-related services or applications. This reduces the attack surface of Domain Controllers as there are fewer services, ports and applications that may be vulnerable and used to compromise a Domain Controller.
Centrally log and analyse Domain Controller logs in a timely manner to identify malicious activity. Domain Controller logs provide a rich source of information that is important for investigating potentially malicious activity on Domain Controllers and in the domain.
Disable the Print Spooler service on Domain Controllers. For example, malicious actors have targeted the Print Spooler service on Domain Controllers as a technique to authenticate to a system they control to collect the Domain Controllers computer object password hash or TGT. Malicious actors can then use this to authenticate to the Domain Controller they coerced and gain administrative access.
Disable the Server Message Block (SMB) version 1 protocol on Domain Controllers. There are multiple Active Directory compromises that leverage weaknesses in the SMBv1 protocol to gain access to systems, including Domain Controllers. Disabling SMBv1 on Domain Controllers and on all systems in a domain mitigates compromises that leverage the SMBv1 protocol.
Protect Domain Controllers:
Restrict physical and remote access to domain controllers.
Use firewalls to limit communication with domain controllers.
Restrict Shadow Copy Access:
Limit access to tools like
vssadmin
anddiskshadow
.
Secure Registry Keys:
Limit access to
HKLM\SYSTEM
to prevent boot key extraction.
Enable Advanced Auditing:
Configure auditing for file access, shadow copy operations, and command-line execution.
Monitor for Known Tools:
Detect tools like Mimikatz, Impacket, or ntdsutil in use.
Common Tools Used for NTDS.dit Dumping
Mimikatz:
Extracts hashes and secrets directly from memory or NTDS.dit.
Impacket (secretsdump.py):
Extracts hashes remotely using the DRSUAPI protocol.
NTDSUtil:
Native Windows tool used to export AD data.
Volume Shadow Copy Tools:
vssadmin
ordiskshadow
to create shadow copies.
Dumping the NTDS.dit file provides attackers with a powerful mechanism to compromise an entire Active Directory domain. By securing domain controllers, monitoring for unusual activities like shadow copy creation or registry access, and limiting the use of native tools like ntdsutil
, organisations can significantly reduce their risk.
KQL Detection Queries
Detecting attempts to dump the NTDS.dit file involves monitoring shadow copy creation, unauthorised access to the NTDS.dit file, and suspicious use of tools like ntdsutil
. Below is a KQL query for Microsoft Sentinel to identify potential NTDS.dit dumping activity.
Query to detect potential dumping of the ntds.dit
file:
Query performs the following steps:
Defines the time range for the query to look back over the past 7 days.
Identifies suspicious access to the
ntds.dit
file by looking for Event ID 4662.Identifies shadow copy creation events by looking for Event ID 5136.
Combines the results to identify potential compromises by matching suspicious NTDS.dit access with shadow copy creation events.
Splunk Detection Queries
To detect NTDS.dit dumping in Splunk, you should focus on monitoring activities like shadow copy creation, access to the NTDS.dit file, and usage of tools like vssadmin
, diskshadow
, or ntdsutil
. Below is a Splunk query to detect suspicious activities associated with dumping NTDS.dit.
Splunk Query to Detect NTDS.dit Dumping
Query Breakdown
Targeted Event Codes:
4688: Detects process creation for commands like
vssadmin
,diskshadow
, andntdsutil
.4663: Tracks object access to files like
NTDS.dit
.5145: Monitors file share access to directories containing
NTDS.dit
.
Filter Suspicious Commands and Access:
Detects:
Shadow copy creation commands (
vssadmin
,diskshadow
).Attempts to access
NTDS.dit
.File share access to the
\\NTDS\\
directory.
Aggregate and Summarise:
Groups events by
ComputerName
andEventCode
.Aggregates suspicious commands, accessed objects, and involved accounts.
Suspicious Scoring:
Assigns High or Medium scores to events based on their likelihood of being malicious:
High: Shadow copy creation or direct NTDS.dit access.
Medium: Remote file share access to NTDS.dit.
Output:
Displays the computer, suspicious commands, accessed objects, accounts, source IPs, and event details for investigation.
Reference
Last updated