Detection waits for a known bad signal. Hunting assumes the bad signal was missed and goes looking for it, with a hypothesis, a data source, and a test that can prove the hypothesis wrong. A good hunt program is a loop - intelligence and telemetry suggest hypotheses, hunts test them, findings become detections so the next hunt starts from a better position, and coverage gaps become the next backlog. This skill covers that loop end to end. Authorized defensive hunting on systems you own or are authorized to test, only.
Quick Workflow
- Build the hypothesis backlog from threat intelligence, recent incidents, and gaps in detection coverage.
- Prioritize hypotheses by risk - what would hurt most if it were true and undetected.
- Check the data exists before hunting - telemetry, retention, and query access for every source the hunt needs.
- Run the hunt in a time box, across the full fleet, not on a sample of convenient hosts.
- Triage every hit as benign, suspicious, or malicious, with the evidence for each call recorded.
- Escalate malicious findings to incident response immediately, and do not continue hunting on a live intrusion alone.
- Turn each validated technique into a detection, so the hunt never has to be repeated by hand.
- Record coverage, close the hypothesis, and feed the gaps back into the backlog.
1. Writing a testable hypothesis
A hypothesis is a sentence an analyst can prove or disprove with data. "Attackers might be here" is not one. "An adversary is using scheduled tasks for persistence on finance workstations" is, because it names the technique, the population, and the data that would show it. Every hypothesis carries its data source, its expected benign rate, and its escalation rule before the hunt starts.
# Hypothesis card template, one per hunt, filed before execution
cat > /tmp/hunt-hypothesis.txt <<'EOF'
hypothesis: adversaries use scheduled tasks for persistence
on finance workstations, based on recent threat reporting
technique: MITRE ATT&CK T1053, scheduled task or job
population: all finance workstations, last 90 days
data sources: endpoint telemetry, scheduled task creation events
expected benign rate: high, patching and software installers use tasks too
escalation rule: unknown binary, unusual path, or task created
by a non-admin process escalates to incident response
time box: 4 hours
EOF
cat /tmp/hunt-hypothesis.txt
# osquery: hunt for scheduled tasks created outside normal tooling
# Baseline first, then flag tasks whose binaries live in user-writable
# paths or temp folders, which legitimate installers rarely use.
osqueryi --json "SELECT name, path, action FROM scheduled_tasks WHERE path LIKE '%Temp%' OR path LIKE '%Users\\Public%';"
2. Hunting across network telemetry
Endpoint data shows what ran. Network data shows what talked, and the two together are much harder to fake. Hunt for beacons by looking for regularity, for long-lived low-volume sessions, and for destinations that appear on few hosts but persist over time. Zeek connection logs are the usual starting point, because they compress well and retain for months.
# Zeek: list rare external destinations contacted persistently
# A destination seen from one host, every day, in small sessions,
# is a beacon candidate. A destination seen from hundreds of hosts
# is usually a software update service or a cloud provider.
# Start from conn.log, filter to external destinations, and rank
# by host count ascending and session count descending.
echo "zeek-cut id.orig_h id.resp_h duration orig_bytes < conn.log | head -20"
echo "rare plus persistent beats loud plus common in beacon hunting"
#!/usr/bin/env python3
"""Score beacon candidates from a simple connection summary."""
sessions = [
("host-a", "203.0.113.50", 42, 120),
("host-b", "203.0.113.50", 3, 9000),
("host-c", "198.51.100.23", 38, 95),
]
for host, dest, count, avg_bytes in sessions:
score = 0
if count >= 30:
score += 2
if avg_bytes < 500:
score += 2
print(f"{host} -> {dest}: {count} sessions, {avg_bytes} avg bytes, score {score}/4")
print("high scores are triage priorities, not verdicts")
3. Hunting across endpoints at fleet scale
Fleet-scale hunts need a collection tool, not manual logins. Velociraptor hunts run the same query across every client and return the results centrally, which is what makes a hypothesis testable across thousands of hosts in hours rather than weeks. Scope the hunt to the hypothesis population, keep the query narrow enough to return in the time box, and record the exact query with the results so the hunt is reproducible.
# Velociraptor: hunt for unsigned binaries in autostart locations
# Unsigned code in a persistence location is suspicious, though
# internal tools are often unsigned too, so triage needs the
# baseline of known internal binaries before calling anything bad.
velociraptor --config server.config.yaml query \
"SELECT client_id, hostname FROM clients() WHERE last_seen > now() - 86400"
echo "hunt query, scope, and results filed together for reproducibility"
# osquery: hunt for processes with deleted executables still running
# A running process whose binary was deleted from disk is a
# classic sign of fileless or self-deleting malware staging.
osqueryi --json "SELECT pid, name, path FROM processes WHERE path = '' OR path LIKE '%(deleted)%';"
4. Triage, escalation, and detection creation
Triage is where hunts fail most often - either everything is called benign because the baseline was never built, or everything escalates and the SOC drowns. Every hit gets a verdict with evidence, malicious verdicts go to incident response at once, and every validated technique becomes a detection with a test case. A hunt that finds a technique but leaves no detection behind has only bought a few weeks of safety.
# Triage record template, one line per hit, verdict with evidence
cat > /tmp/hunt-triage.txt <<'EOF'
hit,verdict,evidence,action
task-updater-x,benign,known patching tool, path matches baseline,close
task-svc-helper,suspicious,unsigned binary in temp path,escalate to IR
task-backup-job,benign,internal backup agent, signed, documented,close
EOF
cat /tmp/hunt-triage.txt
#!/usr/bin/env python3
"""Track hunt coverage against MITRE ATT&CK techniques."""
techniques = {
"T1053": "scheduled task - hunted, detection created",
"T1059": "command interpreter - hunted, no detection yet",
"T1071": "application layer protocol - backlog, telemetry gap",
}
for tid, status in techniques.items():
print(f"{tid}: {status}")
print("coverage gaps become the next backlog, not forgotten items")
5. Measuring the hunt program
A hunt program without measurement drifts into favourite hunts repeated forever. Track hypotheses tested, hunts that found something real, time from hypothesis to detection, and coverage against the techniques that matter to your threat model. Report the misses too - a hunt that proves a hypothesis false is a success, because it closes a question the defenders were unsure about.
# Quarterly hunt program metrics, one row per hunt
cat > /tmp/hunt-metrics.txt <<'EOF'
hunt,hypothesis,verdict,detection_created,time_to_detection_days
H-041,scheduled task persistence,malicious found,yes,6
H-042,rare DNS beaconing,benign,improved baseline,n/a
H-043,cloud token abuse,telemetry gap,backlog item,n/a
EOF
cat /tmp/hunt-metrics.txt
Edge cases
- Telemetry retention is shorter than the hunt window. Scope the hunt to what the data actually covers, and log the retention gap as a backlog item, not as a silent assumption.
- The hunt finds a live intrusion. Stop hunting, escalate to incident response, and preserve evidence. Continuing to hunt around an active attacker risks tipping them off and destroying the response.
- Every hit looks benign. That may mean the hypothesis was wrong, the data source is blind, or the query was too narrow. Check the query against a known positive test case before closing.
- A hunt technique matches legitimate admin tooling. Work with the admin team to baseline their tooling, and tune the detection to the anomaly, not to the tool itself.
- Threat intelligence is vague or stale. A hypothesis built on a two-year-old report about a different sector is a weak hunt. Prefer intelligence tied to your sector, your technology, and recent incidents.
- Hunt findings implicate an insider. Hand the case to the insider-threat process with HR and legal, and keep the hunt team out of the employment side of the case.
Key references
- MITRE ATT&CK framework: https://attack.mitre.org/
- CISA hunt guidance and advisories: https://www.cisa.gov/topics/cyber-threats-and-advisories
- TaHiTI threat hunting methodology: https://www.betaalvereniging.nl/wp-content/uploads/TaHiTI-Threat-Hunting-Methodology.pdf
- Related skills in this repo - incident-timeline-analysis, incident-breach-scoping, incident-response, incident-containment-playbooks.
