Analyzing Malware Persistence with Autoruns
Overview
Sysinternals Autoruns extracts data from hundreds of Auto-Start Extensibility Points (ASEPs) on Windows, scanning 18+ categories including Run/RunOnce keys, services, scheduled tasks, drivers, Winlogon entries, LSA providers, print monitors, WMI subscriptions, and AppInit DLLs. Digital signature verification filters Microsoft-signed entries. The compare function identifies newly added persistence via baseline diffing. VirusTotal integration checks hash reputation. Offline analysis via -z flag enables forensic disk image examination.
When to Use
Trigger phrases:
"analyzing malware persistence with autoruns"
"Use Sysinternals Autoruns to systematically identify and analyze malware persist"
When investigating security incidents that require analyzing malware persistence with autoruns
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
- Sysinternals Autoruns (GUI) and Autorunsc (CLI)
- Administrative privileges on target system
- Python 3.9+ for automated analysis
- VirusTotal API key for reputation checks
- Clean baseline export for comparison
Workflow
- Isolate the sample — ensure the malware is in a sandboxed environment with no network access
- Record file metadata — hash the sample and note file type, size, and compile timestamp
- Static analysis — examine strings, imports, and disassembled code without execution
- Dynamic analysis — execute in a monitored sandbox and record behavior (file, registry, network)
- Document IOCs — extract indicators of compromise and write the analysis report
Step 1: Automated Persistence Scanning
#!/usr/bin/env python3
"""Automate Autoruns-based persistence analysis."""
import subprocess
import csv
import json
import sys
def scan_and_analyze(autorunsc_path="autorunsc64.exe", csv_path="scan.csv"):
cmd = [autorunsc_path, "-a", "*", "-c", "-h", "-s", "-nobanner", "*"]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=600)
with open(csv_path, 'w') as f:
f.write(result.stdout)
return parse_and_flag(csv_path)
def parse_and_flag(csv_path):
suspicious = []
with open(csv_path, 'r', errors='replace') as f:
for row in csv.DictReader(f):
reasons = []
signer = row.get("Signer", "")
if not signer or signer == "(Not verified)":
reasons.append("Unsigned binary")
if not row.get("Description") and not row.get("Company"):
reasons.append("Missing metadata")
path = row.get("Image Path", "").lower()
for sp in ["\temp\\", "\appdata\local\temp", "\users\public\\"]:
if sp in path:
reasons.append(f"Suspicious path")
launch = row.get("Launch String", "").lower()
for kw in ["powershell", "cmd /c", "wscript", "mshta", "regsvr32"]:
if kw in launch:
reasons.append(f"LOLBin: {kw}")
if reasons:
row["reasons"] = reasons
suspicious.append(row)
return suspicious
if __name__ == "__main__":
if len(sys.argv) > 1:
results = parse_and_flag(sys.argv[1])
print(f"[!] {len(results)} suspicious entries")
for r in results:
print(f" {r.get('Entry','')} - {r.get('Image Path','')}")
for reason in r.get('reasons', []):
print(f" - {reason}")
Validation Criteria
- All ASEP categories scanned and cataloged
- Unsigned entries flagged for investigation
- Suspicious paths and LOLBin launch strings highlighted
- Baseline comparison identifies new persistence mechanisms
When NOT to Use
- You need to perform the attack, not analyze it (use performing-* skills)
- Task is about detection, not analysis (use detecting-* skills)
- You need to implement controls (use implementing-* skills)
- Task is about threat hunting, not post-incident analysis (use hunting-* skills)
- You don't have access to the artifacts/logs to analyze
- Task requires real-time monitoring (use SOC tools)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Analyzing malware on a machine connected to the production network
- Failing to isolate the analysis environment from the internet
- Executing samples without proper containment (VM, sandbox)
Verification
- All steps executed successfully against a test environment before production use
- Output documented with screenshots or logs demonstrating expected behavior
- Sample hash recorded and verified (MD5, SHA-1, SHA-256)
- Analysis environment confirmed isolated from production network
- Indicators of compromise (IOCs) extracted and documented
References
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: analyzing-malware-persistence-with-autoruns3description: Use when use Sysinternals Autoruns to systematically identify and analyze malware persistence mechanisms across registry keys, scheduled tasks, services, drivers, and startup locations on Windows systems. Use when working with analyzing malware persistence with autoruns.4license: Apache-2.05---67# Analyzing Malware Persistence with Autoruns89## Overview1011Sysinternals Autoruns extracts data from hundreds of Auto-Start Extensibility Points (ASEPs) on Windows, scanning 18+ categories including Run/RunOnce keys, services, scheduled tasks, drivers, Winlogon entries, LSA providers, print monitors, WMI subscriptions, and AppInit DLLs. Digital signature verification filters Microsoft-signed entries. The compare function identifies newly added persistence via baseline diffing. VirusTotal integration checks hash reputation. Offline analysis via -z flag enables forensic disk image examination.121314## When to Use15**Trigger phrases:**16- "analyzing malware persistence with autoruns"17- "Use Sysinternals Autoruns to systematically identify and analyze malware persist"181920- When investigating security incidents that require analyzing malware persistence with autoruns21- When building detection rules or threat hunting queries for this domain22- When SOC analysts need structured procedures for this analysis type23- When validating security monitoring coverage for related attack techniques2425## Prerequisites2627- Sysinternals Autoruns (GUI) and Autorunsc (CLI)28- Administrative privileges on target system29- Python 3.9+ for automated analysis30- VirusTotal API key for reputation checks31- Clean baseline export for comparison3233## Workflow34351. **Isolate the sample** — ensure the malware is in a sandboxed environment with no network access362. **Record file metadata** — hash the sample and note file type, size, and compile timestamp373. **Static analysis** — examine strings, imports, and disassembled code without execution384. **Dynamic analysis** — execute in a monitored sandbox and record behavior (file, registry, network)395. **Document IOCs** — extract indicators of compromise and write the analysis report40### Step 1: Automated Persistence Scanning4142```43#!/usr/bin/env python344"""Automate Autoruns-based persistence analysis."""45import subprocess46import csv47import json48import sys495051def scan_and_analyze(autorunsc_path="autorunsc64.exe", csv_path="scan.csv"):52 cmd = [autorunsc_path, "-a", "*", "-c", "-h", "-s", "-nobanner", "*"]53 result = subprocess.run(cmd, capture_output=True, text=True, timeout=600)54 with open(csv_path, 'w') as f:55 f.write(result.stdout)56 return parse_and_flag(csv_path)575859def parse_and_flag(csv_path):60 suspicious = []61 with open(csv_path, 'r', errors='replace') as f:62 for row in csv.DictReader(f):63 reasons = []64 signer = row.get("Signer", "")65 if not signer or signer == "(Not verified)":66 reasons.append("Unsigned binary")67 if not row.get("Description") and not row.get("Company"):68 reasons.append("Missing metadata")69 path = row.get("Image Path", "").lower()70 for sp in ["\temp\\", "\appdata\local\temp", "\users\public\\"]:71 if sp in path:72 reasons.append(f"Suspicious path")73 launch = row.get("Launch String", "").lower()74 for kw in ["powershell", "cmd /c", "wscript", "mshta", "regsvr32"]:75 if kw in launch:76 reasons.append(f"LOLBin: {kw}")77 if reasons:78 row["reasons"] = reasons79 suspicious.append(row)80 return suspicious818283if __name__ == "__main__":84 if len(sys.argv) > 1:85 results = parse_and_flag(sys.argv[1])86 print(f"[!] {len(results)} suspicious entries")87 for r in results:88 print(f" {r.get('Entry','')} - {r.get('Image Path','')}")89 for reason in r.get('reasons', []):90 print(f" - {reason}")91```9293## Validation Criteria9495- All ASEP categories scanned and cataloged96- Unsigned entries flagged for investigation97- Suspicious paths and LOLBin launch strings highlighted98- Baseline comparison identifies new persistence mechanisms99100## When NOT to Use101102- You need to perform the attack, not analyze it (use performing-* skills)103- Task is about detection, not analysis (use detecting-* skills)104- You need to implement controls (use implementing-* skills)105- Task is about threat hunting, not post-incident analysis (use hunting-* skills)106- You don't have access to the artifacts/logs to analyze107- Task requires real-time monitoring (use SOC tools)108109110## Red Flags111112- Performing actions without explicit written authorization from the asset owner113- Testing against production systems without a defined scope and rules of engagement114- Analyzing malware on a machine connected to the production network115- Failing to isolate the analysis environment from the internet116- Executing samples without proper containment (VM, sandbox)117118## Verification119120- All steps executed successfully against a test environment before production use121- Output documented with screenshots or logs demonstrating expected behavior122- Sample hash recorded and verified (MD5, SHA-1, SHA-256)123- Analysis environment confirmed isolated from production network124- Indicators of compromise (IOCs) extracted and documented125126## References127128- [Sysinternals Autoruns](https://learn.microsoft.com/en-us/sysinternals/downloads/autoruns)129- [SANS - Offline Autoruns Revisited](https://www.sans.org/blog/offline-autoruns-revisited-auditing-malware-persistence/)130- [Hunting Malware with Autoruns](https://nasbench.medium.com/hunting-malware-with-windows-sysinternals-autoruns-19cbfe4103c2)131- [MITRE ATT&CK T1547 - Boot or Logon Autostart](https://attack.mitre.org/techniques/T1547/)132133## Process1341351. Analyze the task requirements1362. Apply domain expertise1373. Verify output quality138139## Anti-Rationalization Table140141| Rationalization | Reality |142|---|---|143| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |144| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |145| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |