Active Directory / ARTICLE

NTDS dumping attack

بسم الله والصلاة والسلام على رسول الله, اللهم علمنا ما ينفعنا وانفعنا بما علمتنا وقنا عذاب النار


Labs of this article

LAB 1 : NTDS dumping attack

https://anas404.gitbook.io/anas404/htb-labs/lab-1-ntds-dumping-attack

LAB 2 : NTDS dumping attack

https://anas404.gitbook.io/anas404/htb-labs/lab-2-ntds-dumping-attack

preparation

What NTDS.dit ?\
containsThis single database file stores essential information for managing and authenticating users and resources across a network. It contains:

  • Users, groups, and computers: Details about every object in the domain.
  • Password hashes
  • Group memberships: Records of which users belong to which groups.
  • Schema definitions: The rules that define the structure and attributes of all objects in the directory.
  • Configuration data: Information about the domain’s structure, replication settings, and more.

Adversaries may attempt to access or create a copy of the Active Directory domain database in order to steal credential information, as well as obtain other information about domain members such as devices, users, and access rights. By default, the NTDS file (NTDS.dit) is located in %SystemRoot%\NTDS\Ntds.dit of a domain controller.

registry path :

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters

In addition to looking for NTDS files on active Domain Controllers, adversaries may search for backups that contain the same or similar information.[2]

The following tools and techniques can be used to enumerate the NTDS file and the contents of the entire Active Directory hashes.

  • Volume Shadow Copy
  • secretsdump.py
  • Using the in-built Windows tool, ntdsutil.exe
  • Invoke-NinjaCopy

https://attack.mitre.org/techniques/T1003/003/

After obtaining the password hashes from the NTDS.dit file, attackers can attempt to crack them offline to obtain the plaintext passwords. If they are unable to crack the hashes offline, they could also try using the password hashes in pass-the-hash attacks to further exploit the environment.

A Pass-the-Hash (PtH) attack is a technique where an attacker captures a password hash (as opposed to the password characters). The threat actor then passes it through for authentication and lateral access to other networked systems.

NTDSUTILis a Microsoft command-line tool for managing Active Directory Domain Services (AD DS) database and performing advanced maintenance tasks, such as database cleanup, restoring snapshots, and managing single master operation roles\
attacker can exploit NTDSUTIL to gain access to this database

Here are some common methods of acquiring NTDS.dit:

  1. Access the virtual hard drive directly for a DC based on a VM
  2. Use ntdsutil
  3. Use diskshadow
  4. Use vssadmin*
  5. Use wmic*

https://trustedsec.com/blog/exploring-ntds-dit-part-1-cracking-the-surface-with-dit-explorer

https://redcanary.com/threat-detection-report/techniques/os-credential-dumping/

Attack Tutorial: How NTDS.dit Password Extraction Works

https://www.netwrix.com/ntds_dit_security_active_directory.html

https://blog.netwrix.com/2021/11/30/extracting-password-hashes-from-the-ntds-dit-file/


Detection

Event ID 325 and 327

  • from Application, system & security logs
  • event source “ESENT” in application logs.
  • These events are logged when a new database is created and when a database is detached respectively.

We need to look for any file path for the newly created database (such as a dumped copy of the original NTDS.dit) besides its original path of %SystemRoot%\ntds. Any copy of NDTS.dit present in another location strongly indicates malicious behavior.

event ID 7036

  • system log
  • orrelate with our application logs findings

we see two services related to Volume shadow, which started running just a second before the creation of the NTDS.dit database

event ID 4799

  • Security logs

We need to look for an event where two security groups (Backup Operators and Administrator) were being enumerated by the ntdsutil.exe process

Event ID 4688 (Microsoft Windows Security Auditing) and 1 (Microsoft Windows Sysmon)

  • provide context of commands and parameters being executed via creation of a new process

Event ID 800 (PowerShell)

  • provides context of commands and parameters being executed via PowerShell “800”

Command line attempt to access or create a copy of ntds.dit file

((sourcetype=”WinEventLog:Microsoft-Windows-Powershell/Operational” EventCode=”800″) AND((CommandLine LIKE “%ntds%” AND CommandLine LIKE “%ntdsutil%” AND CommandLine LIKE “%create%”) OR (CommandLine LIKE “%vssadmin%” AND CommandLine LIKE “%create%” AND CommandLine LIKE “%shadow%”) OR (CommandLine LIKE “%copy%” AND CommandLine LIKE “%ntds.dit%”)))

Events 4656 and 4663

  • provide context of processes and users requesting access or accessing file objects (ObjectType = File) such as C:\Windows\NTDS\ntds.dit

Events 4656 and 4663 (Microsoft Windows Security Auditing)

  • provide context of processes and users creating or copying file objects (ObjectType = File) such as C:\Windows\NTDS\ntds.dit

Event 11 (Microsoft Windows Sysmon)

  • provide context of processes and users creating or copying files. Unfortunately, this event provides context of the file being created or copied, but not the file being copied.
  • Active Directory Dumping via NTDSUtil

(sourcetype=WinEventLog:Security EventCode IN (4656, 4663)) OR (sourcetype=WinEventLog:Microsoft-Windows-Sysmon/Operational EventCode=”11″) ANDObjectType=”File” AND TargetFilename=”*ntds.dit” AND (AccessList=”%%4416″ OR AccessList=”%%4419″ OR AccessList=”%%4417″ OR AccessList=”%%4424″)


← All journal articles
Scroll to Top
Home