Paso 1: Instalar DSInternals en PowerShell. Ejecutar este comando:
Install-Module -Name DSInternals -Force -AllowClobber
Si sale error de NuGet. Ejecutar este comando
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Comprobar que NuGet está instalado. Ejecutar este comando:
Get-PackageProvider -ListAvailable
Si aparece NuGet seguimos al paso 2.
Paso 2: Importar el Módulo DSInternals. Ejecutar este comando:
Import-Module DSInternals
Comprobar que se ha importado correctamente. Ejecutar este comando:
Get-Module -ListAvailable -Name DSInternals
Paso 3: Generar una copia del archivo NTDS.dit. Ejecutar el siguiente comando:
ntdsutil «ac i ntds» «ifm» «create full C:\Backup» q q
Paso 4: Extraer la clave de cifrado del Archivo SYSTEM. Ejecutar este comando:
$BootKey = Get-BootKey -Path «C:\Backup\registry\SYSTEM»
Paso 5: Extraer los hashes de Active Directory. Ejecutar este comando:
$hashes = Get-ADDBAccount -All -DatabasePath «C:\Backup\Active Directory\ntds.dit» -BootKey $BootKey
Paso 6: Mostrar los Hashes de los Usuarios. Ejecutar este comando:
$hashes | ForEach-Object {
[PSCustomObject]@{
SamAccountName = $_.SamAccountName
NTHash = if ($_.NTHash) { ($_.NTHash | ForEach-Object { $_.ToString(«X2″) }) -join » } else { «NoHash» }
LMHash = if ($_.LMHash) { ($_.LMHash | ForEach-Object { $_.ToString(«X2″) }) -join » } else { «NoHash» }
}
} | Export-Csv -Path «C:\Backup\hashes_legibles.csv» -NoTypeInformation
Paso 7. Comprobar que en el CSV aparece correctamente los Hashes en formato Hexadecimal
Se comprueba si en el CSV aparece Hashes de formato hexadecimal con una longitud de 32 caracteres (A-F, 0-9).
Ejemplo de Hash correcto: E52CAC67419A9A2238F10713B629B41B.