Forensic ArtifactWindows: Registry

SAM — Security Accounts Manager

The SAM hive stores local user account information including password hashes (NTLM), account creation dates, last login times, login counts, and group memberships.

The Security Accounts Manager is the gatekeeper of local identity on every Windows system. Every local user account, every NTLM password hash, every logon timestamp, and every group membership lives in this single registry hive — encrypted behind the system boot key but fully recoverable with the right tools and the SYSTEM hive.

What Is the SAM Hive?

The Security Accounts Manager (SAM) is a registry hive that stores the local user account database on every Windows installation from NT 3.1 (1993) through Windows 11. It contains one entry per local account under SAM\Domains\Account\Users, each identified by a Relative Identifier (RID). The default Administrator account always receives RID 500, Guest receives 501, and user-created accounts begin at 1000. Each account entry stores the username, NTLM password hash (in the V value), account creation date, last logon time, logon count, failed logon count, password last set timestamp, and account flags such as disabled, locked, or password-never-expires.

The SAM hive is loaded into the HKLM\SAM registry subtree at boot time. It is locked by the operating system while Windows is running — direct file access is denied to all processes including those running as SYSTEM. The password hashes stored within are double-encrypted: first with a per-account key derived from the user RID (the DES layer), then with the system boot key extracted from the SYSTEM hive. Without both the SAM and SYSTEM hives, hash extraction is not possible.

Domain-joined machines still maintain a local SAM. Domain accounts are authenticated against the domain controller (stored in ntds.dit), but any local accounts — including the built-in Administrator, service accounts, and break-glass accounts — remain in the SAM. Lateral movement investigations frequently reveal that attackers extracted the SAM to harvest local administrator credentials that were reused across the fleet.

Key Insight

The SAM hive records account creation timestamps, last logon times, and logon counts that survive password resets and user profile deletion. Even if an attacker deletes a user account, Volume Shadow Copies and forensic images preserve the SAM state at earlier points in time, allowing investigators to prove the account existed.

Location & Format

File Paths

FilePathNotes
SAM (live)C:\Windows\System32\config\SAMLocked by OS while running; requires raw copy or VSS
SAM (RegBack)C:\Windows\System32\config\RegBack\SAMAutomatic backup (disabled by default on Win 10 1803+)
SYSTEM (required)C:\Windows\System32\config\SYSTEMContains the boot key needed to decrypt SAM hashes
SAM (repair)C:\Windows\repair\SAMLegacy backup from original install; may contain initial hashes
Volume Shadow Copies\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy{N}\Point-in-time snapshots; invaluable for deleted account recovery

Internal Structure

The SAM hive is a standard Windows registry hive file (regf format). Its internal structure follows a fixed hierarchy rooted at SAM\Domains\Account. Two key subtrees contain the forensic data: Users (per-account entries keyed by RID in hexadecimal) and Names (username-to-RID mappings). Each user entry contains two critical binary values: F (fixed-length metadata including timestamps and flags) and V (variable-length data including the username string and encrypted password hashes).

SAM\Domains\Account\Users\000001F4 (RID 500 = Administrator)

F value (binary, 0x50 bytes): Contains last logon time (offset 0x08, FILETIME), account creation time (offset 0x18), password last set time (offset 0x28), last failed logon (offset 0x38), logon count (offset 0x42, WORD), and failed logon count (offset 0x44, WORD).

V value (binary, variable): Contains the username string, full name, comment, NT hash (encrypted), and LM hash (encrypted, usually empty on modern systems). Hash offsets are calculated from the V value header.

What It Reveals

Data PointLocation in SAMForensic Value
NTLM password hashV value (encrypted)Enables pass-the-hash detection; compare against known-compromised hash databases
Account creation timeF value offset 0x18Proves when an account was created; detects backdoor accounts created during intrusions
Last logon timeF value offset 0x08Establishes most recent interactive logon; correlate with event logs
Logon countF value offset 0x42Low count on old account suggests dormant/unused; high count on new account suggests active abuse
Failed logon countF value offset 0x44Brute-force evidence; count resets on successful logon
Password last setF value offset 0x28Detects password changes during incident; proves credential rotation (or lack thereof)
Account flagsF value offset 0x40 (UserAccountControl)Disabled, locked, password-never-expires, no-password-required flags
Group membershipsSAM\Domains\Builtin\AliasesRID-based membership lists for Administrators (0x220), Remote Desktop Users, etc.
Account namesSAM\Domains\Account\NamesUsername-to-RID mapping; detects renamed Administrator accounts
Account Flags Reference

The UserAccountControl field is a bitmask. Key flags: 0x0001 = Account Disabled, 0x0004 = Password Not Required, 0x0010 = Account Locked Out, 0x0200 = Normal Account. An account with 0x0004 set is a significant finding — it means blank-password logon is permitted.

Forensic Use Cases

Backdoor Account Detection

After gaining initial access, adversaries frequently create local accounts for persistence. The SAM records the exact account creation timestamp in the F value. By comparing account creation times against the known timeline of the intrusion, investigators can identify accounts created by the attacker. A local account created at 03:17 AM on the date of initial compromise, with the password-never-expires flag set and membership in the local Administrators group, is a high-confidence indicator of persistence.

Credential Theft Investigation

When an attacker extracts the SAM hive (via reg save, Volume Shadow Copy access, or tools like mimikatz), they obtain NTLM hashes that enable pass-the-hash attacks across the network. The SAM itself does not record that it was copied, but correlating evidence includes: Event ID 4688 showing reg.exe save HKLM\SAM, Prefetch entries for mimikatz.exe or secretsdump.py, and file system artifacts ($MFT, $UsnJrnl) showing SAM copies in staging directories.

Password Reuse Analysis

Extracting NTLM hashes from multiple systems and comparing them reveals password reuse. If the local Administrator account on 47 workstations shares the same NTLM hash, a single compromised credential gives the attacker lateral movement across the entire fleet. This analysis is performed by extracting hashes from each SAM/SYSTEM pair and grouping by hash value.

Insider Threat — Account Manipulation

Insiders with local admin rights may enable the disabled Guest account, remove password requirements, or add accounts to privileged groups. The SAM records the current state of all flags, and Volume Shadow Copies preserve historical states. Comparing the SAM across VSS snapshots reveals exactly when an account was enabled, when its flags changed, and when group memberships were modified.

Acquisition Methods

Live System — Volume Shadow Copy

CMD / ADMIN
:: Create a shadow copy to bypass OS file lock
vssadmin create shadow /for=C:

:: Copy SAM and SYSTEM from the shadow copy
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SAM C:\Evidence\
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\Evidence\

:: Alternative: reg save (requires SYSTEM privileges)
reg save HKLM\SAM C:\Evidence\SAM
reg save HKLM\SYSTEM C:\Evidence\SYSTEM

Live System — KAPE Collection

CMD / ADMIN
:: KAPE target collects SAM, SYSTEM, SECURITY, SOFTWARE, DEFAULT
kape.exe --tsource C: --tdest C:\Evidence\KAPE_Output --target RegistryHives

:: Or use RawCopy to bypass NTFS locks directly
RawCopy.exe /FileNamePath:C:\Windows\System32\config\SAM /OutputPath:C:\Evidence\
RawCopy.exe /FileNamePath:C:\Windows\System32\config\SYSTEM /OutputPath:C:\Evidence\

Forensic Image — Direct Extraction

BASH / FORENSICS
# Mount the forensic image (read-only)
mount -o ro,noexec,nodev /dev/sdb1 /mnt/evidence

# Copy SAM and SYSTEM hives
cp /mnt/evidence/Windows/System32/config/SAM /analysis/sam/
cp /mnt/evidence/Windows/System32/config/SYSTEM /analysis/sam/

# Also grab RegBack copies if they exist
cp /mnt/evidence/Windows/System32/config/RegBack/SAM /analysis/sam/SAM.regback 2>/dev/null
cp /mnt/evidence/Windows/System32/config/RegBack/SYSTEM /analysis/sam/SYSTEM.regback 2>/dev/null

Parsing Tools & Analysis

ToolAuthorLicenseOutputNotes
RegRipper (samparse)Harlan CarveyOpen source (Perl)Textsamparse plugin extracts all user account metadata from SAM
secretsdump.pyImpacketOpen source (Python)TextExtracts NTLM hashes; supports local SAM/SYSTEM pair or remote DCE/RPC
mimikatzBenjamin DelpyOpen sourceTextlsadump::sam module; works on live system or offline hives
Registry ExplorerEric ZimmermanFreeGUIVisual registry browser; auto-decodes F/V binary values
samdump2Objectif SecuriteOpen sourceTextLinux-native SAM hash extractor; requires SYSTEM hive
chntpwPetter Nordahl-HagenOpen sourceInteractiveCan list accounts, reset passwords, and edit SAM offline

Hash Extraction with secretsdump.py

BASH / FORENSICS
# Extract NTLM hashes from offline SAM + SYSTEM hives
secretsdump.py -sam /analysis/sam/SAM -system /analysis/sam/SYSTEM LOCAL

# Output format: username:RID:LMhash:NThash:::
# Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
# Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
# svc_backup:1001:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::

Account Metadata with RegRipper

BASH / FORENSICS
# Run the samparse plugin against the SAM hive
rip.pl -r /analysis/sam/SAM -p samparse

# Output includes per-account:
# Username, Full Name, Account Created, Last Login
# Password Last Set, Login Count, Failed Login Count
# Account Flags (Disabled, Locked, PW Never Expires, etc.)
# Group Memberships (Administrators, Remote Desktop Users, etc.)

Sample Output — Backdoor Account Detection

OUTPUT
Username        : svc_backup
Full Name       :
Account Created : 2026-02-14 03:17:42 UTC
Last Login      : 2026-02-14 03:18:01 UTC
Pwd Last Set    : 2026-02-14 03:17:42 UTC
Login Count     : 1
Failed Logins   : 0
Flags           : Password does not expire | Normal account
Groups          : Administrators, Remote Desktop Users
Reading the Output

This account was created at 03:17 UTC — outside business hours. It was added to both Administrators and Remote Desktop Users immediately. The password-never-expires flag was set at creation time. Login count of 1 with the last login 19 seconds after creation suggests the attacker verified access once, then relied on other channels. The empty Full Name field is atypical for legitimate service accounts, which are usually documented. Cross-reference the creation timestamp with Security.evtx Event ID 4720 (account created) and 4732 (member added to local group).

Retention & Persistence

PropertyDetail
Retention periodPermanent — entries exist for the lifetime of the OS installation
Survives rebootYes — registry hive is persisted to disk
Survives password resetYes — account metadata (creation date, logon count) persists; only the hash changes
Survives user profile deletionYes — SAM is system-level, independent of user profiles
Survives account deletionNo — the account entry is removed from the active SAM; recoverable from VSS or forensic carving
RegBack copiesAutomatic backup to RegBack\ (disabled by default on Windows 10 1803+ unless re-enabled via registry)
Update triggerModified on any account change: logon, password change, flag change, group membership change
RegBack Deprecation

Starting with Windows 10 version 1803, Microsoft disabled automatic registry backups to the RegBack directory. The folder still exists but the files are 0 bytes. To re-enable, set HKLM\System\CurrentControlSet\Control\Session Manager\Configuration Manager\EnablePeriodicBackup to 1 (DWORD). On older systems, RegBack copies can provide historical SAM states that predate the current hive.

Boot Key & Encryption

SAM password hashes are not stored in cleartext. The encryption scheme uses a two-layer approach that requires the SYSTEM hive to decrypt:

Why You Need the SYSTEM Hive

Without the SYSTEM hive, the boot key cannot be derived, and the SAM hashes cannot be decrypted. Always collect both SAM and SYSTEM from the same machine at the same time. If collecting from Volume Shadow Copies, ensure both files come from the same snapshot to maintain key consistency.

Anti-Forensics Resilience

The SAM hive is a system-critical file protected by the operating system. It is locked while Windows is running and resides in a privileged directory. Standard cleanup tools do not target it.

ToolClears SAM?Explanation
CCleanerNoNo module targets registry hive files in System32\config\
EraserNoCannot access locked system files
SDeleteNoWipes specified files; SAM is locked and not a standard target
BleachBitNoNo SAM cleaning module exists
net user /deletePartialRemoves the account entry from the active SAM, but VSS snapshots and disk-level carving can recover it
wevtutil cl SecurityNoClears the Security event log, not the SAM hive; but destroys corroborating 4720/4722/4732 events
Offline password reset (chntpw)PartialModifies the hash in the SAM but does not alter timestamps or logon counts
Attacker Technique: SAM Hive Exfiltration

Sophisticated attackers do not modify the SAM — they copy it. Using reg save HKLM\SAM, Volume Shadow Copy access, or tools like mimikatz (lsadump::sam), they extract hashes for offline cracking or pass-the-hash attacks. The SAM itself shows no evidence of being copied. Detection relies on correlating Event ID 4688 (process creation for reg.exe), Sysmon Event ID 1, Prefetch entries, and file system artifacts showing SAM copies in unexpected locations.

MITRE ATT&CK Detection Mapping

The SAM hive provides evidentiary support for detecting the following MITRE ATT&CK techniques:

TechniqueNameSAM Evidence
T1003.002 T1003.002OS Credential Dumping: SAMDirect target; extracted hashes enable pass-the-hash lateral movement
T1087 T1087Account DiscoverySAM enumeration reveals all local accounts, RIDs, and group memberships
T1136 T1136Create AccountAccount creation timestamps in SAM F value prove when backdoor accounts were created
T1078 T1078Valid AccountsLogon count and last logon time reveal which accounts were actively used during the intrusion window
T1098 T1098Account ManipulationFlag changes (enabling disabled accounts, setting password-never-expires) are recorded in the SAM state
T1110 T1110Brute ForceFailed logon count in SAM tracks unsuccessful authentication attempts against local accounts

Related Artifacts & Cross-References

Corroborating Artifacts

ArtifactRelationship to SAMCross-Correlation Value
Security.evtxEvent IDs 4720 (account created), 4722 (enabled), 4724 (password reset), 4732 (added to group)Provides the “who did it” context that SAM lacks — SAM records the state, Security.evtx records the actor
SYSTEM hiveContains the boot key required to decrypt SAM hashesEssential companion artifact; must be collected alongside SAM
NTUSER.DATPer-user registry hive; contains MRU lists, typed paths, recent documentsAssociates account activity in SAM with specific user actions on the system
PrefetchExecution evidence for credential dumping toolsPrefetch entries for mimikatz.exe, secretsdump, reg.exe corroborate SAM extraction
$MFT / $UsnJrnlFile system timestamps for SAM copiesReveals when and where SAM copies were created (e.g., C:\Temp\SAM)
SRUM.dbNetwork usage per applicationCan show network activity from credential dumping tools that exfiltrated SAM hashes

References

  1. Impacket Project, “secretsdump.py” — https://github.com/fortra/impacket
  2. Harlan Carvey, “RegRipper — samparse plugin” — https://github.com/keydet89/RegRipper3.0
  3. Benjamin Delpy, “mimikatz — lsadump::sam” — https://github.com/gentilkiwi/mimikatz
  4. Eric Zimmerman, “Registry Explorer” — https://ericzimmerman.github.io/
  5. Microsoft, “Security Accounts Manager” — https://learn.microsoft.com
  6. SANS Institute, “Windows Forensic Analysis — SAM Hive” — https://www.sans.org/posters/windows-forensic-analysis/
  7. 13Cubed, “SAM, SYSTEM, and SECURITY Hive Analysis” — https://www.13cubed.com
  8. MITRE ATT&CK, “T1003.002: OS Credential Dumping: SAM” — https://attack.mitre.org/techniques/T1003/002/

Mjolnir Security — Digital Forensics & Incident Response

Mjolnir Security provides 24/7 incident response, digital forensics, and expert witness testimony. Our DFIR team specializes in credential theft investigations, SAM hive analysis, and pass-the-hash attack reconstruction across enterprise environments.

Digital ForensicsIncident ResponseExpert WitnessArtifact AnalysisCredential TheftInsider Threat

mjolnirsecurity.com — 24/7: +1 833 403 5875