Threat Hunting & Detection
When to Activate
- Proactive threat hunting across infrastructure
- Correlating security events across multiple sources
- Detecting anomalous behavior patterns
- Mapping attacks to MITRE ATT&CK framework
- Writing detection rules (Sigma, YARA, Snort)
- Incident response triage
MITRE ATT&CK Mapping
Common Techniques to Hunt
| Tactic |
Technique |
Detection Focus |
| Initial Access |
Phishing, Exploit Public-Facing App |
Email gateways, web WAF logs |
| Execution |
PowerShell, WMI, Scheduled Tasks |
PS logs, Sysmon Event ID 1 |
| Persistence |
Registry Run Keys, Scheduled Tasks |
Registry monitoring, task scheduler logs |
| Privilege Escalation |
Token Manipulation, Exploitation |
Access token changes, exploit indicators |
| Defense Evasion |
Obfuscated Files, Indicator Removal |
File entropy analysis, log gap detection |
| Credential Access |
LSASS Memory, OS Credential Dumping |
LSASS access patterns, dump file creation |
| Discovery |
Network Share Discovery, System Info Discovery |
Net commands, systeminfo execution |
| Lateral Movement |
SMB/Windows Admin Shares, WMI |
SMB connection patterns, remote WMI calls |
| Collection |
Data Staged, Archive Collected Data |
Unusual archive operations, staging directories |
| Exfiltration |
Exfiltration Over C2, DNS |
DNS query volume anomalies, C2 beacon patterns |
Log Analysis & Correlation
Key Event Sources
# Windows (Sysmon)
Event ID 1: Process creation
Event ID 3: Network connection
Event ID 7: Image loaded
Event ID 11: File creation
Event ID 12: Registry object added/modified
Event ID 13: Registry value set
Event ID 15: File creation stream hash
Event ID 17: Pipe created
Event ID 22: DNS query
Event ID 25: Process tampering
# Linux (auditd)
type=EXECVE: Command execution
type=CONNECT: Network connections
type=PATH: File access
type=SYSCALL: System calls (esp. ptrace, execve)
# Network (Zeek/Suricata)
DNS queries and responses
HTTP requests and responses
SSL/TLS certificate analysis
File extraction and hashing
Correlation Queries
-- Splunk: PowerShell encoded command
index=security EventCode=4688
| where match(Process_Command_Line, "powershell.*-enc")
| stats count by Computer, User, _time
| where count > 3
-- Splunk: Lateral movement via PsExec
index=security EventCode=7045 Service_Name="PSEXESVC"
| stats count by Computer, User
| where count > 1
-- Sigma equivalent
detection:
selection:
EventID: 4688
CommandLine|contains|all:
- 'powershell'
- '-enc'
- '-encodedcommand'
condition: selection
Behavioral Anomaly Detection
Baselines
# Normal user behavior:
- Login times and duration
- Common processes and commands
- Network destinations and volumes
- File access patterns
# Anomaly indicators:
- Processes running at unusual hours
- New network destinations (never before seen)
- Sudden increase in data access volume
- Commands that deviate from user's normal pattern
- Service installations on workstations
Hunting Hypotheses
# Generate and test hunting hypotheses:
1. "If there's credential dumping, we'll see Mimikatz or similar tool execution"
2. "If lateral movement occurs, we'll see new admin share connections"
3. "If data exfiltration happens, we'll see unusual outbound DNS or HTTPS traffic"
4. "If there's persistence, we'll see new scheduled tasks or registry modifications"
# Validate with:
- Historical log analysis (last 30-90 days)
- Endpoint telemetry (processes, network, files)
- Network flow data (NetFlow, PCAP)
- Cloud audit logs (CloudTrail, Azure Activity Log)
Detection Rule Development
Sigma Rule Template
title: Suspicious PowerShell Execution
id: rule-uuid-here
status: experimental
description: Detects PowerShell execution with encoded commands and download cradles
references:
- https://attack.mitre.org/techniques/T1059/001/
author: analyst
date: 2026/05/19
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith: '\powershell.exe'
encoded:
CommandLine|contains:
- '-enc'
- '-encodedcommand'
download:
CommandLine|contains:
- 'DownloadString'
- 'DownloadFile'
- 'IEX'
- 'Invoke-Expression'
condition: selection and (encoded or download)
falsepositives:
- Legitimate IT automation scripts
- Software deployment tools
level: high
tags:
- attack.execution
- attack.t1059.001
YARA Network Detection
rule C2_Beacon_Pattern {
meta:
description = "Detects C2 beacon traffic patterns"
strings:
$beacon_http = /POST \/gate\.php HTTP\/1\.1\r\nHost: [^\r\n]+\r\nUser-Agent: Mozilla\/[\d.]+/
$beacon_dns = /[a-z0-9]{32,}\.attacker-domain\.(com|net|org)/
condition:
$beacon_http or $beacon_dns
}
1---2name: threat-hunting-23description: Proactive threat hunting, IOC extraction, MITRE ATT&CK mapping, behavioral anomaly detection, log analysis correlation4---5
6# Threat Hunting & Detection
7
8## When to Activate
9
10- Proactive threat hunting across infrastructure
11- Correlating security events across multiple sources
12- Detecting anomalous behavior patterns
13- Mapping attacks to MITRE ATT&CK framework
14- Writing detection rules (Sigma, YARA, Snort)
15- Incident response triage
16
17## MITRE ATT&CK Mapping
18
19### Common Techniques to Hunt
20
21| Tactic | Technique | Detection Focus |
22|--------|-----------|----------------|
23| Initial Access | Phishing, Exploit Public-Facing App | Email gateways, web WAF logs |
24| Execution | PowerShell, WMI, Scheduled Tasks | PS logs, Sysmon Event ID 1 |
25| Persistence | Registry Run Keys, Scheduled Tasks | Registry monitoring, task scheduler logs |
26| Privilege Escalation | Token Manipulation, Exploitation | Access token changes, exploit indicators |
27| Defense Evasion | Obfuscated Files, Indicator Removal | File entropy analysis, log gap detection |
28| Credential Access | LSASS Memory, OS Credential Dumping | LSASS access patterns, dump file creation |
29| Discovery | Network Share Discovery, System Info Discovery | Net commands, systeminfo execution |
30| Lateral Movement | SMB/Windows Admin Shares, WMI | SMB connection patterns, remote WMI calls |
31| Collection | Data Staged, Archive Collected Data | Unusual archive operations, staging directories |
32| Exfiltration | Exfiltration Over C2, DNS | DNS query volume anomalies, C2 beacon patterns |
33
34## Log Analysis & Correlation
35
36### Key Event Sources
37```
38# Windows (Sysmon)
39Event ID 1: Process creation
40Event ID 3: Network connection
41Event ID 7: Image loaded
42Event ID 11: File creation
43Event ID 12: Registry object added/modified
44Event ID 13: Registry value set
45Event ID 15: File creation stream hash
46Event ID 17: Pipe created
47Event ID 22: DNS query
48Event ID 25: Process tampering
49
50# Linux (auditd)
51type=EXECVE: Command execution
52type=CONNECT: Network connections
53type=PATH: File access
54type=SYSCALL: System calls (esp. ptrace, execve)
55
56# Network (Zeek/Suricata)
57DNS queries and responses
58HTTP requests and responses
59SSL/TLS certificate analysis
60File extraction and hashing
61```
62
63### Correlation Queries
64```sql
65-- Splunk: PowerShell encoded command
66index=security EventCode=4688
67| where match(Process_Command_Line, "powershell.*-enc")
68| stats count by Computer, User, _time
69| where count > 3
70
71-- Splunk: Lateral movement via PsExec
72index=security EventCode=7045 Service_Name="PSEXESVC"
73| stats count by Computer, User
74| where count > 1
75
76-- Sigma equivalent
77detection:
78 selection:
79 EventID: 4688
80 CommandLine|contains|all:
81 - 'powershell'
82 - '-enc'
83 - '-encodedcommand'
84 condition: selection
85```
86
87## Behavioral Anomaly Detection
88
89### Baselines
90```
91# Normal user behavior:
92- Login times and duration
93- Common processes and commands
94- Network destinations and volumes
95- File access patterns
96
97# Anomaly indicators:
98- Processes running at unusual hours
99- New network destinations (never before seen)
100- Sudden increase in data access volume
101- Commands that deviate from user's normal pattern
102- Service installations on workstations
103```
104
105### Hunting Hypotheses
106```
107# Generate and test hunting hypotheses:
1081. "If there's credential dumping, we'll see Mimikatz or similar tool execution"
1092. "If lateral movement occurs, we'll see new admin share connections"
1103. "If data exfiltration happens, we'll see unusual outbound DNS or HTTPS traffic"
1114. "If there's persistence, we'll see new scheduled tasks or registry modifications"
112
113# Validate with:
114- Historical log analysis (last 30-90 days)
115- Endpoint telemetry (processes, network, files)
116- Network flow data (NetFlow, PCAP)
117- Cloud audit logs (CloudTrail, Azure Activity Log)
118```
119
120## Detection Rule Development
121
122### Sigma Rule Template
123```yaml
124title: Suspicious PowerShell Execution
125id: rule-uuid-here
126status: experimental
127description: Detects PowerShell execution with encoded commands and download cradles
128references:
129 - https://attack.mitre.org/techniques/T1059/001/
130author: analyst
131date: 2026/05/19
132logsource:
133 category: process_creation
134 product: windows
135detection:
136 selection:
137 Image|endswith: '\powershell.exe'
138 encoded:
139 CommandLine|contains:
140 - '-enc'
141 - '-encodedcommand'
142 download:
143 CommandLine|contains:
144 - 'DownloadString'
145 - 'DownloadFile'
146 - 'IEX'
147 - 'Invoke-Expression'
148 condition: selection and (encoded or download)
149falsepositives:
150 - Legitimate IT automation scripts
151 - Software deployment tools
152level: high
153tags:
154 - attack.execution
155 - attack.t1059.001
156```
157
158### YARA Network Detection
159```yara
160rule C2_Beacon_Pattern {
161 meta:
162 description = "Detects C2 beacon traffic patterns"
163 strings:
164 $beacon_http = /POST \/gate\.php HTTP\/1\.1\r\nHost: [^\r\n]+\r\nUser-Agent: Mozilla\/[\d.]+/
165 $beacon_dns = /[a-z0-9]{32,}\.attacker-domain\.(com|net|org)/
166 condition:
167 $beacon_http or $beacon_dns
168}
169```