Attacking SAM (Security Account Manager)

When we gain local admin access to a non-domain joined Windows system, we can extract the SAM database and crack password hashes offline, avoiding the need to maintain an active session with the target.


Copying SAM Registry Hives

We need to extract the following registry hives:

Hive
Description

HKLM\SAM

Contains local account password hashes

HKLM\SYSTEM

Contains the system bootkey required to decrypt SAM

HKLM\SECURITY

Contains cached credentials (useful for domain-joined systems)

Using reg.exe Save Registry Hives (Run as Administrator):

reg.exe save hklm\sam C:\sam.save
reg.exe save hklm\system C:\system.save
reg.exe save hklm\security C:\security.save

Transferring the Hives to the Attack Host

🎯 Use smbserver.py from Impacket to share a directory on your attack box:

On attack Box

  1. Start the SMB Server

sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py -smb2support CompData /home/ltnbob/Documents/

On Target Machine

  1. Move files from the Windows machine to your SMB share:

πŸ“ Confirm transfer:


Dumping Hashes with secretsdump.py

  • On attacker machine

  • Once the SAM files has been transfered

πŸ”§ Use Impacket’s secretsdump.py to extract NT hashes from the registry hives:

🧾 Sample Output:

ℹ️ Output format: user:RID:LM Hash:NT Hash:::

πŸ“Œ NT Hashes are what you'll mostly target for cracking, especially on modern systems.


Cracking NT Hashes with Hashcat

πŸ“ Create a file with NT hashes:

⚑ Crack them using Hashcat with NTLM hash mode -m 1000 and the RockYou wordlist:

βœ… Sample Cracked Output:

πŸ’‘ These passwords can now be tested across other systemsβ€”users commonly reuse them.


Remote Dumping with CrackMapExec

With local admin credentials, you can dump secrets remotely using CrackMapExec (CME)arrow-up-right.

Dump LSA Secrets Remotely:

βœ… Sample Output:


Dump SAM Hashes Remotely:

βœ… Sample Output:


🧠 Key Takeaways

Last updated