DefensiveHub

Threat Hunting: Find the Activity Your Alerts Missed

How to look for an attacker no alert is telling you about, and how a hypothesis becomes a query in KQL or SPL.

Ahmed Eid 5 min read

Topic
Threat Hunting
Level
Beginner to intermediate
Techniques
T1204.002 · T1059.001
Data sources
DeviceProcessEvents · 4688
You leave with
One hypothesis, a query in KQL and SPL, and a new detection

The case this article hunts

A teaching scenario written for this article. Click any step to see why it is suspicious and the query that catches it.

Most SOC teams work reactively: an alert fires, and an analyst opens the ticket and investigates. That work is essential, but it assumes your detection tools saw everything. Threat hunting starts from the opposite assumption: that someone is inside the network right now, and no alert has fired.

Why threat hunting?

Detection tools run on rules written in advance, and any written rule describes behavior we’ve already seen. A skilled attacker deliberately stays in the space without rules: using tools already on the machine, like PowerShell and WMI, moving slowly, and using legitimate accounts.

That’s where the hunter comes in. A hunter doesn’t wait to be alerted. They ask a specific question about the environment and look for the answer in the logs themselves. If they find something, they turn it into a new detection, so that next time the tool finds it.

The hypothesis comes first

Hunting without a hypothesis turns into random browsing through logs. A good hypothesis is specific, testable, and based on real attacker behavior. For example:

HypothesisIf an attacker is using Office macros to get in, we will see winword.exe or excel.exe starting powershell.exe or cmd.exe as a child process.

This hypothesis maps to a known MITRE ATT&CK technique, T1204.002 (Malicious File), and it says exactly what to look for and where. It is the same step you saw in the case above.

The hunting loop

Most well-known frameworks agree on a cycle close to this one. The last step brings you back to the first, knowing more about your environment:

12345The loop
  1. Hypothesis generation from threat intelligence, an ATT&CK technique, or something odd you noticed.
  2. Data collection: which log source answers the question, and is it collected at all?
  3. Data analysis: query, filter out the noise, then look at what is left one by one.
  4. Investigation and validation: confirm whether a finding is really malicious.
  5. Reporting and remediation: every successful hunt leaves a detection or better visibility behind.

From hypothesis to query

The hypothesis above becomes a simple query. Use KQL if you are on Microsoft Defender or Sentinel, and SPL if you are on Splunk. Your choice is remembered across the site:

Defender XDR · DeviceProcessEventsWindows Security · 4688
DeviceProcessEvents
| where InitiatingProcessFileName in~ ("winword.exe", "excel.exe")
| where FileName in~ ("powershell.exe", "cmd.exe")
| summarize Count = count(), FirstSeen = min(Timestamp)
    by DeviceName, InitiatingProcessFileName, FileName, ProcessCommandLine
| sort by Count desc
index=wineventlog EventCode=4688
  (ParentProcessName="*\\winword.exe" OR ParentProcessName="*\\excel.exe")
  (NewProcessName="*\\powershell.exe" OR NewProcessName="*\\cmd.exe")
| stats count min(_time) as first_seen by host, ParentProcessName, NewProcessName, CommandLine
| sort - count

The result is not the answer, only where the investigation starts. Every row needs questions: which user? What exactly is the command line? Did the host connect out a few minutes later?

From results to a decision

Let’s read the results with a hunter’s mindset. In a large environment, the query above can return dozens of rows, most of them probably normal work. The goal is to narrow the number down step by step, not to give every row equal attention:

From many rows to a decision

All query resultsNormal and suspicious mixedAfter removing baselineKnown normal drops outRows worth investigatingCommand line and contextDecisionIncident, detection or documentation
The order is illustrative, and counts vary by environment.

Start with these questions for each suspicious row:

  • Command line: does it contain an encoded command, a download or a hidden window?
  • User: is it normal for them to run macros, or is this the first time?
  • File: where did the document come from? An email, or an internal share?
  • What happened next: is there an outbound connection, a new process or a scheduled task?

If all the answers look normal, record that as baseline so you don’t spend time on it again. If something looks suspicious, escalate it as an incident. Either way, document the result.

Where hypotheses come from

You don’t have to wait for an idea. There are 3 practical sources:

  • Threat intelligence: a report on a threat actor targeting your sector, with its behavior turned into a question about your environment.
  • MITRE ATT&CK: pick a technique you have no detection for and hunt it manually.
  • Anomalies: something unusual you noticed in the baseline, like an account that started working at night.

A good hypothesis is written as a statement that can be proved or disproved: “if X is happening, we’ll find Y in Z”. If you don’t know where you’d look, it still needs refining.

Frameworks that organize the work

  • PEAK: a framework from Splunk that divides hunting into 3 types: hypothesis-driven, baseline and model-assisted.
  • TaHiTI: a European framework focused on connecting hunting to threat intelligence, with clear stages for documentation and handover.
  • MITRE ATT&CK: not a hunting framework in itself, but the reference your hypotheses come from and the yardstick for your coverage.

Practices that make the difference

Start with the data you have, not the data you wish you had. The first hunt often shows that the log source you need is not collected at all, and that is a finding worth taking to management.

Know normal before you look for strange. Your environment’s baseline is what lets you tell an admin doing their job from an attacker imitating one.

Finally: a hunt that found nothing is not a failure. If it was built on a clear hypothesis and documented well, you now know something about your environment you did not know yesterday.

Measuring hunting

The number of incidents found is a weak measure on its own, because a clean environment will score zero. Also measure:

  • New detections produced by hunts.
  • Missing log sources discovered and fixed.
  • Techniques that gained coverage.
  • The time your team needs to get from hypothesis to result.

Common mistakes

  • Hunting without a specific question.
  • Relying on old IOCs rather than behavior.
  • Not writing down what you did, so the team repeats the same work.
  • Closing a hunt without turning the result into a detection or an improvement.
  • Judging a row without knowing the baseline.

References

Ahmed Eid. I write about the defensive security work I do every day, and explain it in Arabic to save you time.