Credential Hunting
Gathering credentials is one of the most effective ways to escalate privileges on Windows systems. This document covers common locations and methods to find stored credentials on Windows machines.
File System Searches for Credentials
When hunting for credentials, performing file system searches is often fruitful. Look for configuration files and documents that might contain passwords:
# Recursively search for files with "pass" in the name or ending in ".config"
dir /s /b *pass* == *.config
# Search for the word "password" in common configuration files
findstr /si password *.xml *.ini *.txt *.config *.conf
findstr /si credential *.xml *.ini *.txt *.config *.conf
# More targeted search for credentials in specific directories
findstr /spin "password" C:\Users\*.txt C:\Users\*.ini C:\Users\*.xml
findstr /spin "password" C:\inetpub\*.config C:\Program Files\*.config
# Find common configuration files that might contain credentials
dir /s /b web.config
dir /s /b php.ini
dir /s /b wp-config.php
dir /s /b *credential*
# Find all files containing the word "password" across the entire drive (be patient)
findstr /spin /c:"password" C:\*.* 2>nulUnattended Windows Installations
When deploying Windows across multiple machines, administrators often use unattended installation files which may contain credentials. Check these locations:
Look for credential sections in these files:
Extracting SAM and SYSTEM Hives
The SAM (Security Account Manager) database contains local user account passwords in hashed format. With the SAM and SYSTEM files, you can extract and crack password hashes offline.
SAM/SYSTEM File Locations
Copying SAM and SYSTEM Files
Since these files are locked while Windows is running, you can use several methods to copy them:
Method 1: Using Volume Shadow Copy (requires admin privileges)
Method 2: Using reg save (requires admin privileges)
Method 3: Using Backup Privileges (SeBackupPrivilege)
If you have SeBackupPrivilege, you can copy these files even without full admin rights:
Extracting Hashes from SAM/SYSTEM
After obtaining the files, transfer them to your attack machine and use tools to extract hashes:
Example Scenario
During a penetration test, after obtaining administrative privileges:
PowerShell History
PowerShell saves command history, which might contain credentials used in commands:
Saved Windows Credentials
Windows allows saving credentials for later use, which can be listed and used:
IIS Configuration Files
Internet Information Services (IIS) configuration files often contain database connection strings with credentials:
Credentials in Software Configurations
PuTTY
PuTTY client might store proxy credentials:
WinSCP
WinSCP may save session information with obfuscated passwords:
Remote Desktop Credentials
Saved RDP connections may contain credentials:
Credentials in Registry
Windows may store credentials in the registry:
Credentials Manager
Windows Credential Manager stores credentials for websites, applications, and networks:
Browser Stored Credentials
Browsers often store login credentials that can be extracted:
Tools like LaZagne can automate the extraction of browser credentials.
Configuration Files
Many applications store credentials in configuration files:
Real-World Examples
Example 1: PowerShell History
A system administrator ran a command that included credentials:
Example 2: IIS Web.config
A web.config file with database credentials:
Example 3: Using Saved Credentials
Using runas with saved credentials to run commands as another user:
Example 4: PuTTY Saved Session
Extracting a saved password from PuTTY:
Automated Credential Hunting Tools
LaZagne: Retrieves passwords stored on a local computer
Mimikatz: Extracts plaintext passwords, hashes, and tickets from memory
SessionGopher: Extracts saved session information for remote access tools
SharpWeb: .NET tool for grabbing credentials from web browsers
Password Dumping Tools
Several specialized tools exist for extracting password hashes from Windows systems:
PWDump and Variants
PWDump and its variants (PWDump7, fgdump, etc.) are command-line tools designed to extract password hashes from the SAM database. They can obtain NTLM and LM hashes from a Windows system, even while the system is running.
Impacket Tools
Impacket's secretsdump can extract NTLM hashes, Kerberos keys, and other credentials from a remote system or from local registry hives.
Metasploit Modules
If you have a Meterpreter session:
Cracking the Hashes
After obtaining hashes, you can attempt to crack them:
OSCP Notes on Password Dumping
For the OSCP exam:
Always have multiple password dumping tools ready, as some may trigger antivirus
PWDump variants are useful for quickly extracting hashes locally
Impacket-secretsdump is versatile for both remote and local extraction
Remember to document the complete process:
How you obtained the necessary privileges
How you extracted the hashes
Any attempts to crack or use the hashes
Pass-the-Hash (PtH) Attacks
Once you have obtained password hashes from a Windows system, instead of attempting to crack them (which can be time-consuming or impossible for complex passwords), you can use the hashes directly for authentication using the "Pass-the-Hash" technique.
Understanding Pass-the-Hash
Pass-the-Hash (PtH) exploits the way Windows authentication protocols like NTLM work. Instead of requiring the plaintext password, these protocols use the password hash for authentication. This means if you have the hash, you can authenticate without knowing the actual password.
Tools for Pass-the-Hash
pth-winexe: A modified version of winexe that accepts NTLM hashes
Impacket Suite Tools:
CrackMapExec:
LM and NTLM Hashes Format
When using Pass-the-Hash tools, you typically need both the LM and NTLM hash portions:
LM hash: Usually the first part (aad3b435b51404eeaad3b435b51404ee is the empty LM hash in modern Windows)
NTLM hash: The second part, which is the actual NTLM hash of the password
The full hash format is: LM:NTLM
OSCP Exam Tips
For the OSCP exam:
Efficiency: Pass-the-Hash is much faster than password cracking, especially for complex passwords
Impacket tools are the most reliable and officially allowed on the exam
Always have multiple PtH options ready in case one method fails
Test various login methods - some may work while others fail due to service configurations
Document your approach - showing you understand PtH attack methodology is important
Real-World Example
After extracting hashes from a Windows system:
Defense Against Pass-the-Hash
Organizations can implement these mitigations:
Credential Guard in Windows 10/Server 2016+ to protect credential hashes
LAPS (Local Administrator Password Solution) to use unique local admin passwords
Protected Users security group for sensitive accounts
Network segmentation to limit lateral movement
Monitoring for suspicious authentication patterns
Automated Credential Hunting Tools
LaZagne: Retrieves passwords stored on a local computer
Mimikatz: Extracts plaintext passwords, hashes, and tickets from memory
SessionGopher: Extracts saved session information for remote access tools
SharpWeb: .NET tool for grabbing credentials from web browsers
Password Dumping Tools
Several specialized tools exist for extracting password hashes from Windows systems:
PWDump and Variants
PWDump and its variants (PWDump7, fgdump, etc.) are command-line tools designed to extract password hashes from the SAM database. They can obtain NTLM and LM hashes from a Windows system, even while the system is running.
Impacket Tools
Impacket's secretsdump can extract NTLM hashes, Kerberos keys, and other credentials from a remote system or from local registry hives.
Metasploit Modules
If you have a Meterpreter session:
Cracking the Hashes
After obtaining hashes, you can attempt to crack them:
OSCP Notes on Password Dumping
For the OSCP exam:
Always have multiple password dumping tools ready, as some may trigger antivirus
PWDump variants are useful for quickly extracting hashes locally
Impacket-secretsdump is versatile for both remote and local extraction
Remember to document the complete process:
How you obtained the necessary privileges
How you extracted the hashes
Any attempts to crack or use the hashes
Countermeasures
To protect against credential hunting:
Avoid storing credentials in plain text
Use Windows Credential Guard
Implement strong password policies
Regularly audit stored credentials
Avoid saving credentials when not necessary
Use more secure authentication methods like Windows Hello or smart cards
Last updated