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
- 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
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
References
1---2name: analyzing-malware-persistence-with-autoruns-23description: Use Sysinternals Autoruns to systematically enumerate and analyze malware4 persistence mechanisms across Windows registry run keys, scheduled tasks, services,5 drivers, and startup locations. Use when hunting for persistence during Windows6 incident response, triaging a compromised endpoint, or validating that malware7 autostart entries have been fully identified and removed.8domain: cybersecurity9subdomain: malware-analysis10tags:11- autoruns12- persistence13- malware-analysis14- sysinternals15- windows16- registry17- startup18- incident-response19mitre_attack:20- T1547.00121- T1543.00322- T1053.00523- T1574.00124- T1037.00125version: '1.0'26author: mahipal27license: Apache-2.028d3fend_techniques:29- Executable Denylisting30- Execution Isolation31- File Metadata Consistency Validation32- Content Format Conversion33- File Content Analysis34nist_csf:35- DE.AE-0236- RS.AN-0337- ID.RA-0138- DE.CM-0139metadata:40 source: https://skillmd.com/skills/26zl/analyzing-malware-persistence-with-autoruns-241---4243# Analyzing Malware Persistence with Autoruns4445## Overview4647Sysinternals 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.484950## When to Use5152- When investigating security incidents that require analyzing malware persistence with autoruns53- When building detection rules or threat hunting queries for this domain54- When SOC analysts need structured procedures for this analysis type55- When validating security monitoring coverage for related attack techniques5657## Prerequisites5859- Sysinternals Autoruns (GUI) and Autorunsc (CLI)60- Administrative privileges on target system61- Python 3.9+ for automated analysis62- VirusTotal API key for reputation checks63- Clean baseline export for comparison6465## Workflow6667### Step 1: Automated Persistence Scanning6869```python70#!/usr/bin/env python371"""Automate Autoruns-based persistence analysis."""72import subprocess73import csv74import json75import sys767778def scan_and_analyze(autorunsc_path="autorunsc64.exe", csv_path="scan.csv"):79 cmd = [autorunsc_path, "-a", "*", "-c", "-h", "-s", "-nobanner", "*"]80 result = subprocess.run(cmd, capture_output=True, text=True, timeout=600)81 with open(csv_path, 'w') as f:82 f.write(result.stdout)83 return parse_and_flag(csv_path)848586def parse_and_flag(csv_path):87 suspicious = []88 with open(csv_path, 'r', errors='replace') as f:89 for row in csv.DictReader(f):90 reasons = []91 signer = row.get("Signer", "")92 if not signer or signer == "(Not verified)":93 reasons.append("Unsigned binary")94 if not row.get("Description") and not row.get("Company"):95 reasons.append("Missing metadata")96 path = row.get("Image Path", "").lower()97 for sp in ["\temp\\", "\appdata\local\temp", "\users\public\\"]:98 if sp in path:99 reasons.append(f"Suspicious path")100 launch = row.get("Launch String", "").lower()101 for kw in ["powershell", "cmd /c", "wscript", "mshta", "regsvr32"]:102 if kw in launch:103 reasons.append(f"LOLBin: {kw}")104 if reasons:105 row["reasons"] = reasons106 suspicious.append(row)107 return suspicious108109110if __name__ == "__main__":111 if len(sys.argv) > 1:112 results = parse_and_flag(sys.argv[1])113 print(f"[!] {len(results)} suspicious entries")114 for r in results:115 print(f" {r.get('Entry','')} - {r.get('Image Path','')}")116 for reason in r.get('reasons', []):117 print(f" - {reason}")118```119120## Validation Criteria121122- All ASEP categories scanned and cataloged123- Unsigned entries flagged for investigation124- Suspicious paths and LOLBin launch strings highlighted125- Baseline comparison identifies new persistence mechanisms126127## References128129- [Sysinternals Autoruns](https://learn.microsoft.com/en-us/sysinternals/downloads/autoruns)130- [SANS - Offline Autoruns Revisited](https://www.sans.org/blog/offline-autoruns-revisited-auditing-malware-persistence/)131- [Hunting Malware with Autoruns](https://nasbench.medium.com/hunting-malware-with-windows-sysinternals-autoruns-19cbfe4103c2)132- [MITRE ATT&CK T1547 - Boot or Logon Autostart](https://attack.mitre.org/techniques/T1547/)