Threat Hunting is the proactive search for threats that have evaded automated detection. While SOC analysts wait for alerts, threat hunters actively look for hidden adversaries. It's like going from alarm-based security to actively patrolling for intruders.
Think of it as the difference between a home alarm and a security guard doing rounds. The alarm only triggers when something specific happens. The guard looks for anything suspicious - an open window, a car circling the block, anything that doesn't fit the pattern. Threat hunters look for anomalies that detections miss.
Hunt Assumes Compromise
Hunting vs Detection
1Threat Hunting vs Alert-Based Detection:2 3ALERT-BASED DETECTION4─────────────────────────────────────────────────────────────────5├── Reactive: Wait for rules to trigger6├── Known threats: Detects what rules define7├── Automated: Runs continuously8├── Scalable: Handles volume well9└── Limitation: Can't catch unknown TTPs10 11THREAT HUNTING12─────────────────────────────────────────────────────────────────13├── Proactive: Actively search for threats14├── Unknown threats: Finds what rules miss15├── Human-driven: Analyst expertise required16├── Hypothesis-based: Test theories about attacks17└── Output: New detections, validated or disproved hypotheses18 19COMPLEMENTARY APPROACHES20─────────────────────────────────────────────────────────────────21Detection finds known bad (rules)22Hunting finds unknown bad (anomalies)23Together = comprehensive coverage24 25Example:26├── Detection rule: 606070;">#a5d6ff;">"PowerShell with -EncodedCommand"27├── Hunting query: 606070;">#a5d6ff;">"What PowerShell ran without detection?"28└── Result: Find new evasion technique → Create new ruleHypothesis-Driven Hunting
1Hypothesis-Driven Hunting Framework:2 3THE HUNTING LOOP4─────────────────────────────────────────────────────────────────5 ┌─────────────────────────────────────────┐6 │ 1. CREATE HYPOTHESIS │7 │ 606070;">#a5d6ff;">"Attackers may be using X technique" │8 └───────────────────┬─────────────────────┘9 ↓10 ┌─────────────────────────────────────────┐11 │ 2. INVESTIGATE │12 │ Search data, analyze patterns │13 └───────────────────┬─────────────────────┘14 ↓15 ┌─────────────────────────────────────────┐16 │ 3. IDENTIFY PATTERNS/ANOMALIES │17 │ Find evidence supporting hypothesis │18 └───────────────────┬─────────────────────┘19 ↓20 ┌─────────────────────────────────────────┐21 │ 4. RESPOND OR TUNE │22 │ Incident? → Respond │23 │ Normal? → Document baseline │24 │ Gap? → Create detection │25 └───────────────────┬─────────────────────┘26 ↓27 (Repeat)28 29HYPOTHESIS SOURCES30─────────────────────────────────────────────────────────────────31├── Threat Intelligence: APT29 uses X technique32├── MITRE ATT&CK: Hunt for T1059.001 gaps33├── Red Team findings: What did pentest bypass?34├── Industry reports: Ransomware groups doing Y35├── Anomaly alerts: Investigate unusual patterns36└── Experience: 606070;">#a5d6ff;">"Something feels off about..."37 38GOOD HYPOTHESIS EXAMPLES39─────────────────────────────────────────────────────────────────40606070;">#a5d6ff;">"Attackers may be using LOLBins for execution"41606070;">#a5d6ff;">"Data may be exfiltrating via DNS tunneling"42606070;">#a5d6ff;">"Persistence may exist via scheduled tasks"43606070;">#a5d6ff;">"Lateral movement may be occurring via WMI"44 45BAD HYPOTHESIS EXAMPLES46─────────────────────────────────────────────────────────────────47606070;">#a5d6ff;">"Find all the hackers" (too vague)48606070;">#a5d6ff;">"Look at everything" (not actionable)49606070;">#a5d6ff;">"Check if we're secure" (not specific)Hunting with MITRE ATT&CK
1Using ATT&CK for Threat Hunting:2 3STEP 1: IDENTIFY TECHNIQUE TO HUNT4─────────────────────────────────────────────────────────────────5Choose based on:6├── Threat intel (what APTs use against your sector)7├── Detection gaps (what you can't currently detect)8├── High-impact techniques (credential access, exfil)9└── Prevalence in incidents10 11STEP 2: UNDERSTAND THE TECHNIQUE12─────────────────────────────────────────────────────────────────13For T1059.001 (PowerShell):14├── How is it used by attackers?15├── What are the variations?16├── What artifacts does it leave?17└── What data sources capture it?18 19STEP 3: FORM HYPOTHESIS20─────────────────────────────────────────────────────────────────21"Attackers may be using PowerShell to download22and execute payloads while evading our detection."23 24STEP 4: BUILD HUNT QUERY25─────────────────────────────────────────────────────────────────26Splunk example:27index=sysmon EventCode=128 Image=606070;">#a5d6ff;">"*\powershell.exe"29 (CommandLine=606070;">#a5d6ff;">"*IEX*" OR CommandLine="*DownloadString*"30 OR CommandLine=606070;">#a5d6ff;">"*WebClient*" OR CommandLine="*Invoke-*")31| stats count by ComputerName, User, CommandLine32 33STEP 5: ANALYZE RESULTS34─────────────────────────────────────────────────────────────────35├── Review each result36├── Is it malicious or legitimate?37├── Can we baseline legitimate usage?38└── What variations did we miss?39 40STEP 6: ACTION41─────────────────────────────────────────────────────────────────42Found malicious? → Incident response43Found gap? → Create detection rule44Found nothing? → Document, try different angleHunt Query Examples
1-- HUNTING QUERIES (Splunk SPL format)2 3-- HUNT: Unusual Parent-Child Process Relationships4-- Hypothesis: Attackers spawn shells from unexpected parents5index=sysmon EventCode=16| eval parent_child=ParentImage.606070;">#a5d6ff;">"|".Image7| stats count by parent_child8| where count < 59| sort count10 11-- HUNT: PowerShell Download Cradles12-- Hypothesis: Attackers download payloads via PowerShell13index=sysmon EventCode=1 Image=606070;">#a5d6ff;">"*\powershell.exe"14| where match(CommandLine, 606070;">#a5d6ff;">"(?i)(iex|invoke-expression|downloadstring|webclient|bitstransfer)")15| table _time, ComputerName, User, CommandLine16 17-- HUNT: Rare Scheduled Tasks18-- Hypothesis: Attackers create tasks for persistence19index=sysmon EventCode=120| where ParentImage=606070;">#a5d6ff;">"*\schtasks.exe" OR21 match(CommandLine, 606070;">#a5d6ff;">"(?i)schtasks.*\/create")22| stats count by CommandLine23| where count < 324 25-- HUNT: Lateral Movement via WMI26-- Hypothesis: Attackers use WMI for remote execution27index=sysmon EventCode=128| where ParentImage=606070;">#a5d6ff;">"*\WmiPrvSE.exe"29| stats count by ComputerName, User, Image, CommandLine30 31-- HUNT: Unusual Outbound Connections32-- Hypothesis: C2 over non-standard ports33index=firewall action=allow direction=outbound34| where NOT match(dest_port, 606070;">#a5d6ff;">"^(80|443|53|25)$")35| stats count by src_ip, dest_ip, dest_port36| where count > 10037 38-- HUNT: DNS Tunneling39-- Hypothesis: Data exfiltration via DNS40index=dns41| eval query_length=len(query)42| where query_length > 5043| stats count, avg(query_length) by src_ip44| where count > 1001-- Elastic KQL equivalents2 3606070;">// Unusual PowerShell4event.code: 1 AND process.name: 606070;">#a5d6ff;">"powershell.exe" AND5process.command_line: (*DownloadString* OR *IEX* OR *WebClient*)6 7606070;">// WMI Remote Execution8event.code: 1 AND process.parent.name: 606070;">#a5d6ff;">"WmiPrvSE.exe"9 10606070;">// Scheduled Task Creation11event.code: 1 AND process.command_line: *schtasks* AND12process.command_line: */create*Anomaly-Based Hunting
1Anomaly-Based Hunting Approaches:2 3BASELINE COMPARISON4─────────────────────────────────────────────────────────────────5Concept: Establish normal, find deviations6 7Example: Login times81. Baseline: Users typically log in 8-6 PM92. Hunt: Find logins at 3 AM103. Analyze: Is it attacker or legitimate exception?11 12Query (Splunk):13index=windows EventCode=462414| eval hour=strftime(_time, 606070;">#a5d6ff;">"%H")15| where hour < 6 OR hour > 2016| stats count by user, hour17| sort -count18 19FIRST-TIME OCCURRENCE20─────────────────────────────────────────────────────────────────21Concept: Alert on 606070;">#a5d6ff;">"first time ever" events22 23Examples:24├── User logs into server for first time25├── New service installed on DC26├── First connection to external IP27└── New scheduled task on workstation28 29Query (Splunk):30index=windows EventCode=4624 LogonType=1031| stats earliest(_time) as first_seen by user, dest32| where first_seen > relative_time(now(), 606070;">#a5d6ff;">"-24h")33 34STATISTICAL ANOMALIES35─────────────────────────────────────────────────────────────────36Concept: Find outliers from normal distribution37 38Examples:39├── User with 10x normal data transfer40├── Process with unusual network volume41├── Host with spike in DNS queries42└── Account with abnormal login frequency43 44Query (Splunk):45index=proxy46| stats sum(bytes_out) as total by src_ip47| eventstats avg(total) as avg_bytes, stdev(total) as stdev_bytes48| where total > (avg_bytes + (3 * stdev_bytes))49 50RARE OCCURRENCES51─────────────────────────────────────────────────────────────────52Concept: Investigate things that rarely happen53 54Examples:55├── Rare process names56├── Unusual port combinations57├── Uncommon user-agent strings58└── Infrequent command combinationsHunt Scenarios
1Example Hunt: Persistence Mechanisms2 3HYPOTHESIS4─────────────────────────────────────────────────────────────────5"Attackers may have established persistence via registry6Run keys that are not flagged by our current detections."7 8DATA SOURCES9─────────────────────────────────────────────────────────────────10├── Sysmon Event 12/13/14 (Registry)11├── Windows Security Event 465712├── EDR registry telemetry13 14HUNT QUERIES15─────────────────────────────────────────────────────────────────16Splunk:17index=sysmon EventCode=1318| where match(TargetObject, 606070;">#a5d6ff;">"(?i)(currentversion\\run|policies\\explorer\\run)")19| stats count by ComputerName, TargetObject, Details20| sort -count21 22ANALYSIS23─────────────────────────────────────────────────────────────────24For each result:25├── Is the executable path legitimate?26├── Is it in an unusual location (Temp, Downloads)?27├── Is the filename suspicious?28├── Does the hash exist in threat intel?29└── Is this baseline for this system?30 31FINDINGS EXAMPLE32─────────────────────────────────────────────────────────────────33MALICIOUS FOUND:34├── WORKSTATION-4235├── Key: HKCU\Software\Microsoft\Windows\CurrentVersion\Run36├── Value: 606070;">#a5d6ff;">"SecurityUpdate"37├── Data: 606070;">#a5d6ff;">"C:\Users\Public\Downloads\svc.exe"38└── Action: Incident Response initiated39 40FALSE POSITIVE:41├── All workstations42├── Key: HKLM\...\Run43├── Value: 606070;">#a5d6ff;">"Defender"44├── Data: 606070;">#a5d6ff;">"C:\Program Files\Windows Defender\..."45└── Action: Add to baseline/whitelistDocumenting Hunts
1Hunt Documentation Template:2 3HUNT REPORT4═══════════════════════════════════════════════════════════════5 6Hunt ID: TH-2024-0427Hunt Name: Scheduled Task Persistence8Date: 2024-07-159Hunter: Analyst Name10Status: Completed11 12HYPOTHESIS13─────────────────────────────────────────────────────────────────14Attackers may have created malicious scheduled tasks on15workstations for persistence that evade our current detections.16 17MITRE ATT&CK MAPPING18─────────────────────────────────────────────────────────────────19├── T1053.005 - Scheduled Task20└── TA0003 - Persistence21 22DATA SOURCES23─────────────────────────────────────────────────────────────────24├── Sysmon Event ID 1 (Process Creation)25├── Windows Security Event 4698 (Task Created)26└── Task Scheduler logs27 28SCOPE29─────────────────────────────────────────────────────────────────30├── Time range: Last 30 days31├── Systems: All workstations (2,500 endpoints)32└── Query execution: 4 hours33 34QUERIES USED35─────────────────────────────────────────────────────────────────36[Insert queries here]37 38FINDINGS39─────────────────────────────────────────────────────────────────40Total tasks reviewed: 34241Known legitimate: 32042New legitimate: 1843Suspicious: 344Confirmed malicious: 145 46MALICIOUS FINDING47─────────────────────────────────────────────────────────────────48System: WORKSTATION-4249Task Name: WindowsUpdateTask50Action: C:\Users\Public\svc.exe51Creation Time: 2024-06-28 02:34:0052Created By: jsmith53Status: Escalated to IR (INC-2024-089)54 55RECOMMENDATIONS56─────────────────────────────────────────────────────────────────571. Create detection rule for tasks running from Public folder582. Add baseline whitelist for legitimate tasks593. Schedule recurring hunt quarterlyHunt Methodology
Threat Hunting Workflow
Knowledge Check
What is the primary difference between threat hunting and alert-based detection?
Challenges
Design a Threat Hunt
ChallengeDesign a threat hunt for MITRE ATT&CK technique T1059.001 (PowerShell). Include: hypothesis, data sources needed, a query, and what you would look for in results.
Need a hint? (4 available)
Key Takeaways
- Hunting is proactive search; detection is reactive to rules
- Form specific, testable hypotheses based on ATT&CK or threat intel
- Hunting assumes breach - you're proving you're NOT compromised
- Anomaly hunting: first-time events, rare occurrences, statistical outliers
- Document everything - findings become future detections
- Hunt output: confirmed threats, new detections, validated baselines