Opening Framing: Beyond Reactive Defense
Alerts catch known threats. But what about threats that don't trigger alerts? Sophisticated attackers evade detection. They use legitimate tools, blend with normal traffic, and avoid obvious malware. Automated detection misses them.
Threat hunting is the answer. Instead of waiting for alerts, hunters proactively search for evidence of compromise. They start with a hypothesis about attacker behavior and look for evidence that proves or disproves it.
This week covers hunting methodology, hypothesis development, hunting techniques, and how to turn hunt findings into improved detection.
Key insight: Hunting assumes breach. The question isn't "are we compromised?" but "where is the evidence of compromise hiding?"
1) Threat Hunting Fundamentals
Understanding what makes hunting different from monitoring:
Hunting vs. Monitoring:
Monitoring (Reactive):
- Waits for alerts
- Rule-based detection
- Automated
- Known threats
- High volume, low touch
Hunting (Proactive):
- Seeks evidence
- Hypothesis-based
- Human-driven
- Unknown threats
- Low volume, high touch
They complement each other:
- Monitoring catches known threats at scale
- Hunting finds threats monitoring misses
- Hunt findings improve monitoring
Hunt Maturity Model:
HMM0 - Initial:
- No hunting capability
- Purely reactive
- Limited data collection
HMM1 - Minimal:
- Some ad-hoc hunting
- Relies on IOC searches
- Limited methodology
HMM2 - Procedural:
- Documented procedures
- Regular hunting cadence
- Some hypothesis-based hunts
HMM3 - Innovative:
- Custom tools and techniques
- Threat intel driven
- Creates new detection methods
HMM4 - Leading:
- Automated hunt processes
- Original research
- Contributes to community
Most organizations: HMM1-HMM2
Goal: Progress toward HMM3
Requirements for Hunting:
Data:
- Comprehensive log collection
- Endpoint telemetry (EDR)
- Network visibility
- Historical retention
Tools:
- SIEM with flexible queries
- EDR with hunting capability
- Network analysis tools
- Custom scripts
Skills:
- Deep technical knowledge
- Attacker mindset
- Pattern recognition
- Query language proficiency
Time:
- Dedicated hunting time
- Not interrupt-driven
- Allows deep investigation
Key insight: You can't hunt what you can't see. Data collection and retention are prerequisites for effective hunting.
2) Hypothesis-Driven Hunting
Effective hunts start with a hypothesis:
Hypothesis Structure:
"If [threat actor/technique] is present in our environment,
we would expect to see [observable evidence]."
Example hypotheses:
1. "If attackers are using PowerShell for execution,
we would see encoded command lines or unusual
PowerShell parent processes."
2. "If data exfiltration is occurring,
we would see large outbound transfers to
unusual destinations outside business hours."
3. "If credential theft has occurred,
we would see authentication from unusual
locations or impossible travel patterns."
4. "If lateral movement is happening,
we would see admin tools like PsExec or
WMI being used from non-admin systems."
Hypothesis Sources:
Threat Intelligence:
- "APT29 uses scheduled tasks for persistence"
- Hunt: Scheduled tasks created recently
- Focus: Non-standard locations, encoded commands
ATT&CK Techniques:
- T1053.005: Scheduled Task/Job
- Hunt: schtasks.exe execution
- Look for: Unusual task names, paths, triggers
Recent Incidents:
- "We saw attackers use service creation"
- Hunt: New services across environment
- Check: Services not in baseline
Industry Reports:
- "Healthcare sector seeing Ryuk ransomware"
- Hunt: Ryuk IOCs and TTPs
- Look for: Precursor malware (TrickBot, BazarLoader)
Anomalies Observed:
- "Spike in DNS queries to rare TLDs"
- Hunt: What's generating these queries?
- Investigate: Process and destination
The Hunting Loop:
┌────────────────────────────────────────┐
│ │
▼ │
┌──────────┐ │
│Hypothesis│ ← What are we looking for? │
└────┬─────┘ │
↓ │
┌──────────┐ │
│ Collect │ ← Gather relevant data │
└────┬─────┘ │
↓ │
┌──────────┐ │
│ Analyze │ ← Search for evidence │
└────┬─────┘ │
↓ │
┌──────────┐ │
│ Evaluate │ ← What did we find? │
└────┬─────┘ │
│ │
├─→ Finding! → Investigate → Respond │
│ │
└─→ No finding → Refine hypothesis ─────┘
or → Improve detection
Key insight: A hunt without a hypothesis is just browsing logs. Hypotheses focus effort and make hunts measurable.
3) Hunting Techniques
Multiple approaches to find hidden threats:
Searching (IOC-based):
Look for known bad indicators:
# Search for known malicious hash
index=edr file_hash IN (watchlist_hashes)
# Search for known C2 domain
index=dns query IN (watchlist_domains)
# Search for known attacker IP
index=firewall dest_ip IN (watchlist_ips)
Limitations:
- Only finds known threats
- IOCs change frequently
- Reactive, not proactive
Best for:
- Validating threat intel
- Checking for known campaigns
- Quick sweeps after new intel
Clustering (Pattern-based):
Group similar activities, look for anomalies:
# Group processes by parent
index=edr event_type=process_start
| stats count by parent_process, process
| sort -count
# Group network connections by destination
index=firewall action=allow
| stats sum(bytes) as total_bytes by dest_ip
| sort -total_bytes
# Group authentications by source
index=windows EventCode=4624
| stats count dc(user) as unique_users by src_ip
| where unique_users > 5
Look for:
- Outliers in clusters
- Unexpected groupings
- Rare combinations
Stacking (Frequency Analysis):
Find rare events that might be malicious:
# Rare processes across environment
index=edr event_type=process_start
| stats count by process_name
| where count < 5
# Rare outbound destinations
index=firewall direction=outbound
| stats count by dest_ip
| where count < 10
# Rare scheduled tasks
index=windows EventCode=4698
| stats count by task_name
| where count = 1
Principle: Attackers do unusual things
Rare ≠ malicious, but warrants investigation
Behavioral Analysis:
Look for suspicious behavior patterns:
# PowerShell with encoded commands
index=windows EventCode=4104
| search "*-enc*" OR "*-encoded*"
# Process running from temp directories
index=edr event_type=process_start
| where match(process_path, "(?i)\\\\(temp|tmp)\\\\")
# Admin tools from non-admin systems
index=edr process_name IN ("psexec.exe","wmic.exe")
| where NOT match(host, "admin-*")
# Network connections from unusual processes
index=edr event_type=network_connection
| where process_name IN ("notepad.exe","calc.exe")
Focus: What attackers DO, not what files they use
Key insight: Combine techniques. Searching finds known threats, stacking finds rare events, behavioral analysis finds suspicious actions.
4) ATT&CK-Based Hunting
MITRE ATT&CK provides structured hunting guidance:
Using ATT&CK for Hunt Planning:
1. Select relevant techniques
- Based on threat intel
- Based on gaps in detection
- Based on high-impact techniques
2. Understand the technique
- How does it work?
- What variations exist?
- What artifacts does it leave?
3. Identify data sources
- What logs capture this?
- Do we collect them?
- What fields are relevant?
4. Develop hunt query
- Translate technique to query
- Account for variations
- Reduce false positives
5. Execute and analyze
- Run query
- Review results
- Investigate anomalies
Example: Hunting T1059.001 (PowerShell):
Technique: T1059.001 - Command and Scripting Interpreter: PowerShell
Attacker use:
- Download and execute payloads
- Run encoded commands
- Bypass execution policies
Data sources:
- Windows PowerShell logs (4103, 4104)
- Process creation (Sysmon 1, Security 4688)
- Script block logging
Hunt queries:
# Encoded commands
index=windows source="WinEventLog:Microsoft-Windows-PowerShell*"
| search "*-enc*" OR "*FromBase64String*"
# Download cradles
index=windows source="WinEventLog:Microsoft-Windows-PowerShell*"
| search "*WebClient*" OR "*DownloadString*" OR "*Invoke-WebRequest*"
# Unusual parent processes
index=sysmon EventCode=1 Image="*powershell.exe"
| stats count by ParentImage
| where NOT match(ParentImage, "(explorer|cmd|services)")
# PowerShell network connections
index=sysmon EventCode=3 Image="*powershell.exe"
| stats count by DestinationIp, DestinationPort
High-Value Techniques to Hunt:
Initial Access:
- T1566: Phishing (email with attachments/links)
- T1078: Valid Accounts (compromised credentials)
Execution:
- T1059: Command and Scripting Interpreter
- T1053: Scheduled Task/Job
Persistence:
- T1547: Boot or Logon Autostart
- T1543: Create or Modify System Process
Credential Access:
- T1003: OS Credential Dumping
- T1558: Steal or Forge Kerberos Tickets
Lateral Movement:
- T1021: Remote Services
- T1570: Lateral Tool Transfer
Exfiltration:
- T1041: Exfiltration Over C2 Channel
- T1567: Exfiltration Over Web Service
Key insight: ATT&CK provides a common language and framework for hunting. It ensures comprehensive coverage and facilitates sharing hunt findings.
5) Documenting and Operationalizing Hunts
Hunts should produce lasting value:
Hunt Documentation:
Hunt Report Template:
1. Hunt Overview
- Hypothesis
- Timeframe
- Data sources used
- Techniques covered (ATT&CK)
2. Methodology
- Queries executed
- Tools used
- Analysis approach
3. Findings
- What was discovered
- True positives
- Interesting anomalies
- False positive patterns
4. Recommendations
- Detection rules to create
- Visibility gaps to address
- Process improvements
5. Metrics
- Time spent
- Systems/users covered
- Findings by category
From Hunt to Detection:
Convert successful hunts to automated detection:
Hunt finding:
"Found 3 instances of PowerShell downloading
content using WebClient from unusual parent processes"
Detection rule:
alert any where
process.name == "powershell.exe" and
process.command_line contains "WebClient" and
process.parent.name not in ("explorer.exe", "cmd.exe")
Benefits:
- Future occurrences automatically detected
- Hunting effort has lasting value
- Detection coverage improves
Document why the rule exists:
- Link to hunt report
- ATT&CK technique
- Expected false positives
Building a Hunt Program:
Hunt Program Elements:
Cadence:
- Regular scheduled hunts (weekly/monthly)
- Ad-hoc hunts based on intel
- Post-incident hunts
Coverage tracking:
- Which techniques have been hunted?
- When was each last hunted?
- What's the gap?
Metrics:
- Hunts conducted
- Hours spent
- Findings discovered
- Rules created
- Coverage improvement
Maturation:
- Document successful hunt queries
- Build query library
- Automate repeatable hunts
- Train new hunters
Key insight: A hunt that doesn't result in improved detection or documented knowledge is a missed opportunity.
Real-World Context: Hunting in Practice
Threat hunting catches what automation misses:
Living Off the Land: Attackers use legitimate tools (PowerShell, WMI, PsExec) that don't trigger antivirus. Hunting looks for suspicious USE of legitimate tools.
Dwell Time Reduction: Industry average dwell time (time from compromise to detection) is months. Hunting finds attackers faster by actively searching rather than waiting for alerts.
Detection Engineering: Hunt findings become detection rules. The best detection engineers are hunters who understand what real attacks look like in data.
MITRE ATT&CK Application:
- Coverage Mapping: Which techniques can we hunt for?
- Gap Identification: Which techniques have no coverage?
- Hunt Prioritization: Focus on high-impact gaps
Key insight: Hunting is how you find attackers who are trying not to be found. It requires skill, time, and the right data.
Guided Lab: Hypothesis-Driven Hunt
Practice developing and executing a threat hunt.