Lovedipsingh/AD-Attack-Detection-Lab

GitHub: Lovedipsingh/AD-Attack-Detection-Lab

一个基于 Splunk 的 Active Directory 攻击模拟与检测实验平台,演示如何通过 MITRE ATT&CK 映射编写检测规则并分析安全事件。

Stars: 0 | Forks: 0

# Active Directory 攻击检测实验 ## 概述 一个动手实践的网络安全家庭实验室,模拟真实的 Active Directory 攻击并使用 Splunk SIEM 进行检测。该项目展示了实用的蓝队技能,包括 AD 管理、攻击模拟、Windows 事件日志分析,以及基于 MITRE ATT&CK 框架的威胁检测映射。 ## 实验室架构 ``` ┌──────────────────────────────────────────────────────────────┐ │ HOST MACHINE │ │ Windows (192.168.50.184) │ │ │ │ ┌──────────────────────────────────┐ │ │ │ Splunk Enterprise │ │ │ │ Receiving on port 9997 │ │ │ │ Search, Analysis & │ │ │ │ Detection Queries │ │ │ └───────────────┬──────────────────┘ │ └────────────────────┼─────────────────────────────────────────┘ │ TCP 9997 │ (Log Forwarding) ┌────────────────────┼─────────────────────────────────────────┐ │ VIRTUALBOX VM │ │ │ ▼ │ │ ┌──────────────────────────────────┐ │ │ │ Windows Server 2022 │ │ │ │ DC.lovediplab.local │ │ │ │ 192.168.50.100 │ │ │ │ │ │ │ │ • Active Directory Domain │ │ │ │ Services (AD DS) │ │ │ │ • DNS Server │ │ │ │ • Splunk Universal Forwarder │ │ │ │ • Security Event Log Source │ │ │ └──────────────────────────────────┘ │ └──────────────────────────────────────────────────────────────┘ ``` ## 工具与技术 - **Windows Server 2022** - 运行 AD DS 和 DNS 的域控制器 - **Splunk Enterprise** - 用于日志摄取、搜索和检测的 SIEM - **Splunk Universal Forwarder** - 轻量级代理,用于转发 Windows 事件日志 - **Oracle VirtualBox** - 实验室虚拟化 hypervisor - **PowerShell** - 攻击模拟和系统管理 - **MITRE ATT&CK** - 用于检测映射的威胁框架 ## Active Directory 配置 **域:** lovediplab.local **域控制器:** DC(Windows Server 2022) ### 组织单位 | OU | 用途 | |---|---| | IT | IT 部门用户 | | HR | 人力资源用户 | | Finance | 财务部门用户 | ### 用户账户(总计 10 个) | 用户 | 登录名 | 部门 | |---|---|---| | John Carter | jcarter | IT | | Sarah Miller | smiller | IT | | Mike Torres | mtorres | IT | | Lisa Chen | lchen | HR | | David Brown | dbrown | HR | | Amy Wilson | awilson | HR | | James Park | jpark | Finance | | Rachel Green | rgreen | Finance | | Tom Harris | tharris | Finance | | Nina Patel | npatel | Finance | ### 安全组 | 组 | 成员 | 用途 | |---|---|---| | IT-Admins | jcarter, smiller | 特权 IT 访问 | | HR-Staff | lchen, dbrown, awilson | HR 部门访问 | | Finance-Sensitive | jpark, rgreen | 敏感财务数据访问 | ## Active Directory 结构 ![OU 结构](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/e39b359c8a185624.png) ![IT 用户](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/15f21f4c41185627.png) ![HR 用户](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/1bf02182a2185628.png) ![财务用户](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/a53ffe6e90185630.png) ![IT 管理员成员](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/690d2de37d185631.png) ![财务敏感成员](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/6afc5fb724185634.png) ## 攻击模拟 执行了四个攻击场景,针对域控制器生成了真实的 Windows 安全事件日志遥测数据。 ### 攻击 1:暴力破解(MITRE ATT&CK T1110) - **描述:** 对 jcarter 账户进行 15 次连续失败的登录尝试 - **生成的事件 ID:** 4625(账户登录失败) - **检测逻辑:** 基于阈值的检测——标记在时间窗口内失败登录超过 5 次的账户 ![暴力破解攻击](https://raw.githubusercontent.com/Lovedipsingh/AD-Attack-Detection-Lab/main/screenshots/07-Brute-Force-Attack.png) ### 攻击 2:凭据妥协(MITRE ATT&CK T1078) - **描述:** 在暴力破解尝试后成功登录 jcarter 账户 - **生成的事件 ID:** 4624(账户成功登录) - **检测逻辑:** 将同一源 IP 的多次失败登录(4625)与随后的成功登录(4624)进行关联 ![成功登录](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/9bbf941957185706.png) ### 攻击 3:违规账户创建(MITRE ATT&CK T1136.002) - **描述:** 创建未经授权的 "hacker" 域用户账户 - **生成的事件 ID:** 4720(创建用户账户) - **检测逻辑:** 对任何域账户创建发出警报,特别是非标准管理员账户或变更管理窗口之外的操作 ![违规账户创建](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/df339196d0185707.png) ### 攻击 4:通过组修改的权限提升(MITRE ATT&CK T1098) - **描述:** 将 "hacker" 账户添加到域管理员组 - **生成的事件 ID:** 4728(成员添加到安全全局组)、4732(成员添加到安全本地组) - **检测逻辑:** 对 Domain Admins、Enterprise Admins 或 Schema Admins 组的任何修改立即发出警报 ![权限提升](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/afd28aa201185709.png) ## 事件日志验证 ![安全事件日志](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/224f9f63f2185711.png) ![安全事件日志(续)](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/609584d483185714.png) ![失败登录事件](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/2f5326e56b185717.png) ![Kerberos TGT 事件](https://raw.githubusercontent.com/Lovedipsingh/AD-Attack-Detection-Lab/main/screenshots/13-Kerberos-TGT-Events.png) ## MITRE ATT&CK 映射 | 技术 ID | 技术名称 | 战术 | 事件 ID | SPL 检测 | |---|---|---|---|---| | T1110 | 暴力破解 | 凭据访问 | 4625 | 基于阈值的失败登录检测 | | T1078 | 有效账户 | 防御规避、持久性 | 4624、4625 | 时间窗口内的失败后成功登录关联 | | T1136.002 | 创建账户:域账户 | 持久性 | 4720 | 新域账户创建告警 | | T1098 | 账户操纵 | 持久性、权限提升 | 4728、4732 | 敏感组修改检测 | | T1558.003 | Kerberoasting | 凭据访问 | 4768 | 异常 Kerberos TGT 请求监控 | ## Splunk SIEM 检测 **从域控制器摄取了 3,322 个安全事件** ![Splunk 事件摄取](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/778e0284eb185718.png) ### 检测 1:暴力破解检测 ``` index=main sourcetype="WinEventLog:Security" EventCode=4625 | stats count by Account_Name, Source_Network_Address | where count > 5 | sort -count ``` **目的:** 识别具有过多失败登录尝试的账户,并按源 IP 分组以识别攻击主机。 ![暴力破解检测](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/6c875bb7dd185721.png) ### 检测 2:凭据妥协(失败后成功登录) ``` index=main sourcetype="WinEventLog:Security" (EventCode=4625 OR EventCode=4624) | bin _time span=1h | stats count(eval(EventCode=4625)) as failures, count(eval(EventCode=4624)) as successes, earliest(_time) as first_event, latest(_time) as last_event by _time, Account_Name, Source_Network_Address | where failures > 3 AND successes > 0 | eval time_window=tostring(last_event-first_event,"duration") | table _time, Account_Name, Source_Network_Address, failures, successes, time_window ``` **目的:** 检测在来自同一源 IP 的多次失败登录后 1 小时内发生的成功登录。时间分箱确保成功发生在失败之后,而不是相隔数天。 ![凭据妥协检测](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/f3ed766f56185723.png) ### 检测 3:违规账户创建 ``` index=main sourcetype="WinEventLog:Security" EventCode=4720 | table _time, Account_Name, Security_ID, ComputerName ``` **目的:** 展示所有账户创建事件以供审查。在生产环境中,这将与批准的变更管理列表进行过滤。 ![账户创建检测](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/ce2b831e94185725.png) ### 检测 4:权限提升——敏感组修改 ``` index=main sourcetype="WinEventLog:Security" (EventCode=4728 OR EventCode=4732) | search Group_Name IN ("Domain Admins", "Enterprise Admins", "Schema Admins", "Administrators") | table _time, Account_Name, Group_Name, Member_ID, ComputerName ``` **目的:** 检测对特权安全组的修改。过滤 Domain Admins、Enterprise Admins 和 Schema Admins 确保只有高影响权限提升会生成告警。 ![权限提升检测](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/d2e6576c77185728.png) ### 检测 5:时间窗口暴力破解 ``` index=main sourcetype="WinEventLog:Security" EventCode=4625 | bin _time span=30m | stats count by _time, Account_Name, Source_Network_Address | where count > 2 | sort -count ``` **目的:** 使用时间分箱在 30 分钟窗口内检测暴力破解尝试,减少跨长时间段的分布式失败登录产生的误报。 ![基于时间的暴力破解](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/8552da35e7185731.png) ### 检测 6:完整攻击链时间线 ``` index=main sourcetype="WinEventLog:Security" EventCode IN (4625, 4720, 4728, 4732, 4768) OR (EventCode=4624 AND Account_Name!="SYSTEM" AND Account_Name!="DC$" AND Account_Name!="*$") | eval Action=case( EventCode=4625, "Failed Logon", EventCode=4624, "Successful Logon", EventCode=4720, "Account Created", EventCode=4728, "Added to Global Group", EventCode=4732, "Added to Local Group", EventCode=4768, "Kerberos TGT Request") | table _time, EventCode, Action, Account_Name, ComputerName | sort _time ``` **目的:** 按时间顺序重建完整的攻击叙事,过滤掉机器账户噪声。该查询展示了追踪攻击者路径的能力,从初始访问到权限提升。 ![攻击链时间线](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/90695380cf185753.png) ## 关键 Windows 安全事件 ID | 事件 ID | 描述 | 安全相关性 | |---|---|---| | 4624 | 成功登录 | 跟踪合法和未授权访问 | | 4625 | 登录失败 | 检测暴力破解和密码喷洒 | | 4634 | 账户注销 | 会话跟踪和相关性 | | 4672 | 特殊权限分配 | 特权账户使用监控 | | 4720 | 创建用户账户 | 检测未授权账户创建 | | 4722 | 启用用户账户 | 检测已禁用账户的重新激活 | | 4724 | 密码重置尝试 | 检测未授权的密码更改 | | 4728 | 成员添加到全局组 | 权限提升检测 | | 4732 | 成员添加到本地组 | 权限提升检测 | | 4768 | Kerberos TGT 请求 | 身份验证异常检测 | ## 本项目所展示内容 - **Active Directory 管理** — 域部署、组织单位结构、用户/组管理 - **攻击模拟** — 贴近真实的对抗者行为模拟,映射到 MITRE ATT&CK - **Windows 事件日志分析** — 关键安全事件 ID 的理解 - **SIEM 操作** — Splunk 部署、Universal Forwarder 配置、日志摄取管道 - **检测工程** — 使用 `stats`、`eval`、`bin`、`where` 和 `case` 编写 SPL 查询进行威胁检测 - **事件调查** — 从原始日志数据重建攻击时间线
标签:Active Directory, AD攻击模拟, AI合规, AMSI绕过, Cloudflare, Home Lab, HTTP工具, MITRE ATT&CK, Plaso, Splunk SIEM, SPL查询, StruQ, Windows事件日志, 企业安全, 威胁检测, 安全模拟, 日志转发, 流量嗅探, 网络安全实验室, 网络安全审计, 网络资产管理, 蓝队演练, 虚拟化实验室