Armando-ic/ad-detection-lab

GitHub: Armando-ic/ad-detection-lab

这是一个面向蓝队的 AD 检测工程实验室,通过 Sysmon 和 Splunk 模拟真实攻击场景,帮助用户练习编写检测规则并掌握 SOC 分析师工作流。

Stars: 0 | Forks: 0

# Active Directory 检测实验室 一个蓝队家庭实验室,旨在练习使用 Splunk 作为 SIEM 来检测针对 Active Directory 的真实攻击。目标是模拟 SOC 分析师的工作流程:生成遥测数据、识别恶意活动、编写检测查询,并将发现映射到 MITRE ATT&CK 框架。 实验室按照 [MyDFIR](https://www.youtube.com/@MyDFIR) Active Directory 项目系列构建,并扩展了额外的攻击模拟、检测规则和文档。 ## 实验室架构 ``` graph TB subgraph NAT_Network["NAT Network: AD Project (192.168.10.0/24)"] direction TB ADDC01["ADDC01
Windows Server 2022
192.168.10.7
Domain Controller / DNS"] SPLUNK["Splunk Server
Ubuntu 24.04
192.168.10.10
Splunk Enterprise"] DEMO["Target-PC
Windows 11
192.168.10.100
Sysmon + Forwarder"] KALI["Kali Linux
192.168.10.250
Attacker"] end DEMO -- "Logs (9997)" --> SPLUNK ADDC01 -- "Logs (9997)" --> SPLUNK DEMO -- "Auth (LDAP/Kerberos)" --> ADDC01 KALI -- "Attacks (RDP/3389)" --> DEMO style ADDC01 fill:#4a90d9,stroke:#2c5aa0,color:#fff style SPLUNK fill:#4db848,stroke:#2d8028,color:#fff style DEMO fill:#f5a623,stroke:#c47d0e,color:#fff style KALI fill:#d0021b,stroke:#a00218,color:#fff ``` | 机器 | 操作系统 | 角色 | IP 地址 | |---------|------|------|------------| | ADDC01 | Windows Server 2022 | 域控制器 (mydfir.local) | 192.168.10.7 | | Splunk | Ubuntu Server 24.04 | SIEM — Splunk Enterprise | 192.168.10.10 | | Target-PC (demo) | Windows 11 | 域加入工作站 | 192.168.10.100 | | Kali Linux | Kali 2025.x | 攻击机 | 192.168.10.250 | **虚拟化:** Windows 11 主机上的 Oracle VirtualBox 7.2(32 GB RAM,NVMe SSD) ## 检测覆盖范围 | 检测项 | MITRE ATT&CK | 数据源 | Splunk 查询 | |-----------|-------------|-------------|--------------| | RDP 暴力破解 | [T1110.001](https://attack.mitre.org/techniques/T1110/001/) | Security EventCode=4625 | [failed-logon-spike.spl](splunk-queries/failed-logon-spike.spl) | | 本地账户创建 | [T1136.001](https://attack.mitre.org/techniques/T1136/001/) | Security EventCode=4720 | [new-local-admin.spl](splunk-queries/new-local-admin.spl) | | PowerShell 执行 | [T1059.001](https://attack.mitre.org/techniques/T1059/001/) | Sysmon EventID=1 | [powershell-encoded-command.spl](splunk-queries/powershell-encoded-command.spl) | | 计划任务创建 | [T1053.005](https://attack.mitre.org/techniques/T1053/005/) | Security EventCode=4698 | [suspicious-scheduled-task.spl](splunk-queries/suspicious-scheduled-task.spl) | *检测库正在积极扩展。有关包含排查指导的完整文档,请参阅 [detections/](detections/)*。 ## 攻击模拟与检测演练 ### 示例:RDP 暴力破解 (T1110.001) **攻击:** 从 Kali 攻击机使用密码列表对 Target-PC 进行 RDP 凭据暴力破解。 ``` # 对用户 tsmith 进行 RDP 登录 Brute force while IFS= read -r pass; do timeout 10 xfreerdp /v:192.168.10.100 /u:tsmith /p:"$pass" /cert:ignore +auth-only 2>&1 | grep -q "exit status 1" && echo ">>> SUCCESS: $pass <<<" && break done < passwords.txt ``` **检测:** 在 Splunk 中,短时间内出现大量来自同一源的失败登录事件 (4625),随后是成功的登录事件 (4624)。 ``` index=endpoint EventCode=4625 | stats count by src_ip, dest, user | where count > 10 | sort -count ``` **分析师排查:** 1. 识别失败登录的源 IP 2. 检查是否有来自同一源的成功登录 (4624) —— 表明已攻陷 3. 检查账户是否已被锁定 (4740) 4. 如果在暴力破解模式后确认了成功登录,则进行升级 ## 遥测数据源 所有日志通过 Universal Forwarder 转发到 Splunk 的 `endpoint` 索引中。 | 来源 | 日志类型 | 关键事件 ID | |--------|----------|--------------| | Windows Security | 身份验证、账户管理 | 4624, 4625, 4720, 4740, 4698 | | Windows System | 服务变更、系统事件 | 7045, 7040 | | Windows Application | 应用程序错误和警告 | 1000, 1001 | | Sysmon (Operational) | 进程创建、网络、文件、注册表 | 1, 3, 7, 8, 11, 13 | **Sysmon 配置:** 捕获进程创建 (EID 1)、网络连接 (EID 3)、镜像加载 (EID 7) 和文件创建 (EID 11),提供除默认 Windows 日志之外的深度端点可见性。 ## 练习演练 跨越三个技能轨道的 37 个动手练习。每个演练遵循 **执行 → 查找/验证 → 理解** 的格式:执行一个操作,查找证据或验证结果,然后分析所学内容。 ### Splunk / SIEM 轨道 (12 个演练) | 级别 | 重点 | 演练 | |-------|-------|--------| | **Level 1** | 基础搜索 | 查找登录、统计事件、探索数据源 | | **Level 2** | 攻击检测 | RDP 暴力破解、账户创建、计划任务、PowerShell | | **Level 3** | 分析师思维 | 完整攻击时间线、异常狩猎、仪表板构建 | | **Level 4** | 高级 SPL | Stats、timechart、eval、事务关联 | 参见:[docs/splunk-practice-drills.md](docs/splunk-practice-drills.md) ### Active Directory 轨道 (14 个演练) | 级别 | 重点 | 演练 | |-------|-------|--------| | **Level 1** | AD 基础 | 列出用户、组、计算机;检查锁定状态 | | **Level 2** | 安全调查 | 查找陈旧账户、审计特权组、审查密码策略 | | **Level 3** | 管理任务 | 创建用户/OU、配置 GPO、管理组成员身份 | | **Level 4** | 安全加固 | 启用审核策略、禁用 LLMNR、审查 DC 安全日志 | 参见:[docs/ad-practice-drills.md](docs/ad-practice-drills.md) ### Wireshark / 数据包分析轨道 (11 个演练) | 级别 | 重点 | 演练 | |-------|-------|--------| | **Level 1** | Wireshark 基础 | 捕获流量、显示过滤器、TCP 流、DNS、ICMP | | **Level 2** | 安全分析 | 端口扫描、RDP 暴力破解、Kerberos 认证、恶意软件 pcaps | | **Level 3** | SOC 调查 | 完整攻击捕获、CyberDefenders CTF、Unit 42 测验 | 参见:[docs/wireshark-practice-drills.md](docs/wireshark-practice-drills.md) ## 分析师参考指南 SOC 分析师工作的必备资源,包含用于培养熟练度的练习: | 资源 | 简介 | 使用时机 | |----------|-----------|-------------| | [MITRE ATT&CK](https://attack.mitre.org/) | 映射对手战术、技术和程序的框架 | 对攻击进行分类、编写检测规则、差距分析 | | [Windows 事件百科全书](https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/) | 每个 Windows 安全事件 ID 及其字段的详细细分 | 解码事件字段、理解触发警报的原因 | 包含 5 个研究练习:解码失败登录、将攻击映射到 ATT&CK、基于框架构建检测规则、事件 ID 深入研究以及威胁组织研究。 查看完整指南:[docs/analyst-references.md](docs/analyst-references.md) ## 工具与技术 - **虚拟化:** Oracle VirtualBox 7.2 - **域服务:** Windows Server 2022, Active Directory Domain Services - **SIEM:** Splunk Enterprise (Ubuntu Server 上的索引器 + 搜索头) - **端点遥测:** Sysmon (Microsoft Sysinternals), Splunk Universal Forwarder - **攻击模拟:** Atomic Red Team (Red Canary), Kali Linux, xfreerdp - **网络分析:** Wireshark - **框架:** MITRE ATT&CK ## 仓库结构 ``` ad-detection-lab/ ├── README.md ├── docs/ │ ├── lab-setup.md # Full build guide │ ├── splunk-setup.md # Splunk indexer + forwarder config │ ├── sysmon-config.md # Sysmon configuration choices │ ├── lessons-learned.md # Troubleshooting and fixes │ ├── splunk-practice-drills.md # 12 hands-on SPL exercises (4 levels) │ ├── ad-practice-drills.md # 14 hands-on AD exercises (4 levels) │ ├── wireshark-practice-drills.md # 11 hands-on packet analysis exercises (3 levels) │ └── analyst-references.md # MITRE ATT&CK and Event ID research guide ├── network-diagram/ │ └── ad-lab-topology.md # Mermaid network diagram ├── detections/ │ ├── T1110.001_rdp-brute-force.md │ ├── T1136.001_local-account-creation.md │ ├── T1059.001_powershell-execution.md │ └── T1053.005_scheduled-task-creation.md ├── splunk-queries/ │ ├── failed-logon-spike.spl │ ├── new-local-admin.spl │ ├── powershell-encoded-command.spl │ └── suspicious-scheduled-task.spl ├── scripts/ │ ├── populate-ad.ps1 # Creates OUs, users, groups │ ├── enable-audit-policies.ps1 # Applies recommended audit config │ └── install-sysmon.ps1 # Sysmon deployment script ├── attack-simulations/ │ ├── atomic-red-team-tests.md │ └── kali-rdp-bruteforce.md └── screenshots/ ``` ## 我学到了什么 - **Sysmon 至关重要。** 默认的 Windows 日志记录会遗漏大多数后渗透活动。Sysmon 事件 ID 1(进程创建)是检测 PowerShell 执行和计划任务滥用等攻击的最有价值的单一日志源。 - **时间同步很重要。** 当虚拟机时钟漂移时,SIEM 搜索会完全遗漏事件。在生产环境的 SOC 中,NTP 配置是首先要验证的事项之一。 - **攻击者的视角有助于检测。** 从 Kali 和 Atomic Red Team 运行攻击,让我能够直接了解每种技术会生成哪些遥测数据,从而更容易编写针对性的检测查询。 - **索引配置至关重要。** 搜索错误的 Splunk 索引,即使数据存在也会返回零结果。理解数据路由对于任何 SIEM 分析师来说都是基础。 - **FreeRDP 版本变更会破坏工具。** Crowbar(为 FreeRDP 2 构建)在 FreeRDP 3 中会由于退出代码反转而静默失败。排查这个问题强化了理解工具依赖关系的重要性,而不仅仅是运行命令。 ## 未来工作 - [ ] 为每个检测编写 Sigma 规则 (YAML) —— 与供应商无关的可移植格式 - [ ] 构建用于 SOC 概览的 Splunk 仪表板(失败登录、新账户、可疑进程) - [ ] 添加针对横向移动 (T1021)、凭据转储 (T1003) 和防御规避 (T1070) 的检测 - [ ] 创建威胁狩猎手册(假设驱动的调查) - [ ] 集成 Splunk 告警以实现实时通知 - [ ] 探索 TheHive/Cortex 用于事件响应案例管理 ## 致谢 - [MyDFIR](https://www.youtube.com/@MyDFIR) — 启发该实验室的 Active Directory 项目视频系列 - [Red Canary / Atomic Red Team](https://github.com/redcanaryco/atomic-red-team) — 攻击模拟框架 - [MITRE ATT&CK](https://attack.mitre.org/) — 用于检测映射的威胁框架 - [Claude Code](https://claude.ai/code) — 用于排查实验室问题和构建此仓库的 AI 助手
标签:Active Directory, AMSI绕过, Cloudflare, MITRE ATT&CK, Plaso, PoC, RDP, Splunk Enterprise, Sysmon, VirtualBox, Windows Server, 域控, 威胁检测, 安全运营, 实验室, 库, 应急响应, 扫描框架, 攻防模拟, 暴力破解, 查询语句, 检测规则, 网络安全, 网络资产发现, 虚拟化, 防御工程, 隐私保护