SAM Registry Hive Handle Request#


Adversaries might be getting a handle to the SAM database to extract credentials in my environment

Technical Context#

Every computer that runs Windows has its own local domain; that is, it has an account database for accounts that are specific to that computer. Conceptually,this is an account database like any other with accounts, groups, SIDs, and so on. These are referred to as local accounts, local groups, and so on. Because computers typically do not trust each other for account information, these identities stay local to the computer on which they were created.

Offensive Tradecraft#

Adversaries might use tools like Mimikatz with lsadump::sam commands or scripts such as Invoke-PowerDump to get the SysKey to decrypt Security Account Mannager (SAM) database entries (from registry or hive) and get NTLM, and sometimes LM hashes of local accounts passwords.

In addition, adversaries can use the built-in Reg.exe utility to dump the SAM hive in order to crack it offline.

Additional reading

Pre-Recorded Security Datasets#





Download Dataset#

import requests
from zipfile import ZipFile
from io import BytesIO

url = ''
zipFileRequest = requests.get(url)
zipFile = ZipFile(BytesIO(zipFileRequest.content))
datasetJSONPath = zipFile.extract(zipFile.namelist()[0])

Read Dataset#

import pandas as pd
from import json

df = json.read_json(path_or_buf=datasetJSONPath, lines=True)


A few initial ideas to explore your data and validate your detection logic:

Analytic I#

Monitor for any handle requested for the SAM registry hive.

Data source

Event Provider



Windows registry


Process requested access Windows registry key


Windows registry


User requested access Windows registry key



SELECT `@timestamp`, Hostname, SubjectUserName, ProcessName, ObjectName, AccessMask
FROM dataTable
WHERE LOWER(Channel) = "security"
    AND EventID = 4656
    AND ObjectType = "Key"
    AND lower(ObjectName) LIKE "%sam"

Pandas Query#


[(df['Channel'].str.lower() == 'security')
    & (df['EventID'] == 4656)
    & (df['ObjectType'] == 'Key')
    & (df['ObjectName'].str.lower().str.endswith('sam', na=False))

Known Bypasses#

False Positives#

Hunter Notes#