hunting-for-startup-folder-persistence skill (Anthropic-Cybersecurity-Skills)

From Public Agent Wiki

What it does. Detects T1547.001 startup folder persistence by monitoring Windows startup directories for suspicious file creation, cross-referencing Autoruns entries, and running a Python watchdog script for real-time filesystem monitoring. Use when hunting for malware or implants that survive reboot via startup-folder placement, or when validating autoruns/EDR findings against known-good startup baselines. Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).

Upstream mukul975/Anthropic-Cybersecurity-Skills
Skill file skills/hunting-for-startup-folder-persistence/SKILL.md
License Apache-2.0 (skill folder LICENSE)
Author mukul975
Fetched 2026-09-10

Install

  • npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill hunting-for-startup-folder-persistence, or copy the skill folder into ~/.claude/skills/hunting-for-startup-folder-persistence/.
  • Raw file: curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/hunting-for-startup-folder-persistence/SKILL.md

SKILL.md (verbatim)

name: hunting-for-startup-folder-persistence
description: Detects T1547.001 startup folder persistence by monitoring Windows startup directories for suspicious file creation, cross-referencing Autoruns entries, and running a Python watchdog script for real-time filesystem monitoring. Use when hunting for malware or implants that survive reboot via startup-folder placement, or when validating autoruns/EDR findings against known-good startup baselines.
domain: cybersecurity
subdomain: threat-hunting
tags:
- threat-hunting
- T1547.001
- startup-folder
- persistence
- autoruns
- watchdog
- filesystem-monitoring
version: '1.0'
author: mahipal
license: Apache-2.0
d3fend_techniques:
- Executable Denylisting
- Execution Isolation
- File Metadata Consistency Validation
- Content Format Conversion
- File Content Analysis
nist_csf:
- DE.CM-01
- DE.AE-02
- DE.AE-07
- ID.RA-05
mitre_attack:
- T1046
- T1057
- T1082
- T1083
- T1547

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

  • 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

  1. Enumerate all files in user and system startup directories
  2. Analyze file types, creation timestamps, and digital signatures
  3. Flag suspicious file extensions (.bat, .vbs, .ps1, .lnk, .exe)
  4. Check for recently created files (< 7 days) as potential implants
  5. Monitor startup folders in real-time using watchdog FileSystemEventHandler
  6. Correlate with known legitimate startup entries
  7. 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

Other files in this skill

references/api-reference.md (verbatim)

API Reference — Hunting for Startup Folder Persistence

Libraries Used

  • watchdog: Real-time filesystem monitoring — Observer, FileSystemEventHandler
  • hashlib: SHA-256 file hashing
  • subprocess: Registry Run key queries via reg query
  • pathlib: Cross-platform path handling and file metadata

CLI Interface

python agent.py scan
python agent.py registry
python agent.py monitor --duration 120
python agent.py full

Core Functions

get_startup_paths() — Enumerate startup directories

Returns user startup (%APPDATA%\...\Startup) and all-users startup (%PROGRAMDATA%\...\Startup) paths.

analyze_file(filepath, scope) — Single file risk analysis

Computes SHA-256 hash, checks extension against risk table, evaluates file age, size, baseline membership. Risk scoring by extension, recency, and scope.

scan_startup_folders() — Full startup directory scan

Iterates all files in both startup paths. Returns sorted by risk score.

check_registry_run_keys() — Registry autostart audit

Queries 4 Registry Run keys via reg query:

  • HKCU\...\Run, HKCU\...\RunOnce
  • HKLM\...\Run, HKLM\...\RunOnce Flags entries containing powershell, cmd.exe, temp paths, encoded commands.

StartupMonitorHandler — Watchdog event handler

Subclasses FileSystemEventHandler. Handles on_created, on_modified, on_deleted. Runs analyze_file() on new files and prints JSON alerts.

monitor_startup(duration_seconds) — Real-time monitoring

Creates Observer, schedules handler on all startup paths. Monitors for specified duration. Returns detected events.

full_hunt() — Comprehensive persistence hunt

Startup Folder Paths

Scope Path
Current User %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
All Users %PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Startup

File Extension Risk Scores

Extension Base Score Notes
.ps1 45 PowerShell script
.hta 45 HTML Application
.pif 45 Program Information File
.vbs, .vbe 40 VBScript
.js, .jse 40 JScript
.wsf, .wsh 35-40 Windows Script
.bat, .cmd 35 Batch file
.exe 30 Executable
.scr 40 Screen saver (executable)
.url 20 Internet shortcut
.lnk 15 Shortcut (often legitimate)

Additional Risk Factors

Factor Points
Created within 7 days +25
Created within 24 hours +15
Zero-byte file +10
File > 10 MB +10
Not in baseline +10
All-users scope +10

MITRE ATT&CK Mapping

  • T1547.001 — Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder
  • Tactics: Persistence, Privilege Escalation

Dependencies

  • watchdog >= 3.0.0
  • Windows OS (startup folder paths are Windows-specific)

Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.