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:
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 Registry Hives (Run as Administrator):Transferring the Hives to the Attack Host
π― Use smbserver.py
from Impacket to share a directory on your attack box:
On attack Box
Start the SMB Server
On Target Machine
Move files from the Windows machine to your SMB share:
π Confirm transfer:
Dumping Hashes with secretsdump.py
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
Dump LSA Secrets Remotely:
β Sample Output:
Dump SAM Hashes Remotely:
β Sample Output:
π§ Key Takeaways
𧬠SAM & SYSTEM hives are crucial to decrypt and extract password hashes.
π NTLM hashes (mode 1000) are the main targets for cracking.
π§° Tools used:
π Cracked passwords may give access to other systems due to password reuse.
π Always check for cached domain creds in
HKLM\SECURITY
if on a domain-joined target.
Last updated