cpt-ferna02/ai-soc-detection-lab
GitHub: cpt-ferna02/ai-soc-detection-lab
一个完整的 AI 辅助 SOC 检测实验室,通过模拟真实攻击链路并结合 Claude API 自动化告警增强,帮助安全从业者在隔离环境中实践检测工程与事件响应全流程。
Stars: 0 | Forks: 0
# AI 辅助 SOC 检测实验室
一个功能完备的家庭安全运营中心 (SOC) 实验室,可模拟真实的企业安全工作流 —— 从攻击模拟到 AI 驱动的事件响应。
## 项目功能
本实验室模拟了一个真实的企业环境,其中:
1. **执行攻击** 使用 Atomic Red Team(映射 MITRE ATT&CK 的模拟)
2. **收集遥测数据** 通过受害端点上的 Sysmon
3. **生成警报** 由具有自定义检测规则的 Wazuh SIEM 进行
4. **自动运行 AI 增强** — Python 管道将警报发送到 Claude API 并接收结构化的调查报告
5. **生成事件报告** 包含严重性评级、MITRE 映射、调查步骤和修复指南
## 架构
```
Kali Linux VM → Windows 10 VM → Ubuntu Server VM
192.168.56.101 192.168.56.102 192.168.56.103
[Attacker] Attack [Victim Endpoint] Sysmon [SIEM + AI Pipeline]
Traffic Sysmon Installed Events Wazuh + Python + Claude API
```

**网络:** VirtualBox 仅主机网络 (192.168.56.0/24) 用于实验室流量 + NAT 用于互联网访问
## 技术栈
| 组件 | 工具 | 用途 |
|---|---|---|
| Hypervisor | Oracle VirtualBox 7.x | 虚拟机管理 |
| SIEM | Wazuh 4.7.5 | 日志收集、警报、仪表板 |
| 端点遥测 | Microsoft Sysmon | 深度 Windows 事件日志记录 |
| 攻击模拟 | Atomic Red Team | 安全的 MITRE ATT&CK 映射模拟 |
| AI 增强 | Anthropic Claude API | 自动化警报分析和报告 |
| 检测格式 | Wazuh XML 规则 | 自定义平台特定检测 |
## 攻击 → 检测 → 响应:完整示例
### 攻击:T1059.001 — PowerShell 编码命令执行
**攻击者的行为:**
使用 `-ExecutionPolicy Bypass` 和 `-NonInteractive` 标志执行 Base64 编码的 PowerShell 命令 —— 这是一种用于规避简单基于字符串的检测并在无需用户交互下运行代码的经典技术。
**Sysmon 捕获到的内容:**
```
EventID=1 (Process Creation)
Image: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
CommandLine: powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABjAD0ATgBlAHcALQBPAGIAagBl...
ParentImage: C:\Windows\System32\cmd.exe
User: labuser
SHA256: ABC3E2D7F1B94056E2C1A34D78F29B6E5D0C1A2B3E4F5A6B7C8D9E0F1A2B3C4D
```
**自定义 Wazuh 规则检测到的内容:**
```
sysmon_event1
(?i)powershell\.exe
PowerShell execution detected (T1059.001)
T1059.001
```
**AI 管道生成的内容:**
```
Severity: CRITICAL
MITRE: T1059.001 — Command and Scripting Interpreter: PowerShell
Confidence: High
Classification: Malicious
Summary:
Encoded PowerShell execution with ExecutionPolicy Bypass detected on Win10-Victim.
The combination of -NonInteractive, -ExecutionPolicy Bypass, and -EncodedCommand
is characteristic of offensive tooling rather than legitimate administration.
Investigation Steps:
1. Decode the Base64 command to reveal the actual payload
2. Query Sysmon Event ID 3 for network connections made by this process
3. Trace the parent cmd.exe process to identify the initial execution vector
4. Search for Sysmon Event ID 11 (File Created) to identify dropped payloads
5. Review the user labuser's recent activity: RDP logins, email attachments
Containment:
- Isolate Win10-Victim (192.168.56.102) from the network
- Terminate the PowerShell process and any child processes
- Capture memory dump before remediation for forensic analysis
- Preserve full Sysmon and Windows Event logs
False Positive Check:
Legitimate admin scripts rarely combine ExecutionPolicy Bypass with
EncodedCommand and NonInteractive flags simultaneously. This trifecta
specifically evades security controls and is characteristic of offensive tooling.
```
## 自定义检测规则
位于 `detections/local_rules.xml`
| 规则 ID | 等级 | 技术 | 描述 |
|---|---|---|---|
| 100002 | 10 | T1059.001 | 检测到 PowerShell 执行 |
| 100003 | 10 | T1053.005 | 创建了计划任务 — 可能存在持久化 |
| 100004 | 8 | T1012 | 通过 reg.exe 进行注册表查询 |
| 100005 | 12 | T1082 | 通过 systeminfo.exe 发现系统信息 |
## AI 管道
`automation/alert_enricher.py` 脚本:
1. 读取 Wazuh 警报(通过 API 或示例 JSON)
2. 提取:规则 ID、描述、MITRE 技术、代理名称、进程映像、命令行、父进程、哈希值
3. 将结构化上下文发送到 Claude API
4. 接收包含严重性、分类、调查步骤和修复建议的 JSON 响应
5. 为每个警报保存增强后的 JSON 和格式化的 Markdown 报告
6. 生成带有威胁分类细分的运行摘要
**示例运行输出:**
```
[1/4] Rule 100002 (L10): PowerShell execution detected (T1059.001)
→ Sending to Claude API... ✦ [Critical] Malicious
→ report_100002_2026-05-10T21-14-33.md
[2/4] Rule 100003 (L10): Scheduled task created (T1053.005)
→ Sending to Claude API... ✦ [High] Suspicious
→ report_100003_2026-05-10T21-15-07.md
Run complete — 4/4 alerts enriched
✦ Malicious: 1 ✦ Suspicious: 1 ✦ Likely Benign: 2
```
## 运行的攻击模拟
### T1082 — 系统信息发现
- 运行 `systeminfo.exe` 以枚举操作系统、硬件、修补程序和网络配置
- Sysmon 事件 ID 1 捕获了带有完整命令行的进程创建
- 触发了自定义规则 100005(级别 12)
- **防御者检测到此行为的原因:** 在 IT 管理窗口之外突然执行 systeminfo.exe
### T1053.005 — 计划任务持久化
- 创建了两个计划任务:`T1053_005_OnLogon` 和 `T1053_005_OnStartup`
- Sysmon 捕获到了 `schtasks.exe /create` — 常见的持久化指标
- 触发了自定义规则 100003(级别 10)
- **盲点:** 通过 PowerShell 的任务计划程序 COM 对象可完全绕过 schtasks.exe
### T1012 — 查询注册表
- 查询了运行键、已安装的软件和系统配置注册表配置单元
- Sysmon 捕获到了多次 `reg.exe query` 执行
- 触发了自定义规则 100004(级别 8)
- **盲点:** PowerShell 中的 `Get-ItemProperty` 不会生成 reg.exe — 从而绕过了此检测
### T1059.001 — PowerShell 编码命令
- 执行了带有 ExecutionPolicy Bypass 的 Base64 编码 PowerShell
- Sysmon 捕获到了包含编码负载的完整命令行
- 触发了自定义规则 100002(级别 10) — AI 将其分类为 **严重/恶意**
## 截图
| 截图 | 描述 |
|---|---|
|  | 安装后的 Wazuh 仪表板 |
|  | Win10-Victim 代理已连接并处于活动状态 |
|  | Wazuh 中的实时 Sysmon 事件 |
|  | 攻击模拟后的仪表板 |
|  | 触发自定义规则 100002 |
|  | AI 增强管道正在处理 4 个警报 |
## 仓库结构
```
ai-soc-detection-lab/
├── README.md
├── docs/
│ ├── architecture.png ← Network diagram
│ ├── attack-log.md ← Documented attack techniques
│ └── project-summary.md ← Full project documentation
├── detections/
│ └── local_rules.xml ← Custom Wazuh detection rules
├── automation/
│ └── alert_enricher.py ← AI enrichment pipeline
├── reports/
│ ├── enriched_*.json ← Raw AI analysis output
│ ├── report_*.md ← Formatted incident reports
│ └── timeline-*.md ← Attack timelines
├── screenshots/ ← Lab evidence
└── sample-logs/
└── sample_alerts.json ← Sample Wazuh alerts for testing
```
## 关键经验教训
**遥测数据就是一切。** Sysmon 将基本的 Windows 日志记录转变为对每个进程、网络连接和文件操作具备取证级别的记录。没有它,这些攻击中的大多数将对 SIEM 不可见。
**检测工程比看起来更难。** 编写能够正确加载、匹配正确事件并避免误报的规则,需要对日志格式和攻击者行为有深入的了解。
**AI 增加增加了真正的价值。** Claude API 不仅对警报进行了分类 —— 它还识别出特定组合的 PowerShell 标志是攻击性工具的特征,提供了针对上下文的调查步骤,并建议了取证保全措施。这就是警报与调查之间的区别。
**配置管理很重要。** 此实验室中的几乎所有问题都源于配置错误,而不是软件错误。在编辑之前备份配置文件。在重启服务之前验证 XML。
## 未来扩展
- [ ] 添加 Active Directory 环境以进行横向移动检测
- [ ] 集成 Velociraptor 进行实时取证
- [ ] 添加 Zeek 用于网络流量分析
- [ ] 构建 SOAR 风格的自动化响应操作
- [ ] 添加云攻击模拟 (AWS/Azure)
- [ ] 集成威胁狩猎仪表板
## 工具与参考
- [Wazuh 文档](https://documentation.wazuh.com)
- [Atomic Red Team](https://github.com/redcanaryco/invoke-atomicredteam)
- [MITRE ATT&CK 框架](https://attack.mitre.org)
- [Sysinternals 的 Sysmon](https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon)
- [Anthropic Claude API](https://docs.anthropic.com)
*本项目作为 SOC 分析师、检测工程和安全自动化技能的作品集展示而构建。*
标签:AI安全, Atomic Red Team, Chat Copilot, Claude API, Cloudflare, Conpot, MITRE ATT&CK, OpenCanary, Python, SOC实验室, Sysmon, URL发现, VirtualBox, Wazuh, Windows安全, 人工智能, 企业安全, 告警分类, 告警富化, 安全事件响应, 安全检测, 安全运营中心, 库, 应急响应, 攻击模拟, 数据展示, 数据泄露检测, 无后门, 用户模式Hook绕过, 红队, 网络安全, 网络安全实验室, 网络映射, 网络资产管理, 逆向工具, 隐私保护, 驱动签名利用