mkl24s/microsoft-sentinel-detection-lab
GitHub: mkl24s/microsoft-sentinel-detection-lab
一个构建在 Azure 上的 Microsoft Sentinel SIEM 检测实验室,通过模拟真实攻击链来培养 SOC 分析师在威胁检测、KQL 查询、事件响应和自动化编排方面的实战技能。
Stars: 0 | Forks: 0
# Microsoft Sentinel 检测实验室
这是一个构建在 Microsoft Azure 中的云原生 SIEM 检测实验室,旨在培养与 SOC 分析师角色相关的实际威胁检测、KQL 查询和事件响应技能。
## 概述
该实验室模拟了针对 Windows 11 端点的真实攻击链,并使用 Microsoft Sentinel 进行检测。所有检测都是自定义构建的 KQL 分析规则,并映射到 MITRE ATT&CK 技术。
**模拟的攻击链:**
1. 暴力破解登录尝试(凭证访问)
2. 创建新的本地用户账户(持久化)
3. 将用户添加到本地 Administrators 组(权限提升)
4. 执行侦察命令(发现)
5. 触发账户锁定(影响)
## 架构
┌─────────────────────────────────────────────┐
│ Azure (rg-soc-lab) │
│ │
│ ┌──────────────────┐ │
│ │ vm-target- │ NSG: RDP restricted │
│ │ endpoint │ to analyst IP only │
│ │ Windows 11 Pro │ │
│ │ Standard D2s v3 │ │
│ └────────┬─────────┘ │
│ │ Azure Monitor Agent (AMA) │
│ │ v1.43.0.0 │
│ ▼ │
│ ┌──────────────────┐ │
│ │ Data Collection │ Collects: │
│ │ Rule (DCR) │ - Windows Security │
│ │ dcr-sysmon- │ Events (Security!*)│
│ │ ingest │ - Sysmon Events │
│ └────────┬─────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ Log Analytics │ law-soc-sentinel │
│ │ Workspace (LAW) │ │
│ └────────┬─────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ Microsoft │ 5 custom analytics │
│ │ Sentinel │ rules + workbook │
│ └──────────────────┘ │
└─────────────────────────────────────────────┘
## 使用的技术
| 技术 | 用途 |
|---|---|
| Microsoft Azure | 云平台 |
| Microsoft Sentinel | SIEM / SOAR |
| Log Analytics Workspace | 日志存储和 KQL 查询 |
| Azure Monitor Agent (AMA) | 从 VM 收集日志 |
| Data Collection Rule (DCR) | 定义要收集哪些日志 |
| Sysmon (SwiftOnSecurity config) | 增强的端点遥测 |
| Windows Security Event Log | 身份验证和账户事件 |
| KQL (Kusto Query Language) | 检测规则和威胁狩猎 |
| MITRE ATT&CK | 检测框架映射 |
| Network Security Group (NSG) | 网络访问控制 |
| Azure Logic Apps | SOAR playbook 自动化 |
## 实验室组件
### 基础设施
- **Resource Group:** rg-soc-lab (UK South)
- **Virtual Machine:** vm-target-endpoint — Windows 11 Pro, Standard D2s v3 (2 vCPUs, 8 GiB RAM)
- **VNet:** vm-target-endpoint-vnet — 地址空间 10.0.0.0/16
- **Subnet:** default — 10.0.0.0/24
- **NSG:** vm-target-endpoint-nsg — RDP (端口 3389) 仅限分析师 IP 访问,DenyAllInbound 默认规则
- **Log Analytics Workspace:** law-soc-sentinel
- **Microsoft Sentinel:** 部署在 LAW 之上
### 数据收集
- **Azure Monitor Agent (AMA)** v1.43.0.0 通过 DCR 关联安装在 VM 上
- **DCR:** dcr-sysmon-ingest — 自定义 XPath 规则收集:
- Security!* — 所有 Windows Security 事件
- Microsoft-Windows-Sysmon/Operational* — 所有 Sysmon 事件
- **Sysmon** 使用 SwiftOnSecurity sysmon-config 安装,以获取高质量的端点遥测数据
## 检测规则
在 Microsoft Sentinel 中构建了五个自定义 KQL 分析规则,每 5 分钟运行一次:
### 1. 暴力破解 — 多次登录失败
**严重程度:** 中 | **MITRE:** T1110 — Brute Force
检测 1 小时内来自单个源 IP 的 5 次或更多失败的登录尝试。
```
SecurityEvent
| where EventID == 4625
| where TimeGenerated > ago(1h)
| summarize FailedAttempts = count(),
TargetAccounts = make_set(TargetUserName),
FirstAttempt = min(TimeGenerated),
LastAttempt = max(TimeGenerated)
by IpAddress, Computer
| where FailedAttempts >= 5
```
### 2. 持久化 — 用户被添加到本地 Administrators
**严重程度:** 高 | **MITRE:** T1098 — Account Manipulation
检测是否有任何用户被添加到本地 Administrators 组。
```
SecurityEvent
| where EventID == 4732
| where TargetUserName == "Administrators"
| project TimeGenerated, Computer, SubjectUserName, MemberName
```
### 3. 持久化 — 创建了新的本地用户账户
**严重程度:** 中 | **MITRE:** T1136.001 — Create Account: Local Account
检测新本地用户账户的创建。
```
SecurityEvent
| where EventID == 4720
| project TimeGenerated, Computer, SubjectUserName, TargetUserName
```
### 4. 执行 — 可疑的侦察命令
**严重程度:** 中 | **MITRE:** T1059 — Command and Scripting Interpreter
检测常见后渗透侦察命令的执行。
```
SecurityEvent
| where EventID == 4688
| where CommandLine has_any ("net user", "net localgroup", "whoami", "ipconfig", "systeminfo")
| project TimeGenerated, Computer, Account, NewProcessName, CommandLine
```
### 5. 影响 — 用户账户锁定
**严重程度:** 中 | **MITRE:** T1110.001 — Brute Force: Password Guessing
检测可能表明发生了暴力破解攻击的用户账户锁定事件。
```
SecurityEvent
| where EventID == 4740
| project TimeGenerated, Computer, TargetUserName, SubjectUserName
```
## 攻击模拟
在受害者 VM 上运行了以下 PowerShell 脚本以生成真实的攻击遥测数据:
```
# 启用 audit policies
auditpol /set /subcategory:"Logon" /success:enable /failure:enable
auditpol /set /subcategory:"Process Creation" /success:enable /failure:enable
auditpol /set /subcategory:"User Account Management" /success:enable /failure:enable
auditpol /set /subcategory:"Security Group Management" /success:enable /failure:enable
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit" /v ProcessCreationIncludeCmdLine_Enabled /t REG_DWORD /d 1 /f
# 模拟 brute force (Event ID 4625)
$pw = ConvertTo-SecureString "wrongpassword" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("fakeuser", $pw)
1..10 | ForEach-Object { try { Start-Process cmd -Credential $cred -ErrorAction Stop } catch {} }
# 创建 backdoor account (Event ID 4720)
net user hacker Password123! /add
# 提权至 admin (Event ID 4732)
net localgroup administrators hacker /add
# 运行 recon (Event ID 4688)
whoami
net user
net localgroup administrators
ipconfig /all
systeminfo
# 清理 (Event ID 4726)
net user hacker /delete
```
## 自动化响应
构建了 Logic App playbook 和自动化规则,以自动响应高严重程度的事件:
- **Playbook:** Sentinel-Auto-Comment-High-Severity
- **逻辑:** 当创建高严重程度的事件时,自动添加分析师评论
- **自动化规则:** Trigger-Playbook-High-Severity — 在事件创建且严重程度为高时触发
- **结果:** 在创建事件后几秒钟内添加自动化分类评论
## 威胁狩猎
在 Microsoft Sentinel Hunting 中构建了三个主动狩猎查询:
| 查询 | 战术 | MITRE | 结果 |
|---|---|---|---|
| Hunt - Lateral Movement via Network Logon | Lateral Movement | T1021 | 0 个结果 — 单端点实验室 |
| Hunt - User Account Created Outside Business Hours | Persistence | T1136.001 | 1 个结果 — 20:13 的黑客账户 |
| Hunt - Reconnaissance Command Burst | Discovery | T1087 | 1 个结果 — whoami, ipconfig, systeminfo |
## 生成的事件
攻击模拟在所有 5 个检测规则中生成了 42 个事件。
| 事件 | 严重程度 | MITRE 技术 |
|---|---|---|
| Brute Force - Multiple Failed Logons | 中 | T1110 |
| Persistence - User Added to Local Administrators | 高 | T1098 |
| Persistence - New Local User Account Created | 中 | T1136.001 |
| Execution - Suspicious Reconnaissance Commands | 中 | T1059 |
| Impact - User Account Lockout | 中 | T1110.001 |
有关完整的事件调查报告,请参阅 incidents/investigation-001.md。
## 截图
| 截图 | 描述 |
|---|---|
| 00-resource-group | 创建了资源组 rg-soc-lab |
| 01-log-analytics-workspace | 创建了 LAW law-soc-sentinel |
| 02-sentinel-activated | 激活了 Microsoft Sentinel |
| 03-vm-overview | VM vm-target-endpoint 正在运行 |
| 04-ama-installed | AMA v1.43.0.0 预配成功 |
| 05-dcr-data-sources | DCR 正在收集 Sysmon 和 Security 事件 |
| 06-ama-heartbeat | 确认 AMA 正常工作的 Heartbeat 查询 |
| 07-security-events-flowing | Security 事件正在流入 Sentinel |
| 08-attack-simulation | PowerShell 攻击模拟输出 |
| 09-all-analytics-rules | 所有 5 个检测规则已启用 |
| 10-workbook-dashboard | 带有实时数据的检测仪表板 |
| 11-incidents-list | 生成了 42 个事件 |
| 12-incident-investigation | 带有 MITRE 映射的事件调查 |
| 20-playbook-created | playbook 在 Sentinel 中处于活动状态 |
| 21-automation-rule | 配置了自动化规则 |
| 22-playbook-comment | 将自动化评论添加到事件中 |
## 关键经验教训
有关遇到的问题及其解决方法的完整报告,请参阅 lessons-learned.md。主要问题包括 AMA 安装更改、DCR 缺少 Security 事件、Defender 门户过滤器隐藏了事件,以及跨租户的 Logic App 身份验证。
## SC-200 相关性
在准备 SC-200 Microsoft Security Operations Analyst 考试时构建。该实验室直接涵盖了:
- 配置 Microsoft Sentinel 数据收集
- 创建和管理分析规则
- 调查和响应事件
- 在 Microsoft Sentinel 中执行威胁狩猎
- 使用 playbook 自动化响应
## 认证
CompTIA A+, CompTIA Security+, AZ-900, Splunk Power User
## 作者
Mason Lewis
标签:AI合规, Cloudflare, KQL, Microsoft Sentinel, MITRE ATT&CK, 安全实验室, 配置错误