Hunting for Registry Run Key Persistence
Overview
Registry Run keys (T1547.001) are one of the most commonly used persistence mechanisms by adversaries. When a program is added to a Run key in the Windows registry, it executes automatically when a user logs in. Attackers abuse keys under HKLM\Software\Microsoft\Windows\CurrentVersion\Run, HKCU\Software\Microsoft\Windows\CurrentVersion\Run, and their RunOnce counterparts to maintain persistence. Sysmon Event ID 13 (RegistryEvent - Value Set) captures registry value modifications including the target object path, the process that made the change, and the new value. Detection involves monitoring these events for suspicious executables in temp directories, encoded PowerShell commands, LOLBin paths, and processes that do not normally create Run key entries. Chaining Event 13 with Event 1 (Process Creation) and Event 11 (FileCreate) strengthens detection by confirming payload creation and execution.
When to Use
- When investigating security incidents that require hunting for registry run key persistence
- When building detection rules or threat hunting queries for this domain
- When SOC analysts need structured procedures for this analysis type
- When validating security monitoring coverage for related attack techniques
Prerequisites
- Windows systems with Sysmon installed and configured to log Event ID 13
- Sysmon config with RegistryEvent rules for Run/RunOnce keys
- Python 3.9+ with
json, xml.etree.ElementTree, re modules
- SIEM or log aggregator collecting Sysmon logs (Splunk, Elastic, Sentinel)
- Knowledge of legitimate auto-start programs for baseline comparison
Steps
- Collect Sysmon Event ID 13 logs filtered for Run/RunOnce key paths
- Parse event XML/JSON for TargetObject, Details (value written), Image (modifying process)
- Flag entries where the value points to temp directories, AppData, or ProgramData
- Detect encoded PowerShell commands or script interpreters in registry values
- Identify LOLBin abuse (mshta.exe, rundll32.exe, regsvr32.exe, wscript.exe)
- Compare against known-good baseline of legitimate auto-start entries
- Check if the modifying process (Image) is unusual (cmd.exe, powershell.exe, python.exe)
- Chain with Event ID 1 to verify if the registered binary was recently created
- Generate detection report with MITRE ATT&CK mapping and severity scores
- Produce Sigma/Splunk detection rules from findings
Expected Output
A JSON report listing suspicious Run key entries with the registry path, value written, modifying process, timestamp, MITRE technique mapping, severity rating, and recommended Sigma detection rules.
1---
2name: hunting-for-registry-run-key-persistence
3description: Detect MITRE ATT&CK T1547.001 registry Run key persistence by analyzing
4 Sysmon Event ID 13 logs and registry queries to identify malicious auto-start entries.
5domain: cybersecurity
6subdomain: threat-hunting
7tags:
8- persistence
9- registry-run-keys
10- t1547-001
11- sysmon
12- threat-hunting
13- windows-forensics
14- mitre-attack
15version: '1.0'
16author: mahipal
17license: Apache-2.0
18d3fend_techniques:
19- Executable Denylisting
20- Execution Isolation
21- File Metadata Consistency Validation
22- Content Format Conversion
23- File Content Analysis
24nist_csf:
25- DE.CM-01
26- DE.AE-02
27- DE.AE-07
28- ID.RA-05
29mitre_attack:
30- T1046
31- T1057
32- T1082
33- T1083
34- T1547
35source: https://github.com/mukul975/Anthropic-Cybersecurity-Skills
36source_commit: 04450304b12645cb2b974ab96d28c0664758a88d
37metadata:
38 source: https://skillmd.com/skills/yanacuti1121/hunting-for-registry-run-key-persistence
39---
40
41# Hunting for Registry Run Key Persistence
42
43## Overview
44
45Registry Run keys (T1547.001) are one of the most commonly used persistence mechanisms by adversaries. When a program is added to a Run key in the Windows registry, it executes automatically when a user logs in. Attackers abuse keys under `HKLM\Software\Microsoft\Windows\CurrentVersion\Run`, `HKCU\Software\Microsoft\Windows\CurrentVersion\Run`, and their RunOnce counterparts to maintain persistence. Sysmon Event ID 13 (RegistryEvent - Value Set) captures registry value modifications including the target object path, the process that made the change, and the new value. Detection involves monitoring these events for suspicious executables in temp directories, encoded PowerShell commands, LOLBin paths, and processes that do not normally create Run key entries. Chaining Event 13 with Event 1 (Process Creation) and Event 11 (FileCreate) strengthens detection by confirming payload creation and execution.
46
47
48## When to Use
49
50- When investigating security incidents that require hunting for registry run key persistence
51- When building detection rules or threat hunting queries for this domain
52- When SOC analysts need structured procedures for this analysis type
53- When validating security monitoring coverage for related attack techniques
54
55## Prerequisites
56
57- Windows systems with Sysmon installed and configured to log Event ID 13
58- Sysmon config with RegistryEvent rules for Run/RunOnce keys
59- Python 3.9+ with `json`, `xml.etree.ElementTree`, `re` modules
60- SIEM or log aggregator collecting Sysmon logs (Splunk, Elastic, Sentinel)
61- Knowledge of legitimate auto-start programs for baseline comparison
62
63## Steps
64
651. Collect Sysmon Event ID 13 logs filtered for Run/RunOnce key paths
662. Parse event XML/JSON for TargetObject, Details (value written), Image (modifying process)
673. Flag entries where the value points to temp directories, AppData, or ProgramData
684. Detect encoded PowerShell commands or script interpreters in registry values
695. Identify LOLBin abuse (mshta.exe, rundll32.exe, regsvr32.exe, wscript.exe)
706. Compare against known-good baseline of legitimate auto-start entries
717. Check if the modifying process (Image) is unusual (cmd.exe, powershell.exe, python.exe)
728. Chain with Event ID 1 to verify if the registered binary was recently created
739. Generate detection report with MITRE ATT&CK mapping and severity scores
7410. Produce Sigma/Splunk detection rules from findings
75
76## Expected Output
77
78A JSON report listing suspicious Run key entries with the registry path, value written, modifying process, timestamp, MITRE technique mapping, severity rating, and recommended Sigma detection rules.