rudraverma/Claude-KQL-Skills

GitHub: rudraverma/Claude-KQL-Skills

一套 Claude Code 技能包,将 AI 转化为 Microsoft Sentinel 和 Defender XDR 的 KQL 检测规则专家,自动编写经过架构验证、MITRE 映射并可部署的分析规则。

Stars: 0 | Forks: 0

CyberHawk Threat Intel

Claude KQL Detections Skill

作者:CyberHawk Threat Intel · Rudra Verma | 高级网络安全架构师

## 概述 **Claude KQL Detections Skill** 将 Claude Code 变身为专为 **Microsoft Sentinel** 和 **Microsoft Defender XDR** 服务的专家级 KQL 检测工程师。它编写可直接用于生产环境的检测规则,包含经过验证的表结构、正确的列名、MITRE ATT&CK 映射、实体映射以及完整的 YAML 分析规则输出 —— 随时可部署到您的 SIEM。 ## 此 Skill 的功能 - 为 **Sentinel 计划分析规则**、**NRT 规则**和 **Defender XDR 自定义检测**编写 KQL 查询 - 在编写前验证表结构 —— 绝不猜测列名 - 将每个检测映射到 **MITRE ATT&CK** 的战术和技术 - 输出纯 KQL(用于测试)和**完整的 YAML**(用于部署) - 包含 Sentinel 事件创建所需的实体映射 - 提供调试说明和建议的 SOC 响应操作 - 涵盖身份、端点、电子邮件和云端的 **20 多种预验证检测模式** ## 覆盖范围 ### 检测场景 | 类别 | 示例 | |---|---| | 身份 | 匿名登录、暴力破解、密码喷洒、不可能的旅行、MFA 疲劳攻击 | | 权限 | 角色分配、管理员同意授予、非工作时间 PIM 激活 | | 持久化 | OAuth 应用被授予高权限范围、服务主体创建 | | 端点 | 可疑的 PowerShell、无文件攻击 (LotL)、横向移动 | | 电子邮件 | 网络钓鱼投递、转发规则创建、收件箱规则滥用 | | 云 | SharePoint 大量下载、Azure 资源删除、新的租户联合 | | 网络 | Tor 出口节点登录、陌生国家/地区访问、不可能的 ASN 跳转 | | 勒索软件 | 大规模文件加密信号、影子副本删除、VSS 滥用 | ### 平台 | 平台 | 表 | 规则类型 | |---|---|---| | Microsoft Sentinel | SigninLogs, AuditLogs, OfficeActivity, AzureActivity, SecurityEvent, Syslog 及其他 30 多个 | Scheduled, NRT | | Defender XDR | DeviceEvents, IdentityLogonEvents, EmailEvents, CloudAppEvents, AlertEvidence 及其他 15 多个 | Custom Detection, Advanced Hunting | | 统一门户 | 结合 Sentinel + Defender 表的跨平台查询 | Scheduled + Custom Detection | ## 安装说明 ### 安装到 Claude Code(全局,所有项目) ``` # 复制到你的 skills 目录 cp -r . ~/.claude/skills/kql-detections/ ``` ### 安装到特定项目 ``` mkdir -p .claude/skills/kql-detections/references cp SKILL.md .claude/skills/kql-detections/ cp references/*.md .claude/skills/kql-detections/references/ ``` ## 使用方法 当您的对话提及以下内容时,该 skill 会自动触发: ``` KQL · Sentinel · Defender XDR · analytic rule · custom detection · advanced hunting brute force · impossible travel · anonymous sign-in · lateral movement · persistence password spray · MFA fatigue · OAuth abuse · ransomware detection · SIEM rule "write a KQL" · "build a detection" · "create an analytic rule" · "detect X in Sentinel" ``` 或者明确引用它: ``` Use the kql-detections skill to write a Sentinel rule for impossible travel ``` ## 示例用例 **1. 身份检测:** ``` Write a Sentinel scheduled analytic rule to detect impossible travel — a user signing in from two countries within 1 hour. Include YAML output. ``` **2. 端点检测:** ``` Write a Defender XDR advanced hunting query to detect PowerShell downloading a file from the internet using WebClient or Invoke-WebRequest. Map to MITRE T1059.001. ``` **3. 持久化检测:** ``` Detect when an OAuth application is granted the Mail.ReadWrite scope in Microsoft 365. I need a Sentinel analytic rule with entity mappings. ``` **4. 勒索软件检测:** ``` Build a KQL detection for mass file rename events on Windows endpoints that could indicate ransomware encryption. Defender XDR, high severity. ``` ## Skill 结构 ``` kql-detections/ ├── SKILL.md ← Main skill + workflow + output formats ├── README.md ← This file ├── LICENSE ← MIT └── references/ ├── sentinel-tables.md ← All major Sentinel/Log Analytics table schemas ├── defender-tables.md ← All Defender XDR advanced hunting table schemas ├── kql-syntax.md ← KQL operators, functions, performance rules ├── detection-patterns.md ← 20+ pre-validated detection recipes └── analytic-rule-yaml.md ← Full YAML schema, ARM templates, entity mappings ``` ## 工作原理 每个检测都遵循 6 步工作流程: ``` 1. Clarify intent — what behaviour, which platform, what output format 2. Identify data sources — which tables hold the required telemetry 3. Verify schema — check reference files, fetch Microsoft Learn docs if needed 4. Build KQL — apply performance rules, use detection patterns where available 5. Wrap in YAML — for Sentinel rules: add MITRE, entity mappings, severity, frequency 6. Document — detection logic, false positives, tuning, recommended SOC response ``` ## 性能规则(每次查询均强制执行) 该 skill 对其编写的每个检测强制执行 10 条 KQL 性能规则: - `TimeGenerated` 过滤器始终放在首位 - 尽早使用 `project` 以减少数据量 - 在索引词搜索中使用 `has` 代替 `contains` - 无前导通配符 - 在 `summarize` 或 `join` 之前进行过滤 - 使用特定表 —— 绝不使用 `search *` 或 `union *` - 使用 `in` 代替链式 `or` - 在 `where` 谓词中不使用 `tostring()` - 对重用的子查询使用 `materialize()` - 在 `bag_unpack()` 之后保持架构稳定
标签:AI技能, AMSI绕过, DLL 劫持, KQL, Microsoft Sentinel, 大语言模型, 威胁检测, 安全运营, 扫描框架