performing-threat-hunting-with-elastic-siem
使用 KQL/EQL 查询、检测规则和 Timeline 调查在 Elastic Security SIEM 中执行主动威胁狩猎, 识别绕过自动检测的威胁。适用于 SOC 团队针对特定 ATT&CK 技术进行狩猎、调查异常行为, 或使用 Elasticsearch 和 Kibana Security 验证检测覆盖缺口。
Best use case
performing-threat-hunting-with-elastic-siem is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
使用 KQL/EQL 查询、检测规则和 Timeline 调查在 Elastic Security SIEM 中执行主动威胁狩猎, 识别绕过自动检测的威胁。适用于 SOC 团队针对特定 ATT&CK 技术进行狩猎、调查异常行为, 或使用 Elasticsearch 和 Kibana Security 验证检测覆盖缺口。
Teams using performing-threat-hunting-with-elastic-siem should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/performing-threat-hunting-with-elastic-siem/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How performing-threat-hunting-with-elastic-siem Compares
| Feature / Agent | performing-threat-hunting-with-elastic-siem | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
使用 KQL/EQL 查询、检测规则和 Timeline 调查在 Elastic Security SIEM 中执行主动威胁狩猎, 识别绕过自动检测的威胁。适用于 SOC 团队针对特定 ATT&CK 技术进行狩猎、调查异常行为, 或使用 Elasticsearch 和 Kibana Security 验证检测覆盖缺口。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 使用 Elastic SIEM 执行威胁狩猎
## 适用场景
以下情况使用本技能:
- SOC 团队需要主动搜索未被现有检测规则捕获的威胁
- 威胁情报报告描述了需要针对历史数据进行验证的新 TTP
- 红队演练发现了需要开发狩猎查询的检测缺口
- 定期狩猎节奏需要结构化的假设驱动调查
**不适用于**实时告警分类——该场景应使用 Elastic Security 告警队列配合自动检测规则。
## 前置条件
- Elastic Security 8.x+ 并在 Kibana 中启用 Security 应用
- 通过 Elastic Agent(端点安全集成)或 Beats(Winlogbeat、Filebeat、Packetbeat)摄取数据
- 数据规范化为 Elastic Common Schema(ECS)字段映射
- 用户角色具有 `kibana_security_solution` 和相关索引的 `read` 访问权限
- 具备 MITRE ATT&CK 框架知识,用于生成假设
## 工作流程
### 步骤 1:制定狩猎假设
基于威胁情报、ATT&CK 技术或异常现象制定假设:
**假设示例**:"攻击者正在使用离地攻击(LOLBins)执行操作,具体是使用 certutil.exe 进行文件下载(T1105 — 工具传输入侵)。"
定义范围:
- **数据源**:`logs-endpoint.events.process-*`、`logs-windows.sysmon_operational-*`
- **时间范围**:最近 30 天
- **预期指标**:带有 `-urlcache`、`-split` 或 `-decode` 标志的 certutil.exe
### 步骤 2:在 Discover 中使用 KQL 进行狩猎
打开 Kibana Discover 并使用 KQL(Kibana 查询语言)进行查询:
```kql
process.name: "certutil.exe" and process.args: ("-urlcache" or "-split" or "-decode" or "-encode" or "-verifyctl")
```
排除已知合法用途进行精炼:
```kql
process.name: "certutil.exe"
and process.args: ("-urlcache" or "-split" or "-decode")
and not process.parent.name: ("sccm*.exe" or "ccmexec.exe")
and not user.name: "SYSTEM"
```
使用编码命令进行 PowerShell 狩猎(T1059.001):
```kql
process.name: "powershell.exe"
and process.args: ("-enc" or "-encodedcommand" or "-e " or "frombase64string" or "iex" or "invoke-expression")
and not process.parent.executable: "C:\\Windows\\System32\\svchost.exe"
```
### 步骤 3:使用 EQL 进行序列检测
Elastic 事件查询语言(EQL)支持狩猎多步骤攻击序列:
**检测父子进程异常(T1055 — 进程注入):**
```eql
sequence by host.name with maxspan=5m
[process where event.type == "start" and process.name == "explorer.exe"]
[process where event.type == "start" and process.parent.name == "explorer.exe"
and process.name in ("cmd.exe", "powershell.exe", "rundll32.exe", "regsvr32.exe")]
```
**检测凭据转储序列(T1003):**
```eql
sequence by host.name with maxspan=2m
[process where event.type == "start"
and process.name in ("procdump.exe", "procdump64.exe", "rundll32.exe", "taskmgr.exe")
and process.args : "*lsass*"]
[file where event.type == "creation"
and file.extension in ("dmp", "dump", "bin")]
```
**检测通过 PsExec 进行横向移动(T1021.002):**
```eql
sequence by source.ip with maxspan=1m
[authentication where event.outcome == "success" and winlog.logon.type == "Network"]
[process where event.type == "start"
and process.name == "psexesvc.exe"]
```
### 步骤 4:使用 Elastic Security Timeline 进行调查
在 Elastic Security 中创建 Timeline 调查以进行协作分析:
1. 导航至 **Security > Timelines > 创建新 timeline**
2. 通过 Discover 中的"添加到 timeline"添加狩猎查询的事件
3. 固定关键事件并添加调查注释
4. 使用 Timeline 查询栏进行额外过滤:
```kql
host.name: "WORKSTATION-042" and event.category: ("process" or "network" or "file")
```
添加关键字段列:`@timestamp`、`event.action`、`process.name`、`process.args`、`user.name`、`source.ip`、`destination.ip`
### 步骤 5:从发现结果构建检测规则
将成功的狩猎查询转换为 Elastic 检测规则:
```json
{
"name": "Certutil 下载活动",
"description": "检测用于文件下载的 certutil.exe,一种常见的 LOLBin 技术",
"risk_score": 73,
"severity": "high",
"type": "eql",
"query": "process where event.type == \"start\" and process.name == \"certutil.exe\" and process.args : (\"-urlcache\", \"-split\", \"-decode\") and not process.parent.name : (\"ccmexec.exe\", \"sccm*.exe\")",
"threat": [
{
"framework": "MITRE ATT&CK",
"tactic": {
"id": "TA0011",
"name": "Command and Control"
},
"technique": [
{
"id": "T1105",
"name": "Ingress Tool Transfer"
}
]
}
],
"tags": ["Hunting", "LOLBins", "T1105"],
"interval": "5m",
"from": "now-6m",
"enabled": true
}
```
通过 Elastic Security API 部署:
```bash
curl -X POST "https://kibana:5601/api/detection_engine/rules" \
-H "kbn-xsrf: true" \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey YOUR_API_KEY" \
-d @certutil_rule.json
```
### 步骤 6:聚合并可视化发现结果
使用聚合创建狩猎仪表板:
```json
GET logs-endpoint.events.process-*/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{"term": {"process.name": "certutil.exe"}},
{"range": {"@timestamp": {"gte": "now-30d"}}}
]
}
},
"aggs": {
"by_host": {
"terms": {"field": "host.name", "size": 20},
"aggs": {
"by_user": {
"terms": {"field": "user.name", "size": 10}
},
"by_args": {
"terms": {"field": "process.args", "size": 10}
}
}
}
}
}
```
### 步骤 7:记录狩猎结果并闭环
在结构化狩猎报告中记录发现结果并更新检测覆盖率:
- 假设已验证或已驳斥
- 发现的 IOC 和受影响主机
- 已创建或更新的检测规则
- ATT&CK Navigator 层已更新为新覆盖范围
- 安全控制改进建议
## 核心概念
| 术语 | 定义 |
|------|-----------|
| **KQL** | Kibana 查询语言——用于在 Kibana Discover 和仪表板中过滤数据的简化查询语法 |
| **EQL** | 事件查询语言——Elastic 的序列感知查询语言,用于检测多步骤攻击模式 |
| **ECS** | Elastic 通用模式——标准化字段命名规范,支持跨数据源关联 |
| **Timeline** | Elastic Security 调查工作区,用于协作事件分析和注释 |
| **假设驱动狩猎** | 从攻击者行为理论出发,针对遥测数据进行测试的结构化方法 |
| **LOLBins** | 离地二进制(Living Off the Land Binaries)——被攻击者滥用的合法 Windows 工具(certutil、mshta、rundll32) |
## 工具与系统
- **Elastic Security**:基于 Elasticsearch 构建的 SIEM 平台,具有检测规则、Timeline 和案例管理功能
- **Elastic Agent**:统一数据采集 Agent,替代 Beats 用于端点和网络遥测
- **Elastic Endpoint Security**:集成到 Elastic Agent 的 EDR 功能,用于进程、文件和网络监控
- **ATT&CK Navigator**:MITRE 工具,用于跟踪 ATT&CK 矩阵中的检测和狩猎覆盖率
## 常见场景
- **LOLBin 滥用**:狩猎带有可疑参数的 mshta.exe、regsvr32.exe、rundll32.exe、certutil.exe
- **持久化机制**:查询计划任务创建、注册表 Run 键修改、WMI 订阅
- **C2 信标**:分析网络流数据,寻找间隔一致的周期性出站连接
- **数据暂存**:狩猎大文件压缩(7z、rar、zip)后跟随出站传输的模式
- **账户操控**:搜索非管理员用户执行的 net.exe 创建用户、组成员变更或密码重置
## 输出格式
```
威胁狩猎报告 — TH-2024-012
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
假设: 攻击者使用 certutil.exe 进行工具下载(T1105)
时间段: 2024-02-15 至 2024-03-15
数据源: Elastic Endpoint(进程事件)、Sysmon
发现结果:
certutil 执行总次数: 342
带 -urlcache 标志: 12(3.5%)
可疑(非 SCCM): 3 个已确认异常
受影响主机:
WORKSTATION-042(财务) — certutil 从外部 IP 下载 payload.exe
SERVER-DB-03(数据库) — certutil 解码 base64 编码二进制文件
LAPTOP-EXEC-07(高管) — certutil 从 Pastebin 下载脚本
已采取行动:
[完成] 3 台主机已隔离进行取证调查
[完成] 检测规则"Certutil 下载活动"已部署(ID: elastic-th012)
[完成] ATT&CK Navigator 已更新:T1105 覆盖率 = 绿色
结论: 假设已确认——3 个真阳性发现已上报 IR
```Related Skills
tracking-threat-actor-infrastructure
威胁行为者基础设施追踪涉及使用被动 DNS、证书透明度日志、Shodan/Censys 扫描、WHOIS 分析和网络指纹技术,对对手控制的 C2 服务器、钓鱼域名和暂存服务器等资产进行监控、映射和持续追踪
profiling-threat-actor-groups
通过聚合 TTP 文档、历史活动数据、工具指纹和来自多个情报源的归因指标,为 APT 组织、犯罪组织和黑客活动组织开发全面的威胁行为者画像。适用于就行业特定威胁向管理层汇报、更新威胁模型假设,或针对特定对手优先部署防御控制措施。当涉及 MITRE ATT&CK 组织、Mandiant APT 画像、CrowdStrike 对手命名或行业特定威胁简报时激活。
performing-yara-rule-development-for-detection
通过识别可执行文件中的唯一字节模式、字符串和行为指标,开发精准的 YARA 恶意软件检测规则,同时将误报率降至最低。
performing-wireless-security-assessment-with-kismet
使用 Kismet 通过被动射频监控进行无线网络安全评估,检测流氓接入点(Rogue AP)、隐藏 SSID、弱加密和未授权客户端。
performing-wireless-network-penetration-test
执行无线网络渗透测试,通过捕获握手包、破解 WPA2/WPA3 密钥、检测流氓接入点以及使用 Aircrack-ng 和相关工具测试无线网络分段,评估 WiFi 安全性。
performing-windows-artifact-analysis-with-eric-zimmerman-tools
使用 Eric Zimmerman 的开源 EZ Tools 套件(包括 KAPE、MFTECmd、PECmd、LECmd、JLECmd 和 Timeline Explorer)执行全面的 Windows 取证制品分析,解析注册表 hive、预取文件、事件日志和文件系统元数据。
performing-wifi-password-cracking-with-aircrack
在授权无线安全评估中捕获 WPA/WPA2 握手包,并使用 aircrack-ng、hashcat 和字典攻击进行离线密码破解, 以评估密码短语强度和无线网络安全状况。
performing-web-cache-poisoning-attack
在授权安全测试期间,通过未纳入缓存键的头部和参数毒化缓存响应,利用 Web 缓存机制向其他用户投递恶意内容。
performing-web-cache-deception-attack
通过利用 CDN 缓存层与源服务器之间的路径规范化差异,执行 Web 缓存欺骗攻击,从而缓存并获取敏感的已认证内容。
performing-web-application-vulnerability-triage
使用 OWASP 风险评级方法论对 DAST/SAST 扫描器的 Web 应用程序漏洞发现进行分类,区分真阳性和假阳性,并确定修复优先级。
performing-web-application-scanning-with-nikto
Nikto 是一款开源 Web 服务器和 Web 应用程序扫描器,可针对超过 7,000 个潜在危险文件/程序进行测试,检查超过 1,250 个服务器的过期版本,并识别超过 270 个服务器的版本特定问题。
performing-web-application-penetration-test
遵循 OWASP Web 安全测试指南(WSTG)方法论,对 Web 应用程序执行系统化安全测试,识别认证、授权、 输入验证、会话管理和业务逻辑中的漏洞。测试人员以 Burp Suite 作为主要拦截代理,结合手动测试技术 发现自动化扫描器遗漏的缺陷。适用于 Web 应用渗透测试、OWASP 测试、应用安全评估或 Web 漏洞测试等请求场景。