Cybersecurity-Mastery

Home › Defensive Security › Threat Hunting

Threat Hunting

Hypothesis-driven hunts, the pyramid of pain, MITRE-aligned queries and hunt reporting.

Advanced⌨ ~72 min hands-on📖 ~24 min read

▶ Here to build, not read? Jump to the Hands-On Practice.

Prerequisites: MITRE ATT&CK · SIEM · Log Analysis

Overview

Threat hunting is the proactive, hypothesis-driven search for adversaries who have evaded automated detection. It starts from the assumption that prevention and alerting are imperfect and that a determined attacker may already be present, then goes looking for them in telemetry rather than waiting for an alert. Hunting is human-led and creative where alerting is machine-led and repetitive; its outputs are not just findings but new, durable detections that turn each successful hunt into permanent coverage.

The discipline is anchored by two ideas. David Bianco's Pyramid of Pain ranks indicators by how much it hurts an adversary to change them — hashes and IPs are trivial to rotate, but tactics, techniques and procedures (TTPs) are costly — so effective hunting targets behaviour high on the pyramid. And MITRE ATT&CK supplies the behavioural vocabulary and a map of what to hunt for, technique by technique.

How it works

A hunt runs as a loop:

  1. Hypothesis — a specific, testable statement, ideally tied to an ATT&CK technique and your environment: e.g. "an adversary is using WMI for lateral movement (T1047), visible as wmiprvse.exe spawning shells on servers."
  2. Data — identify the telemetry that would show it (process creation with parent/child, network flows, authentication logs) and confirm you actually collect it.
  3. Hunt — query, pivot and filter, distinguishing malicious from the (large) benign baseline. This is where knowing 'normal' matters most.
  4. Findings — confirm or refute; if confirmed, hand to incident response.
  5. Operationalise — turn what you learned into a detection (a Sigma rule), so the hunt need not be repeated manually.

The whole loop turns tacit adversary knowledge into codified, repeatable coverage.

flowchart TD
    A["Threat Hunting"] --> B["Concepts & terminology"]
    A --> C["Internal mechanics"]
    C --> D["Trust boundaries"]
    D --> E["Attack surface"]
    D --> F["Defensive controls"]
    E --> G["Detection & telemetry"]
    F --> G
    G --> H["Verification in the lab"]
🔑 Key terms
  • Hypothesis-driven hunt — A hunt starting from a specific, testable statement about adversary behaviour.
  • Pyramid of Pain — A ranking of indicators by how costly they are for an adversary to change.
  • TTP — Tactics, Techniques and Procedures — behaviour high on the pyramid, the best hunting target.
  • Baseline / 'normal' — Knowledge of expected activity, without which anomalies cannot be spotted.
  • Dwell time — How long an adversary is present before detection — hunting aims to shrink it.
  • Operationalising — Converting a hunt finding into a durable automated detection.
Example
In the wild. Long-dwell intrusions. Post-incident reports of major breaches repeatedly show adversaries

present for months, using legitimate tools (living-off-the-land) that signature detection missed but a behaviour-focused hunt (unusual parent/child processes, anomalous service-ticket requests, new persistence) would have surfaced. Pick one public report, extract the TTPs, and design the hunts that would have caught it.

Hands-On Practice

Tip
This is the main event. Bring up the lab, then work the walkthrough — every command has a ▸ Run button (needs the lab runner) and a 📋 Copy button. ~72 min, Kali attacker, fully local.

Mission. Run one full hypothesis-driven hunt loop and turn the result into a standing detection.

🧪 Lab setup — Defensive Security

  • Wazuh dashboard — https://localhost:5601 (or :443) — SIEM/XDR UI, rules, alerts
  • victim host + agent — generates the telemetry you hunt over
docker-compose.yml
# blue-lab/docker-compose.yml  —  Defensive part environment
# Wazuh ships an official single-node compose. Pull it and bring it up:
#   git clone https://github.com/wazuh/wazuh-docker -b v4.x
#   cd wazuh-docker/single-node && docker compose up -d
# Then add a target that generates events:
services:
  victim:
    image: ubuntu:22.04
    container_name: blue-victim
    command: sleep infinity
    networks: [labnet]
  # (install the Wazuh agent in 'victim', or run Sysmon on a Windows VM,
  #  then run Atomic Red Team tests to generate detections.)

networks:
  labnet:
    driver: bridge

Target for this lesson: the Wazuh/ELK stack with telemetry from the victim host. Full setup: Defensive Security lab environment.

Guided walkthrough

1Form a hypothesis
command
# 'An adversary is Kerberoasting: many 4769 with RC4 from one account.'
Expected output
A specific, testable statement tied to ATT&CK T1558.003.
A good hunt starts narrow and falsifiable, not 'look for bad stuff'.
2Confirm you have the data
command
# check that Windows 4769 events are being ingested
Expected output
4769 events present with TicketEncryptionType field.
You can only hunt what you collect — verify the data source first.
3Query for the pattern
command
index=win EventCode=4769 TicketEncryptionType=0x17
| stats dc(ServiceName) as svcs by Account
| where svcs > 10
Expected output
One account requested tickets for 14 distinct SPNs with RC4.
That fan-out with RC4 is the Kerberoasting fingerprint.
4Triage
command
# pivot on that account's other activity and logon source
Expected output
The account is a workstation user, not a scanner — suspicious.
Separate benign (vuln scanners, apps) from real attacker behaviour by context.
5Operationalise
command
# write a Sigma rule for the pattern and deploy it
Expected output
A standing detection now fires automatically on recurrence.
Every confirmed hunt should become a detection so the work compounds.

Live terminal

kali@threat-hunting — start the lab runner for a live shelloffline
Start the Lab Runner (see labserver/README.md), then click Connect lab runner and paste the token. Until then, copy commands from the walkthrough and run them in your own Kali terminal.
$

Try it yourself

Note
Try each for real. Open the hint only when stuck, the solution only to check.

Challenge 1. Generate the telemetry yourself with Atomic Red Team, then hunt it.

Hint

Atomic has tests mapped to ATT&CK technique IDs.

Solution

Invoke-AtomicTest T1558.003 on the lab host, then run your query and confirm it fires.

Challenge 2. Write a hunt for lateral movement via WMI (T1047) and name the data source.

Hint

Process creation with a wmiprvse.exe parent.

Solution

Sysmon Event 1 where ParentImage ends with wmiprvse.exe spawning shells/LOLBins.

Challenge 3. Explain why hunting for the attacker's C2 IP is weaker than hunting the behaviour.

Hint

Think Pyramid of Pain.

Solution

IPs rotate trivially (bottom of the pyramid); the TTP (roasting/WMI) is costly for the adversary to change.

Quick quiz

Per the Pyramid of Pain, which is most costly for an adversary to change?
Hashes/IPs/domains rotate trivially; changing tactics and techniques is expensive — so hunt behaviour, not atomic indicators.

Detect & defend (blue-team view)

  • This chapter is the blue side — each hunt output becomes a Sigma detection.
  • Track hunt→detection conversion and dwell-time reduction as program metrics.

Skills check

You can move on when you can, without notes:

Going deeper — Running a hunt, concretely

Hunt for Kerberoasting (T1558.003) as a worked example:

  1. Hypothesis: an adversary is requesting many service tickets with RC4 to crack offline.
  2. Data: Windows Security Event 4769 (service ticket requests), including ticket encryption type and requesting account.
  3. Hunt (pseudo-query): ``` EventID=4769 AND TicketEncryptionType=0x17 // RC4 | stats count by Account, count(distinct ServiceName) | where distinct_services > 10 // one account, many SPNs ```
  4. Triage: is this a vulnerability scanner, a misconfigured app, or an attacker? Pivot on the account's other activity.
  5. Operationalise: publish a Sigma rule for the pattern so future occurrences alert automatically.

Validate your hunts and detections with Atomic Red Team — execute the technique safely and confirm your hunt would have found it.

Check Yourself

Quick self-test — answers hidden. If you can't answer without notes, redo the relevant walkthrough step.

Q1. In one sentence, what security problem does Threat Hunting address or create?

Show answer

Threat Hunting matters because its behaviour determines where trust is placed; misplacing that trust is the root of the associated bug class.

Q2. Name one trust boundary involved in Threat Hunting and what crosses it.

Show answer

Any point where attacker-influenced data meets privileged processing — e.g. user input reaching an interpreter, or a token reaching a verifier.

Q3. Give one attack against Threat Hunting and the single control that most reduces its impact.

Show answer

State the attack precisely, then the primary control (validation, encoding, isolation, authentication, or least privilege) — not a laundry list.

Interview angles

  • Walk me through how Threat Hunting works, then tell me where you would attack it.
  • How would you detect Threat Hunting being abused in an environment you defend?
  • What is the difference between mitigating and eliminating the risk associated with Threat Hunting?

Pitfalls & Best Practice

Common mistakes

  • Hunting for hashes/IPs (bottom of the pyramid) that adversaries rotate trivially.
  • Starting without a hypothesis, producing aimless dashboard-staring.
  • Hunting for a technique whose required telemetry you do not actually collect.
  • Not baselining 'normal', so every result looks anomalous and nothing is actionable.
  • Finding something and not operationalising it into a detection, so the work does not compound.

Do this instead

  • Frame every hunt as a specific, testable hypothesis tied to an ATT&CK technique.
  • Target TTPs high on the Pyramid of Pain, not easily-changed atomic indicators.
  • Confirm you collect the needed data source before committing to a hunt.
  • Invest in understanding your environment's baseline; it is the hunter's core asset.
  • Turn every confirmed hunt into a Sigma detection and validate with Atomic Red Team.

Reference

MITRE ATT&CK Mapping

No single ATT&CK technique maps cleanly to this concept. Once you apply it offensively or defensively, map the specific behaviour using the ATT&CK chapter.

OWASP Mapping

  • See OWASP Top 10 for the relevant category when this applies to web systems.

CWE Mapping

  • No direct weakness ID; when this concept fails in code it usually surfaces as one of the CWE Top 25 entries.

CAPEC Mapping

  • No single attack pattern; see the CAPEC chapter to map behaviour to patterns.

CVE References

  • No canonical CVE for a concept page. Search the NVD for concrete instances when studying real cases.

NIST References

RFC References

  • No governing RFC for this topic. Where a protocol is involved, its RFC is linked from the relevant networking chapter.

Research Papers

  • The Pyramid of Pain — David Bianco, 2013

Books

  • Blue Team Handbook — Don Murdoch
  • The Practice of Network Security Monitoring — Richard Bejtlich
  • Intelligence-Driven Incident Response — Roberts & Brown

Official Documentation


Part of the Defensive Security section of Cybersecurity-Mastery. 🟠 Advanced · ~72 min hands-on · Last updated 2026-08-12.

Cybersecurity-Mastery — interactive security learning · runs locally