Hunting for Startup Folder Persistence
Overview
Attackers use Windows startup folders for persistence (MITRE ATT&CK T1547.001 — Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder). Files placed in %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup or C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup execute automatically at user logon. This skill scans startup directories for suspicious files, monitors for real-time changes using Python watchdog, and analyzes file metadata to detect persistence implants.
When to Use
Trigger phrases:
"hunting for startup folder persistence"
"Detect T1547"
When investigating security incidents that require hunting for startup folder 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
- Python 3.9+ with
watchdog, pefile (optional for PE analysis)
- Access to Windows startup folders (user and all-users)
- Windows Event Logs for Event ID 4663 correlation (optional)
Steps
# Example: IOC detection
import re
IOC_PATTERNS = {
"ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",
"domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",
"hash_md5": r"\b[a-f0-9]{32}\b",
"hash_sha256": r"\b[a-f0-9]{64}\b",
}
def extract_iocs(text: str) -> dict:
return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}
- Enumerate all files in user and system startup directories
- Analyze file types, creation timestamps, and digital signatures
- Flag suspicious file extensions (.bat, .vbs, .ps1, .lnk, .exe)
- Check for recently created files (< 7 days) as potential implants
- Monitor startup folders in real-time using watchdog FileSystemEventHandler
- Correlate with known legitimate startup entries
- Generate threat hunting report with T1547.001 MITRE mapping
Expected Output
- JSON report listing all startup folder contents with risk scores, file metadata, and suspicious indicators
- Real-time monitoring alerts for new file creation in startup directories
When NOT to Use
- You're responding to a known incident (use IR skills)
- Task is about analyzing confirmed malware (use analyzing-* skills)
- You need to implement detection rules (use implementing-* skills)
- Task is about vulnerability scanning (use scanning tools)
- You don't have access to endpoint/network data
- Task requires compliance auditing (use auditing-* skills)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Acting on threat intelligence without validating source reliability
- Sharing classified or sensitive indicators without proper handling procedures
- Alerting threat actors to detection capabilities through visible response actions
Process
- Reconnaissance — Gather target information, identify attack surface, enumerate services
- Analysis/Exploitation — Execute the technique, analyze results, document findings
- Reporting — Document IOCs, write findings, provide remediation recommendations
Verification
- All steps executed successfully against a test environment before production use
- Output documented with screenshots or logs demonstrating expected behavior
- Results validated against known-good baselines or reference implementations
- Documentation complete enough for another analyst to reproduce findings
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: hunting-for-startup-folder-persistence3description: Use when detect T1547.001 startup folder persistence by monitoring Windows4 startup directories for suspicious file creation, analyzing autoruns entries, and5 using Python watchdog for real-time filesystem monitoring. Use when detecting t1547.0016 startup folder persistence by monitoring windows startup directories.7domain: cybersecurity8subdomain: threat-hunting9tags:10- threat-hunting11- T1547.00112- startup-folder13- persistence14- autoruns15- watchdog16- filesystem-monitoring17version: '1.0'18author: oyi7719license: Apache-2.020d3fend_techniques:21- Executable Denylisting22- Execution Isolation23- File Metadata Consistency Validation24- Content Format Conversion25- File Content Analysis26nist_csf:27- DE.CM-0128- DE.AE-0229- DE.AE-0730- ID.RA-0531category: cybersecurity32metadata:33 source: https://skillmd.com/skills/oyi77/hunting-for-startup-folder-persistence34---353637# Hunting for Startup Folder Persistence3839## Overview4041Attackers use Windows startup folders for persistence (MITRE ATT&CK T1547.001 — Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder). Files placed in `%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup` or `C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup` execute automatically at user logon. This skill scans startup directories for suspicious files, monitors for real-time changes using Python watchdog, and analyzes file metadata to detect persistence implants.424344## When to Use45**Trigger phrases:**46- "hunting for startup folder persistence"47- "Detect T1547"484950- When investigating security incidents that require hunting for startup folder persistence51- When building detection rules or threat hunting queries for this domain52- When SOC analysts need structured procedures for this analysis type53- When validating security monitoring coverage for related attack techniques5455## Prerequisites5657- Python 3.9+ with `watchdog`, `pefile` (optional for PE analysis)58- Access to Windows startup folders (user and all-users)59- Windows Event Logs for Event ID 4663 correlation (optional)6061## Steps6263```python64# Example: IOC detection65import re6667IOC_PATTERNS = {68 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",69 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",70 "hash_md5": r"\b[a-f0-9]{32}\b",71 "hash_sha256": r"\b[a-f0-9]{64}\b",72}7374def extract_iocs(text: str) -> dict:75 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}76```77781. Enumerate all files in user and system startup directories792. Analyze file types, creation timestamps, and digital signatures803. Flag suspicious file extensions (.bat, .vbs, .ps1, .lnk, .exe)814. Check for recently created files (< 7 days) as potential implants825. Monitor startup folders in real-time using watchdog FileSystemEventHandler836. Correlate with known legitimate startup entries847. Generate threat hunting report with T1547.001 MITRE mapping8586## Expected Output8788- JSON report listing all startup folder contents with risk scores, file metadata, and suspicious indicators89- Real-time monitoring alerts for new file creation in startup directories90## When NOT to Use9192- You're responding to a known incident (use IR skills)93- Task is about analyzing confirmed malware (use analyzing-* skills)94- You need to implement detection rules (use implementing-* skills)95- Task is about vulnerability scanning (use scanning tools)96- You don't have access to endpoint/network data97- Task requires compliance auditing (use auditing-* skills)9899100## Red Flags101102- Performing actions without explicit written authorization from the asset owner103- Testing against production systems without a defined scope and rules of engagement104- Acting on threat intelligence without validating source reliability105- Sharing classified or sensitive indicators without proper handling procedures106- Alerting threat actors to detection capabilities through visible response actions107108## Process1091101. **Reconnaissance** — Gather target information, identify attack surface, enumerate services1111. **Analysis/Exploitation** — Execute the technique, analyze results, document findings1121. **Reporting** — Document IOCs, write findings, provide remediation recommendations113114## Verification115116- All steps executed successfully against a test environment before production use117- Output documented with screenshots or logs demonstrating expected behavior118- Results validated against known-good baselines or reference implementations119- Documentation complete enough for another analyst to reproduce findings120121## Anti-Rationalization Table122123| Rationalization | Reality |124|---|---|125| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |126| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |127| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |