mcpField
P
performing-threat-hunting-with-elastic-siem

performing-threat-hunting-with-elastic-siem

github.com/mukul975安全35.2k67 次安装8 周前更新
代码仓库

关于 performing-threat-hunting-with-elastic-siem

面向 SOC 团队的 Elastic SIEM 威胁狩猎流程技能,指导基于假设查询历史遥测、调查事件并将发现转化为检测规则。

主要功能

  1. 01制定基于假设的狩猎计划
  2. 02使用 KQL 查询遥测
  3. 03用 EQL 检测事件序列
  4. 04在 Timeline 协作调查
  5. 05将发现转为检测规则
  6. 06汇总结果并记录报告

适用场景

  1. 01验证威胁情报中的 TTP
  2. 02排查 LOLBin 滥用与横向移动
  3. 03分析事件序列并定位主机
  4. 04将狩猎结果纳入检测覆盖

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-threat-hunting-with-elastic-siem

安装后在 Claude Code 中输入/performing-threat-hunting-with-elastic-siem确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
api-reference.md
scripts/
agent.py

详细介绍

使用 Elastic SIEM 进行威胁狩猎

适用场景

在以下情况下使用此技能:

  • SOC 团队需要主动搜索现有检测规则未发现的威胁
  • 威胁情报报告描述了需要通过历史数据验证的新 TTP
  • 红队演练发现了需要开发狩猎查询来弥补的检测盲区
  • 定期狩猎需要开展结构化、基于假设的调查

请勿用于实时告警分诊——这应在 Elastic Security 的 Alerts 队列中通过自动检测规则处理。

前提条件

  • 已启用 Kibana 中 Security 应用的 Elastic Security 8.x+
  • 通过 Elastic Agent(Endpoint Security 集成)或 Beats(Winlogbeat、Filebeat、Packetbeat)摄取数据
  • 数据已规范化为 Elastic Common Schema(ECS)字段映射
  • 用户角色具有 kibana_security_solution,并且对相关索引具有 read 访问权限
  • 具备用于生成假设的 MITRE ATT&CK 框架知识

工作流

第 1 步:制定狩猎假设

根据威胁情报、ATT&CK 技术或异常情况提出假设:

假设示例:“攻击者正在使用就地取材二进制文件(LOLBins)执行操作,具体来说是使用 certutil.exe 下载文件(T1105 — Ingress Tool Transfer)。”

定义范围:

  • 数据源:logs-endpoint.events.process-*、logs-windows.sysmon_operational-*
  • 时间范围:过去 30 天
  • 预期指标:带有 -urlcache、-split 或 -decode 标志的 certutil.exe
第 2 步:在 Discover 中使用 KQL 狩猎

打开 Kibana Discover,使用 KQL(Kibana Query Language)查询:

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 Event Query Language(EQL)支持狩猎多步骤攻击序列:

检测父子进程异常(T1055 — Process Injection):

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 调查,以开展协作分析:

  1. 导航至 Security > Timelines > Create new timeline
  2. 使用 Discover 中的“Add to timeline”将狩猎查询中的事件添加到 Timeline
  3. 固定关键事件并添加调查备注
  4. 使用 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 Download Activity",
  "description": "Detects certutil.exe used for file download, a common LOLBin technique",
  "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 部署:

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},
      "aggs": {
        "by_user": {
          "terms": {"field": "user.name", "size": 10}
        },
        "by_args": {
          "terms": {"field": "process.args", "size": 10}
        }
      }
    }
  }
}
第 7 步:记录狩猎并完成闭环

在结构化的狩猎报告中记录发现,并更新检测覆盖情况:

  • 假设已验证或证伪
  • 发现的 IOC 和受影响主机
  • 已创建或更新的检测规则
  • 已使用新增的覆盖内容更新 ATT&CK Navigator 层
  • 关于改进安全控制的建议

关键概念

术语定义
KQLKibana Query Language — 用于在 Kibana Discover 和仪表板中筛选数据的简化查询语法
EQLEvent Query Language — Elastic 的时序感知查询语言,用于检测多步骤攻击模式
ECSElastic Common Schema — 标准化字段命名规范,支持跨数据源关联
TimelineElastic Security 调查工作区,用于协作分析和注释事件
基于假设的狩猎从攻击者行为理论出发,并通过遥测数据进行验证的结构化方法
LOLBinsLiving 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
  • 持久化机制:查询计划任务创建、注册表运行键修改、WMI 订阅
  • C2 信标通信:分析网络流量数据,查找以固定间隔定期进行的出站连接
  • 数据暂存:搜寻大型文件压缩(7z、rar、zip)后发生的出站传输
  • 账户操纵:搜索由非管理员用户执行的 net.exe 用户创建、组成员身份变更或密码重置

输出格式

THREAT HUNT REPORT — TH-2024-012
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Hypothesis:   Attackers using certutil.exe for tool download (T1105)
Period:       2024-02-15 to 2024-03-15
Data Sources: Elastic Endpoint (process events), Sysmon

Findings:
  Total certutil executions:     342
  With -urlcache flag:           12 (3.5%)
  Suspicious (non-SCCM):        3 confirmed anomalous

Affected Hosts:
  WORKSTATION-042 (Finance)  — certutil downloading payload.exe from external IP
  SERVER-DB-03 (Database)    — certutil decoding base64 encoded binary
  LAPTOP-EXEC-07 (Executive) — certutil downloading script from Pastebin

Actions Taken:
  [DONE] 3 hosts isolated for forensic investigation
  [DONE] Detection rule "Certutil Download Activity" deployed (ID: elastic-th012)
  [DONE] ATT&CK Navigator updated: T1105 coverage = GREEN

Verdict:      HYPOTHESIS CONFIRMED — 3 true positive findings escalated to IR

评论

支持 Markdown