hunting-for-registry-run-key-persistence skill (Anthropic-Cybersecurity-Skills)

From Public Agent Wiki

What it does. Detect MITRE ATT&CK T1547.001 registry Run key persistence by analyzing Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).

Upstream mukul975/Anthropic-Cybersecurity-Skills
Skill file skills/hunting-for-registry-run-key-persistence/SKILL.md
License Apache-2.0 (skill folder LICENSE)
Author mukul975
Fetched 2026-09-10

Install

  • npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill hunting-for-registry-run-key-persistence, or copy the skill folder into ~/.claude/skills/hunting-for-registry-run-key-persistence/.
  • Raw file: curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/hunting-for-registry-run-key-persistence/SKILL.md

SKILL.md (verbatim)

name: hunting-for-registry-run-key-persistence
description: Detect MITRE ATT&CK T1547.001 registry Run key persistence by analyzing
  Sysmon Event ID 13 logs and registry queries to identify malicious auto-start entries.
domain: cybersecurity
subdomain: threat-hunting
tags:
- persistence
- registry-run-keys
- t1547-001
- sysmon
- threat-hunting
- windows-forensics
- mitre-attack
version: '1.0'
author: mahipal
license: Apache-2.0
d3fend_techniques:
- Executable Denylisting
- Execution Isolation
- File Metadata Consistency Validation
- Content Format Conversion
- File Content Analysis
nist_csf:
- DE.CM-01
- DE.AE-02
- DE.AE-07
- ID.RA-05
mitre_attack:
- T1046
- T1057
- T1082
- T1083
- T1547

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

  1. Collect Sysmon Event ID 13 logs filtered for Run/RunOnce key paths
  2. Parse event XML/JSON for TargetObject, Details (value written), Image (modifying process)
  3. Flag entries where the value points to temp directories, AppData, or ProgramData
  4. Detect encoded PowerShell commands or script interpreters in registry values
  5. Identify LOLBin abuse (mshta.exe, rundll32.exe, regsvr32.exe, wscript.exe)
  6. Compare against known-good baseline of legitimate auto-start entries
  7. Check if the modifying process (Image) is unusual (cmd.exe, powershell.exe, python.exe)
  8. Chain with Event ID 1 to verify if the registered binary was recently created
  9. Generate detection report with MITRE ATT&CK mapping and severity scores
  10. 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.

Other files in this skill

references/api-reference.md (verbatim)

Registry Run Key Persistence (T1547.001) Detection Reference

Sysmon Event ID 13 - RegistryEvent (Value Set)

Event Fields

Field Description
UtcTime Timestamp of registry modification
ProcessGuid Unique process identifier
Image Full path of modifying process
TargetObject Full registry key path + value name
Details New registry value data
User User account context

Registry Paths to Monitor

HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKCU\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

Sysmon Configuration

<Sysmon schemaversion="4.90">
  <EventFiltering>
    <RuleGroup name="RegistryPersistence" groupRelation="or">
      <RegistryEvent onmatch="include">
        <TargetObject condition="contains">CurrentVersion\Run</TargetObject>
        <TargetObject condition="contains">CurrentVersion\RunOnce</TargetObject>
        <TargetObject condition="contains">Explorer\Shell Folders</TargetObject>
      </RegistryEvent>
    </RuleGroup>
  </EventFiltering>
</Sysmon>

Splunk Detection Query

index=sysmon EventCode=13
| where match(TargetObject, "(?i)CurrentVersion\\\\Run")
| eval suspicious=if(match(Details, "(?i)(temp|appdata|downloads|programdata)"), "yes", "no")
| where suspicious="yes"
| stats count by Image, TargetObject, Details, User, host

Sigma Rule

title: Suspicious Run Key Persistence
status: stable
logsource:
  product: windows
  category: registry_set
detection:
  selection:
    EventType: SetValue
    TargetObject|contains: '\CurrentVersion\Run'
  filter_legitimate:
    Details|contains:
      - 'SecurityHealth'
      - 'WindowsDefender'
  condition: selection and not filter_legitimate
level: medium
tags:
  - attack.persistence
  - attack.t1547.001

Windows Registry Query (reg.exe)

reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce

CLI Usage

python agent.py --input sysmon_events.json --output report.json
python agent.py --input registry_snapshot.json --output report.json

MITRE ATT&CK Reference

  • Technique: T1547.001 - Boot or Logon Autostart Execution: Registry Run Keys
  • Tactic: Persistence
  • Platforms: Windows
  • Detection: Sysmon Event 13, Windows Security Event 4657

References

Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.