meltedinhex/analyst-ai-pack / skills/hunting-scheduled-task-abuse
hunting-scheduled-task-abuse
VerifiedHunts for malicious scheduled task persistence by analyzing task registration events (4698) and schtasks process creation for suspicious actions, triggers, and hidden tasks. Activates for requests to hunt scheduled task abuse, detect malicious schtasks usage, or find persistence via the Task Scheduler.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 340 B |
| SKILL.md | skill md | 2.6 KB |
| references/api-reference.md | markdown | 1.2 KB |
| scripts/analyst.py | script | 2.7 KB |
scripts/analyst.py
View on GitHub#!/usr/bin/env python3
"""Hunt scheduled-task persistence abuse in 4698 and schtasks process telemetry.
Parses task-registration (4698) and process-creation events (CSV or JSON-lines) and flags task
actions or schtasks command lines that run script hosts, encoded commands, or binaries from
suspicious paths. Parses telemetry only; executes nothing.
"""
from __future__ import annotations
import argparse
import csv
import json
import sys
from pathlib import Path
SUSPICIOUS_ACTIONS = ["powershell", "-enc", "-encodedcommand", "mshta", "wscript", "cscript",
"cmd /c", "cmd.exe /c", "rundll32", "regsvr32", "bitsadmin", "curl",
"certutil"]
SUSPICIOUS_PATHS = ["\\temp\\", "\\appdata\\", "\\public\\", "\\programdata\\",
"\\users\\public", "%temp%", "%appdata%"]
def _rows(path: str):
text = Path(path).read_text(encoding="utf-8-sig", errors="replace")
if path.lower().endswith(".json") or text.lstrip()[:1] in "{[":
for line in text.splitlines():
line = line.strip()
if line:
try:
yield json.loads(line)
except json.JSONDecodeError:
continue
else:
for row in csv.DictReader(text.splitlines()):
yield row
def _get(row: dict, *keys: str) -> str:
for k in keys:
if row.get(k):
return str(row[k])
return ""
def hunt(path: str) -> dict:
findings = []
for row in _rows(path):
eid = _get(row, "EventID", "event_id")
action = _get(row, "TaskContent", "Action", "Command", "CommandLine",
"command_line").lower()
task = _get(row, "TaskName", "task_name")
if not action:
continue
is_task_event = eid == "4698" or "schtasks" in action or task
if not is_task_event:
continue
hits = [a for a in SUSPICIOUS_ACTIONS if a in action]
path_hits = [p for p in SUSPICIOUS_PATHS if p in action]
if hits or path_hits:
findings.append({
"task": task or "(unnamed)",
"indicators": hits + [f"path:{p}" for p in path_hits],
"action": action[:200],
})
return {"suspicious_tasks": findings, "total": len(findings)}
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="Hunt scheduled task abuse")
sub = parser.add_subparsers(dest="cmd", required=True)
p = sub.add_parser("hunt")
p.add_argument("events")
args = parser.parse_args(argv)
print(json.dumps(hunt(args.events), indent=2))
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |