K-9 is an operator-first PowerShell toolkit for blue teams hunting stealthy persistence, fileless tradecraft, and covert pivoting on Windows endpoints. Every module runs in dry-run mode and requires interactive confirmation before deleting or changing anything, making it safe for first-pass triage in labs or controlled environments where situational awareness matters more than stealth.
Warning
Run K-9 only on systems where you have explicit written authorization. The authors are not liable for damage, data loss, or service interruption caused by misuse.
| Module | Focus |
|---|---|
RegistryReaper |
Autoruns, AppInit_DLLs, IFEO/Debugger hooks, Winlogon hijacks, stealth Scheduled Tasks, WMI subs (with baseline diff) |
MemoryHunter |
Process heuristics, LOLBAS command-line matching, suspicious parent/child trees |
NetworkNinja |
ARP spoofing, hosts/DNS tampering, netsh portproxy, reverse shell telemetry, DNS tunneling, routing anomalies + scoring |
FirmwarePhantom |
Secure Boot, TPM and Device Guard posture checks, UEFI boot chain inspection |
ForensicsWarden |
Hidden VM/disk image sweep, WSL/Hyper-V/VMware artifacts, tunnel binary hunts, YARA/string scan, forensic snapshots, baseline/diff |
DriverSentinel |
Driver baseline/blocklist diff, DLL sideload hunting, Event 7045 audit (with deep mode) |
K9State |
Baseline store, scoring engine, operator tip registry, settings (YARA paths, etc.) |
Recent additions:
- Disk-wide search with hashing/entropy sampling for
.vhd/.vhdx/.vmdk/.qcow2/.img/.raw/.isoimages plus Hyper-V/VirtualBox/VMware/WSL metadata discovery. Compact/minimal profiles skip the heaviest WSL paths for CI. - Reverse-proxy intelligence:
netsh interface portproxy, ssh-R/-L/-Denumeration, long-lived outbound correlation (process ⇔ socket ⇔ parent), and baseline tracking for DNS/portproxy shifts. - DNS tunneling heuristics (entropy, TXT/NULL prevalence, single-domain cache floods) and routing stack sanity checks for pivot detection.
- Persistence hunting beyond run keys: IFEO debugger hijacks, Winlogon shell/userinit swaps, scheduled tasks launching from user/temp paths, WMI event subscriptions.
- Optional YARA integration (auto-detects local
yara.exeor user-specified binary) with string-hunt fallback plus comprehensive "mission snapshot" export (processes.csv, network endpoints, autoruns, tasks, event logs, drivers, ARP, routes). - DriverSentinel module for BYOVD/DLL sideload detection: unsigned/blocklisted drivers, suspicious module loads, Event 7045 installs (enable
-Deepfor service metadata + forced event audit). - JSON reporting hook via
-ReportPathor theK9_REPORT_PATHenvironment variable captures per-module findings + threat score as structured output. - Threat scoring + operator tips: every module emits weighted indicators, summarized in the mission debrief with actionable remediation hints. MemoryHunter also baselines executable hashes and reports new processes.
K-9_Script/
├─ K9.ps1 # orchestrator / interactive UX
└─ modules/
├─ K9Utils.ps1 # shared helpers (entropy, path utils, IP classifiers)
├─ K9State.ps1 # baseline store, score/tip registries, config helpers
├─ VenomUI.ps1 # banner, module logging, session summary
├─ RegistryReaper.ps1 # persistence + autorun hunter
├─ MemoryHunter.ps1 # process/memory heuristics
├─ NetworkNinja.ps1 # network/pivot/dns detection
├─ FirmwarePhantom.ps1# firmware posture
└─ ForensicsWarden.ps1# disk/VM/YARA/snapshot module
git clone https://github.com/m4rba4s/K-9_Script.git
cd K-9_Script
# Full interactive menu (default)
pwsh .\K9.ps1
# Target specific modules w/out banner noise
pwsh .\K9.ps1 -Registry -NoBanner
pwsh .\K9.ps1 -Network -NoBanner
pwsh .\K9.ps1 -Forensics -NoBanner
# Non-interactive smoke (auto-answers "N" to prompts)
function Read-Host { 'N' }
pwsh .\K9.ps1 -All -NoBanner
Remove-Item function:\Read-Host| Switch | Description |
|---|---|
-Registry |
Run RegistryReaper only |
-Memory |
Run MemoryHunter only |
-Network |
Run NetworkNinja only |
-Firmware |
Run FirmwarePhantom only (requires admin for best coverage) |
-Forensics |
Run ForensicsWarden (VM artifacts, tunnels, YARA, mission snapshot) |
-Driver |
Run DriverSentinel (driver baseline/blocklist + DLL sideload hunt) |
-Driver -Deep |
Extend driver telemetry with version/company metadata and force Event 7045 audit |
-All |
Execute every module sequentially |
-NoBanner |
Skip ASCII art + session slate (useful for CI) |
- Launch
pwsh .\K9.ps1 -NoBanner -Allin a controlled console. - Review per-module findings and respond to prompts (deletions are never automatic).
- Let the new baseline engine capture first-run state (VM images, portproxy rules, autoruns, DNS servers). Subsequent runs highlight diffs automatically.
- Use ForensicsWarden’s optional snapshot to preserve CSV/log artifacts before remediation.
- Rerun modules with
-Allor targeted switches to confirm cleanup and watch the threat score drop.
- Settings live in
%LOCALAPPDATA%\K9Watchdog\config\settings.json. - Supported keys:
YaraExecutable: full path toyara.exe/yara64.exeif it is not onPATH.YaraRulesPath: folder containing.yar/.yarasignatures (defaults to.\yara_rules).ForensicsScope:Full(default),Compact, orMinimal. Compact/Minimal limit disk roots, skip legacy WSL enumerations, and cap artifact/tunnel results for faster triage/CI.DriverBlocklistPath: optional override for the driver blocklist CSV (defaults to.\data\driver_blocklist.csv). Use this to feed your own LOLDrivers/Microsoft blocklist exports.K9_REPORT_PATH(env var) or CLI-ReportPath: emit a JSON report containing module findings, threat score, and tips.
pwsh .\K9.ps1 -Driver -NoBanner # quick check (baseline + DLL sideload)
pwsh .\K9.ps1 -Driver -NoBanner -Deep # adds version/publisher metadata + forces Event 7045 audit
Deep mode captures per-driver company/version/signature/start account details and logs them into the JSON report (if enabled) so you can diff drivers across engagements. It also ignores the -SkipEventAudit flag to guarantee Event 7045 coverage.
- Example:
{
"YaraExecutable": "D:\\Tools\\yara64.exe",
"YaraRulesPath": "D:\\Intel\\rules"
}Use the bundled smoke runner to dry-run major modules with safe defaults (autoruns/network/forensics minimal scope):
pwsh .\tests\Smoke.ps1 # full smoke
pwsh .\tests\Smoke.ps1 -SkipNetwork # if network calls are blockedThe script auto-denies destructive prompts, forces ForensicsWarden into -Scope Minimal -SkipSnapshot -Roots <repo>, and now exercises DriverSentinel (with event log audit disabled for speed) so CI still finishes quickly.
- Baseline/diff engine to compare mission snapshots over time.
- JSON report export + webhook/SIEM forwarding.
- Local hash allow/deny lists + TI lookups.
- Optional kill-switch helpers (network isolation guidance, not automatic).
MIT licensed. Stay paranoid.