v3153/sentinel-detection-engineering

GitHub: v3153/sentinel-detection-engineering

面向生产级 SOC 环境的 Microsoft Sentinel 检测工程项目,涵盖从威胁建模、KQL 规则开发、误报调优到调查 playbook 的完整检测生命周期。

Stars: 0 | Forks: 0

# Sentinel 检测工程 [![Microsoft Sentinel](https://img.shields.io/badge/Microsoft%20Sentinel-0078D4?logo=microsoft-azure&logoColor=white)](https://azure.microsoft.com/products/microsoft-sentinel) [![KQL](https://img.shields.io/badge/KQL-Analytics%20Rules-0078D4)](detections/) [![MITRE ATT&CK](https://img.shields.io/badge/MITRE%20ATT%26CK-12%20Techniques-red)](attack-mappings/) [![Detections](https://img.shields.io/badge/Scheduled%20Detections-9-blue)](detections/) [![Hunting](https://img.shields.io/badge/Hunting%20Queries-5-green)](hunting-queries/) [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) ## 关于 本仓库记录了**来自生产级 SOC 环境的检测工程工作** —— 这不是一个查询语句的堆砌,而是一个结构化的作品集,展示了检测是如何进行端到端设计、部署、调优和调查的。 它展示了完整检测生命周期内的各项能力: | 阶段 | 本仓库中的产出物 | |-------|------------------------| | 威胁建模 | MITRE ATT&CK 技术映射、假设文档 | | 规则开发 | 具有可调 `let` 变量的计划内 KQL 分析规则 | | 验证 | 紫队参考、误报分析、性能目标 | | 生产调优 | 包含告警量指标和阈值变更的检测报告 | | 调查 | 包含追溯查询和升级标准的 incident playbook | | 可移植性 | 用于跨 SIEM 转换的 Sigma 规则 | **涵盖技能:** 假设驱动的检测设计 · KQL 查询优化 · MITRE ATT&CK 映射 · 误报分析 · 检测调优 · 威胁狩猎 · Sigma 规则编写 · SOC 调查工作流设计 检测工程分析文章:[Medium](https://medium.com/@patelvidhi4288) ## 推荐检测 — 编码的 PowerShell 执行 一个完整的检测套件,展示了端到端的检测工程 —— 从假设到生产调优。 | 属性 | 详情 | |-----------|--------| | **MITRE ATT&CK** | [T1059.001 — PowerShell](https://attack.mitre.org/techniques/T1059/001/) (执行) | | **数据源** | `DeviceProcessEvents` (Microsoft Defender for Endpoint → Sentinel) | | **严重性** | 中 (在 AlertScore ≥ 5 时动态升级) | | **检测方法** | 带有父进程风险评分的多指标编码检测 | **为什么选择此检测:** Base64 编码的 PowerShell 是生产端点遥测中最常见的混淆技术之一。此规则专门针对编码行为 —— `-EncodedCommand`、内联 `FromBase64String`、Unicode 解码以及 DeflateStream stager —— 同时对父进程上下文(Office 应用程序、LOLBins)进行评分,以优先处理钓鱼软件和宏投放链,而非良性的管理脚本。 **生产成果**(28 天调优期): - 经过三次调优迭代,告警量从 **52次/天 → 8次/天** 降低 - **100%** 保留了紫队演练和已确认 incident 的检测率 - 捕获了真实的钓鱼投递宏 → 编码的下载 cradle (AlertScore 6) **完整套件:** | 产出物 | 描述 | |----------|-------------| | [检测规范 + KQL](detections/endpoint/encoded-powershell-detection.md) | 假设、逻辑、可部署的查询、误报 (FP) 指南 | | [Sigma 规则](sigma-rules/endpoint/encoded-powershell.yml) | 供应商无关的 process_creation 规则 | | [MITRE 映射](attack-mappings/T1059.001.md) | 覆盖率评估和差距分析 | | [调查 playbook](incident-playbooks/encoded-powershell-investigation.md) | 带有追溯查询的三阶段分诊工作流 | | [调优报告](detection-reports/encoded-powershell-tuning.md) | 生产指标、误报 (FP) 根本原因、变更日志 | 对于评估本仓库检测工程深度的审阅者来说,这是推荐的起点。 ## Microsoft Sentinel 专业能力 本仓库中的检测是为**生产级 Sentinel 部署**而构建的,而非临时的日志搜索。 | 能力 | 展示方式 | |------------|------------------------| | **计划内分析规则** | 9 条生产级 KQL 规则,包含标准文件头块、严重性和实体映射 | | **KQL 最佳实践** | 时间限定查询、基于 `let` 的调优变量、选择性投影、风险评分 | | **MDE 集成** | 针对 `DeviceProcessEvents`、`DeviceNetworkEvents` 及相关 MDE 表的规则 | | **身份遥测** | `SigninLogs`、Entra ID 登录异常模式 | | **网络分析** | DNS 熵、VPN 相关性、威胁情报扩充 | | **运营就绪度** | 误报文档、白名单模式、查询运行时间目标 (< 30s) | **部署路径:** 每个 `.kql` 文件都可以直接粘贴到 **Sentinel → Analytics → Scheduled query rule** 中。狩猎查询通过 **Sentinel → Hunting → New Query** 进行部署。 ## 检测覆盖率 规则按攻击领域组织,并映射到 MITRE ATT&CK 技术。 ### 身份与访问 | 规则 | MITRE | 严重性 | 描述 | |------|-------|----------|-------------| | [不可能的旅行](detections/identity/impossible-travel.kql) | T1078 | 高 | 来自地理上不可能位置的登录 | | [密码喷射](detections/identity/password-spray.kql) | T1110.003 | 高 | 针对大量账户的低速密码喷射 | ### 端点 | 规则 | MITRE | 严重性 | 描述 | |------|-------|----------|-------------| | [编码的 PowerShell 执行](detections/endpoint/encoded-powershell-detection.md) | T1059.001 | 中 | Base64 编码的命令、内联解码、DeflateStream stager | | [可疑的 PowerShell](detections/endpoint/suspicious-powershell.kql) | T1059.001 | 中 | 复合风险评分 —— IEX、AMSI 绕过、下载 cradle | ### 云 | 规则 | MITRE | 严重性 | 描述 | |------|-------|----------|-------------| | [异常的 Azure 登录](detections/cloud/anomalous-azure-signin.kql) | T1078.004 | 高 | 新国家/地区的登录和旧版身份验证 (MFA 绕过) | ### 网络 | 规则 | MITRE | 严重性 | 描述 | |------|-------|----------|-------------| | [DNS 隧道传输](detections/network/dns-tunneling.kql) | T1048.003 | 中 | 高熵子域和异常的查询量 | | [VPN 内部扫描](detections/network/vpn-internal-scanning.kql) | T1046 | 高 | 经过 VPN 身份验证的源扫描内部主机/端口 | | [TOR 节点通信](detections/network/tor-node-communication.kql) | T1090.003 | 高 | 允许与活跃 TOR 出口和中继节点的流量 | ### 横向移动 | 规则 | MITRE | 严重性 | 描述 | |------|-------|----------|-------------| | [PsExec 检测](detections/lateral-movement/psexec-detection.kql) | T1569.002 | 高 | PSEXESVC 服务创建和远程执行 | 完整目录:[detections/](detections/) ## 威胁狩猎 用于主动发现威胁的、假设驱动的 KQL 查询。狩猎查询在升级为计划内检测之前用于验证假设。 | 查询 | 领域 | MITRE | 描述 | |-------|--------|-------|-------------| | [SMB 共享高频访问](hunting-queries/endpoint/smb-share-high-frequency.kql) | 端点 | T1021.002 | 异常的 SMB 共享访问 —— 勒索软件或数据暂存 | | [卷影副本与恢复操纵](hunting-queries/endpoint/shadow-copy-manipulation.kql) | 端点 | T1490 | VSS 删除和启动恢复篡改 | | [URL 中的高风险 Base64 命令](hunting-queries/network/risky-base64-in-url.kql) | 网络 | T1071 | Web 请求中 Base64 编码的操作系统命令 | | [新的目标 IP](hunting-queries/network/new-destination-ip.kql) | 网络 | T1071, TA0043 | 指向不在 30 天基线内 IP 的出站连接 | | [URL 中 Base64 编码的 IPv4](hunting-queries/network/base64-encoded-ipv4-in-url.kql) | 网络 | T1071 | 请求 URL 中被混淆的 C2 IP | 完整目录:[hunting-queries/](hunting-queries/) ## MITRE ATT&CK 覆盖率 检测和狩猎查询映射跨越 **9 个战术** 和 **12 个技术**,使用核心资产 + kill chain 模型(初始访问 → 凭据访问 → 横向移动 → 数据窃取)进行优先级排序。 | 战术 | 技术 | 检测 | 狩猎 | |--------|------------|------------|---------| | 侦察 | TA0043 | — | 1 | | 初始访问 | T1078, T1078.004 | 2 | — | | 执行 | T1059.001 | 2 | — | | 发现 | T1046 | 1 | — | | 横向移动 | T1021.002, T1569.002 | 1 | 1 | | 凭据访问 | T1110.003 | 1 | — | | 命令与控制 | T1071, T1090.003 | 1 | 3 | | 数据窃取 | T1048.003 | 1 | — | | 影响 | T1490 | — | 1 | 包含差距分析的技术级覆盖文档:[attack-mappings/](attack-mappings/) · [T1059.001 — PowerShell](attack-mappings/T1059.001.md) ## 检测工程产出物 除了查询之外,本仓库还包含将检测工程与普通规则编写区分开来的运营产出物。 | 产出物 | 位置 | 目的 | |----------|----------|---------| | 检测方法论 | [docs/detection-methodology.md](docs/detection-methodology.md) | 生命周期、KQL 标准、严重性分类 | | 命名约定 | [docs/naming-convention.md](docs/naming-convention.md) | 文件命名、KQL 文件头、提交格式 | | 模板 | [docs/templates/](docs/templates/) | 检测、Sigma、playbook 和映射模板 | | Incident playbook | [incident-playbooks/](incident-playbooks/) | 分析师分诊和升级工作流 | | 检测报告 | [detection-reports/](detection-reports/) | 调优历史、误报 (FP) 分析、生产指标 | | Sigma 规则 | [sigma-rules/](sigma-rules/) | 用于跨平台使用的可移植检测逻辑 | ## 仓库结构 ``` sentinel-detection-engineering/ ├── detections/ # Scheduled Sentinel analytics rules (KQL) ├── hunting-queries/ # Proactive threat hunting queries (KQL) ├── sigma-rules/ # Vendor-agnostic Sigma rules (YAML) ├── attack-mappings/ # MITRE ATT&CK technique coverage maps ├── incident-playbooks/ # Alert triage and investigation runbooks ├── detection-reports/ # Tuning notes, gap analyses, post-mortems └── docs/ # Methodology, standards, and templates ``` 完整布局:[docs/repository-structure.md](docs/repository-structure.md) ## 快速入门 ### 部署检测 1. 在 [detections/](detections/) 中打开一个 `.kql` 文件(或 `.md` 检测规范中的 KQL) 2. 粘贴到 **Microsoft Sentinel → Analytics → Scheduled query rule** 中 3. 映射实体(Account、Host、IP)并调整 `let` 调优变量 ### 运行狩猎 1. 在 [hunting-queries/](hunting-queries/) 中打开一个 `.kql` 文件 2. 通过 **Microsoft Sentinel → Hunting → New Query** 执行 ### 审查检测工程深度 从 [推荐检测](#featured-detection--encoded-powershell-execution) 套件开始,然后探索 [检测方法论](docs/detection-methodology.md) 和 [调优报告](detection-reports/)。 ## 路线图 | 优先级 | 项目 | 状态 | |----------|------|--------| | 高 | 所有覆盖技术的 MITRE 技术映射文件 | 进行中(T1059.001 已完成) | | 高 | 前 5 名检测的 Incident playbook | 进行中(编码的 PowerShell 已完成) | | 中 | 其余 KQL 检测的 Sigma 规则转换 | 进行中 | | 中 | 身份和云端狩猎查询 | 计划中 | | 中 | 第二季度检测覆盖率差距分析报告 | 计划中 | | 低 | ATT&CK Navigator 层导出 | 计划中 | ## 许可证 MIT — 可自由使用、改写和在此基础上进行构建。感谢保留署名。 *检测规则和文档在生产级 SOC 环境中开发。在 [LinkedIn](https://linkedin.com) 上联系 · 在 [Medium](https://medium.com/@patelvidhi4288) 上阅读检测分析文章*
标签:DNS 反向解析, IP 地址批量处理, KQL, Microsoft Sentinel, Sigma规则, 安全运营, 扫描框架, 目标导入, 知识库安全