1---2name: hunting-for-persistence-mechanisms-in-windows3description: Systematically hunt for adversary persistence mechanisms across Windows endpoints including registry, services, startup folders, and WMI subscriptions.4license: Apache-2.05---67# Hunting for Persistence Mechanisms in Windows89## When to Use1011- During periodic proactive threat hunts for dormant backdoors12- After an incident to identify all persistence mechanisms an attacker planted13- When investigating unusual services, scheduled tasks, or startup entries14- When threat intel reports describe new persistence techniques in the wild15- During security posture assessments to identify unauthorized persistent software1617## Detection Gaps & Validation1819- **Run-key-centric hunts miss the stealthy spots.** WMI event subscriptions (Sysmon EID 19/20/21), COM hijacks (`HKCU\...\CLSID\{..}\InprocServer32`), IFEO/GlobalFlag debuggers, and services created by direct registry edits (which generate no 4697) all evade Run-key/startup-folder sweeps.20- **Signed-but-malicious passes signature checks:** DLL sideloading into a legitimately signed application looks clean to "Signed=Yes" filters.21- **Scheduled tasks written via registry** (`...\Schedule\TaskCache\Tree`) rather than the API generate no 4698 — hunt the registry path, not just the event.22- **Validate the hunt fires:** run Atomic Red Team T1547.001 (Run key), T1546.003 (WMI consumer), and T1543.003 (service); confirm Sysmon EID 12/13 (registry), EID 19/20/21 (WMI), and Security 4697/4698 all fire and your detection flags the new entries.23- **FP tuning:** GPO/SCCM-deployed entries and legitimate vendor services dominate the noise — diff against an Autoruns baseline and triage by signer/hash/creation time.2425## Prerequisites2627- Sysmon deployed with Event IDs 12/13/14 (Registry), 19/20/21 (WMI), 1 (Process Creation)28- Windows Security Event forwarding for 4697 (Service Install), 4698 (Scheduled Task)29- EDR with registry and file monitoring capabilities30- PowerShell script block logging enabled (Event ID 4104)31- Autoruns or equivalent baseline of legitimate persistent entries3233## Workflow34351. **Enumerate Known Persistence Locations**: Build a comprehensive list of Windows persistence points (Run keys, services, scheduled tasks, WMI, startup folder, DLL search order, COM hijacks, AppInit DLLs, Image File Execution Options).362. **Collect Endpoint Data**: Use EDR, Sysmon, or Velociraptor to collect current persistence artifacts from endpoints across the environment.373. **Baseline Legitimate Persistence**: Compare collected data against known-good baselines (Autoruns snapshots, GPO-deployed entries, SCCM configurations).384. **Identify Anomalies**: Flag new, unsigned, or unknown entries in persistence locations that deviate from the baseline.395. **Investigate Suspicious Entries**: For each anomaly, examine the binary it points to, its digital signature, file hash, and creation timestamp.406. **Correlate with Process Activity**: Link persistence entries to process execution, network activity, and user login events.417. **Document and Remediate**: Record findings, remove malicious persistence, and update detection rules.4243## Key Concepts4445| Concept | Description |46|---------|-------------|47| T1547.001 | Registry Run Keys / Startup Folder |48| T1543.003 | Windows Service (Create or Modify) |49| T1053.005 | Scheduled Task |50| T1546.003 | WMI Event Subscription |51| T1546.015 | Component Object Model (COM) Hijacking |52| T1546.012 | Image File Execution Options Injection |53| T1546.010 | AppInit DLLs |54| T1547.004 | Winlogon Helper DLL |55| T1547.005 | Security Support Provider |56| T1574.001 | DLL Search Order Hijacking |57| TA0003 | Persistence Tactic |58| Autoruns | Sysinternals tool showing persistent entries |5960## Tools & Systems6162| Tool | Purpose |63|------|---------|64| Sysinternals Autoruns | Comprehensive persistence enumeration |65| Velociraptor | Endpoint-wide persistence artifact collection |66| CrowdStrike Falcon | Real-time persistence monitoring |67| Sysmon | Registry and WMI event monitoring |68| OSQuery | SQL-based persistence queries |69| RECmd | Registry Explorer for forensic analysis |70| Splunk | SIEM correlation of persistence events |7172## Common Scenarios73741. **Registry Run Key Backdoor**: Malware adds `HKCU\Software\Microsoft\Windows\CurrentVersion\Run` entry pointing to payload in `%APPDATA%`.752. **WMI Event Subscription**: Adversary creates WMI consumer/filter pair that executes PowerShell on system boot.763. **Malicious Service**: Attacker creates Windows service with `sc create` pointing to a backdoor binary.774. **COM Object Hijack**: Legitimate COM CLSID InprocServer32 path replaced with malicious DLL.785. **IFEO Debugger Injection**: Image File Execution Options key set with debugger pointing to implant for common utilities.7980## Output Format8182```83Hunt ID: TH-PERSIST-[DATE]-[SEQ]84Persistence Type: [Registry/Service/Task/WMI/COM/Other]85MITRE Technique: T1547.xxx / T1543.xxx / T1053.xxx86Location: [Full registry key / service name / task path]87Value: [Binary path / command line]88Host(s): [Affected endpoints]89Signed: [Yes/No]90Hash: [SHA256]91Creation Time: [Timestamp]92Risk Level: [Critical/High/Medium/Low]93Verdict: [Malicious/Suspicious/Benign]94```