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 Windows startup directories for suspicious file creation, analyzing autoruns entries, and using Python watchdog for real-time filesystem monitoring. Use when detecting t1547.001 startup folder persistence by monitoring windows startup directories.4license: Apache-2.05---678# Hunting for Startup Folder Persistence910## Overview1112Attackers 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.131415## When to Use16**Trigger phrases:**17- "hunting for startup folder persistence"18- "Detect T1547"192021- When investigating security incidents that require hunting for startup folder persistence22- When building detection rules or threat hunting queries for this domain23- When SOC analysts need structured procedures for this analysis type24- When validating security monitoring coverage for related attack techniques2526## Prerequisites2728- Python 3.9+ with `watchdog`, `pefile` (optional for PE analysis)29- Access to Windows startup folders (user and all-users)30- Windows Event Logs for Event ID 4663 correlation (optional)3132## Steps3334```python35# Example: IOC detection36import re3738IOC_PATTERNS = {39 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",40 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",41 "hash_md5": r"\b[a-f0-9]{32}\b",42 "hash_sha256": r"\b[a-f0-9]{64}\b",43}4445def extract_iocs(text: str) -> dict:46 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}47```48491. Enumerate all files in user and system startup directories502. Analyze file types, creation timestamps, and digital signatures513. Flag suspicious file extensions (.bat, .vbs, .ps1, .lnk, .exe)524. Check for recently created files (< 7 days) as potential implants535. Monitor startup folders in real-time using watchdog FileSystemEventHandler546. Correlate with known legitimate startup entries557. Generate threat hunting report with T1547.001 MITRE mapping5657## Expected Output5859- JSON report listing all startup folder contents with risk scores, file metadata, and suspicious indicators60- Real-time monitoring alerts for new file creation in startup directories61## When NOT to Use6263- You're responding to a known incident (use IR skills)64- Task is about analyzing confirmed malware (use analyzing-* skills)65- You need to implement detection rules (use implementing-* skills)66- Task is about vulnerability scanning (use scanning tools)67- You don't have access to endpoint/network data68- Task requires compliance auditing (use auditing-* skills)697071## Red Flags7273- Performing actions without explicit written authorization from the asset owner74- Testing against production systems without a defined scope and rules of engagement75- Acting on threat intelligence without validating source reliability76- Sharing classified or sensitive indicators without proper handling procedures77- Alerting threat actors to detection capabilities through visible response actions7879## Process80811. **Reconnaissance** — Gather target information, identify attack surface, enumerate services821. **Analysis/Exploitation** — Execute the technique, analyze results, document findings831. **Reporting** — Document IOCs, write findings, provide remediation recommendations8485## Verification8687- All steps executed successfully against a test environment before production use88- Output documented with screenshots or logs demonstrating expected behavior89- Results validated against known-good baselines or reference implementations90- Documentation complete enough for another analyst to reproduce findings9192## Anti-Rationalization Table9394| Rationalization | Reality |95|---|---|96| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |97| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |98| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |