| name | performing-threat-hunting-with-elastic-siem |
| description | 使用 KQL/EQL 查询、检测规则和 Timeline 调查在 Elastic Security SIEM 中执行主动威胁狩猎, 识别绕过自动检测的威胁。适用于 SOC 团队针对特定 ATT&CK 技术进行狩猎、调查异常行为, 或使用 Elasticsearch 和 Kibana Security 验证检测覆盖缺口。
|
| domain | cybersecurity |
| subdomain | soc-operations |
| tags | ["soc","elastic","siem","threat-hunting","kql","eql","mitre-attack","kibana"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
使用 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 查询语言)进行查询:
process.name: "certutil.exe" and process.args: ("-urlcache" or "-split" or "-decode" or "-encode" or "-verifyctl")
排除已知合法用途进行精炼:
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):
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 — 进程注入):
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):
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):
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 调查以进行协作分析:
- 导航至 Security > Timelines > 创建新 timeline
- 通过 Discover 中的"添加到 timeline"添加狩猎查询的事件
- 固定关键事件并添加调查注释
- 使用 Timeline 查询栏进行额外过滤:
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 检测规则:
{
"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"
通过 Elastic Security API 部署:
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:聚合并可视化发现结果
使用聚合创建狩猎仪表板:
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},
步骤 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