NightErth/Active-Directory-Home-Lab-Threat-Detection-Automated-Incident-Response

GitHub: NightErth/Active-Directory-Home-Lab-Threat-Detection-Automated-Incident-Response

基于 Vultr 云环境搭建的 Active Directory 安全实验室,集成 Splunk SIEM 与 Shuffle SOAR,演示从日志采集、未授权登录检测到自动化账户封禁的端到端蓝队检测响应流水线。

Stars: 0 | Forks: 0

# Active Directory 家庭实验室 — 威胁检测与自动化事件响应 一个部署在 **Vultr** 上的基于云的 Active Directory 环境,集成了 **Splunk** 用于驱动 SIEM 的威胁检测,以及 **Shuffle** 作为 SOAR 平台来自动化事件响应工作流。本项目模拟了一个真实的 SOC 环境,用于检测未经授权的登录,并通过自定义 playbook 自动修复受损账户。 ## 目录 - [项目概述](#project-overview) - [架构](#architecture) - [前置条件](#prerequisites) - [第 1 步 — 云基础设施配置 (Vultr)](#step-1--cloud-infrastructure-provisioning-vultr) - [第 2 步 — 网络配置与 VPC 设置](#step-2--network-configuration--vpc-setup) - [第 3 步 — Active Directory 设置与域配置](#step-3--active-directory-setup--domain-configuration) - [第 4 步 — Splunk 部署、日志摄取与告警配置](#step-4--splunk-deployment-log-ingestion--alert-configuration) - [第 5 步 — 使用 Shuffle 与 Slack 集成的 SOAR Playbook](#step-5--soar-playbook-with-shuffle--slack-integration) ## 项目概述 本项目演示了使用行业标准工具进行蓝队检测与响应流水线的端到端实现。核心目标包括: 1. **构建** 一个基于云的功能性 Active Directory 域环境。 2. **检测** 使用 Splunk 作为 SIEM 的未经授权或可疑登录活动。 3. **自动化** 事件响应——禁用受损的域账户——使用 Shuffle SOAR 并以 Slack 作为分析师通知渠道。 **关键技术:** | 工具 | 角色 | |---|---| | [Vultr](https://www.vultr.com/) | 云基础设施提供商 | | Windows Server 2022 | 域控制器与端点模拟 | | Ubuntu Server 22.04 | Splunk 服务器主机 | | Splunk Enterprise | SIEM — 日志摄取、关联和告警 | | Splunk Universal Forwarder | Windows 端点上的日志转发代理 | | Shuffle | SOAR — 自动化 playbook 执行 | | Slack | SOC 分析师通知与响应渠道 | | LDAP / Active Directory | 身份管理与用户修复目标 | ## 架构 ``` ┌─────────────────────────────────────────────────────────────────┐ │ Vultr Cloud (VPC) │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌───────────────────┐ │ │ │ ADDC01 │ │ TestMac01 │ │ SplunkServer │ │ │ │ Windows 2022 │ │ Windows 2022 │ │ Ubuntu 22.04 │ │ │ │ Domain Ctrl │◄──►│ Test Machine │───►│ Splunk :8080 │ │ │ │ 2vCPU/4GB │ │ 1vCPU/2GB │ │ 4vCPU/8GB/160GB │ │ │ └──────┬───────┘ └──────┬───────┘ └────────┬──────────┘ │ │ │ │ │ │ │ └──────── VPC Private Network ────────────┘ │ └─────────────────────────────────────────────────────────────────┘ │ Splunk Alert (Webhook) │ ┌──────────────▼───────────────┐ │ Shuffle (SOAR) │ │ Automated Response │ │ Playbook: MyAutoADSpl │ └──────┬───────────────┬────────┘ │ │ ┌──────▼──────┐ ┌──────▼──────┐ │ Slack │ │ Active Dir │ │ Alerts │ │ (LDAP :389) │ │ #Alerts │ │ Disable User │ └─────────────┘ └─────────────┘ ``` ## 前置条件 - 一个已启用账单的 [Vultr](https://www.vultr.com/) 账户 - 一个 [Splunk](https://www.splunk.com/en_us/download/splunk-enterprise.html) Enterprise 免费试用许可证 - 一个 [Shuffle](https://shuffler.io/) 账户 - 一个拥有管理员访问权限的 [Slack](https://slack.com/) 工作区 - 一台具有 RDP 客户端和 SSH 功能的本地机器 - 具备 Windows Server 管理和 Linux CLI 的基础知识 ## 第 1 步 — 云基础设施配置 (Vultr) 在同一个 Vultr 区域内部署三个云实例以构成实验环境。 ### 实例 1 — 域控制器 (`ADDC01`) 导航至 **Products → Compute → Deploy New Server** 并进行如下配置: | 设置 | 值 | |---|---| | Type | Shared CPU | | OS | Windows Server 2022 x64 | | vCPUs | 2 | | RAM | 4 GB | | Storage | 50 GB SSD | | Bandwidth | 3 TB/mo | | Server Name | `ADDC01` | ### 实例 2 — 测试机 (`TestMac01`) | 设置 | 值 | |---|---| | Type | Shared CPU | | OS | Windows Server 2022 x64 | | vCPUs | 1 | | RAM | 2 GB | | Storage | 50 GB SSD | | Bandwidth | 2 TB/mo | | Server Name | `TestMac01` | ### 实例 3 — Splunk 服务器 (`SplunkServer`) | 设置 | 值 | |---|---| | Type | Shared CPU | | OS | Ubuntu Server 22.04 | | vCPUs | 4 | | RAM | 8 GB | | Storage | 160 GB SSD | | Bandwidth | 4 TB/mo | | Server Name | `SplunkServer` | ### 访问控制 — 防火墙配置 导航至 **Products → Network → Firewall → Add Firewall Group**,并将其命名为 `MyFirewall-ADDC`。 配置以下入站规则,将访问权限限制为仅限您的 IP: | 规则 | 协议 | 端口 | 来源 | |---|---|---|---| | SSH | TCP | 22 | 仅限您的 IP | | RDP | TCP (MS RDP) | 3389 | 仅限您的 IP | 通过 **Settings → Firewall** 将此防火墙组应用于所有三个实例。 ## 第 2 步 — 网络配置与 VPC 设置 ### 虚拟私有云 (VPC) 从 Vultr 实例设置中为两个 Windows 实例和 Splunk 服务器启用 VPC。VPC 连接范围限于单个区域,因此所有三个实例必须部署在同一个地理区域中。 一旦启用 VPC,每个实例将被分配一个私有 IP 地址。在每台 Windows 机器上配置静态私有 IP: **Start Menu → Network & Internet Settings → Change Adapter Options → Right-click adapter → Properties → IPv4 → Use the following IP address** 为每台机器分配其各自的 VPC 发行的静态 IP 和子网掩码。通过在实例之间 ping 私有 IP 来验证连接。 ### 访问实例 **域控制器 (`ADDC01`):** 在本地机器上打开 **Remote Desktop Connection**,并使用 Vultr 控制台中的公共 IP 和凭据进行连接。 **测试机 (`TestMac01`):** 使用 `TestMac01` 的公共 IP 重复相同的 RDP 过程。 **Splunk 服务器 (`SplunkServer`):** 通过终端使用 SSH 连接: ``` ssh username@ ``` 连接后,从 Vultr 控制台启用 VPC 并将防火墙组应用于 Splunk 实例。 ## 第 3 步 — Active Directory 设置与域配置 ### 将 `ADDC01` 提升为域控制器 通过 RDP 登录到 `ADDC01` 并打开 **Server Manager**。导航至: **Add Roles and Features → Server Roles → Active Directory Domain Services → Add Features → Install** 安装完成后,点击 **Promote this server to a domain controller** 并配置: | 设置 | 值 | |---|---| | Deployment Operation | Add a new forest | | Root domain name | `Mylab.local` | | Directory Services Restore Mode (DSRM) password | *(设置一个强密码)* | 完成向导并允许服务器重启。重启后,该实例将作为完全配置好的 Active Directory 域控制器运行。 ### 创建域用户 打开 **Active Directory Users and Computers**: **Start → Active Directory Users and Computers → 展开 `Mylab.local` → Users → 右键点击 → New → User** 创建一个标准的域用户(例如,`Jane Doe` / 用户名: `JDoe`)并设置一个安全的密码。 ### 将 `TestMac01` 加入域 通过 RDP 登录到 `TestMac01` 并导航至: **Settings → System → About → Rename this PC (Advanced) → Member of: Domain → 输入 `Mylab`** 在提示时提供 Domain Admin 凭据并重启机器。 重启后,登录屏幕应显示 **Sign in to: MYLAB**,确认已成功加入域。使用 `Jane Doe` 的凭据登录以进行验证。 ### 为域用户启用 RDP 在 `TestMac01` 上,导航至: **Start → Allow remote connections to this computer → Select Users → Add → 输入 `JDoe`** 您现在可以使用域凭据通过 RDP 登录到 `TestMac01`: ``` Username: MYLAB\JDoe Password: ``` ## 第 4 步 — Splunk 部署、日志摄取与告警配置 ### 在 Ubuntu 上安装 Splunk Enterprise 通过 SSH 登录到 Splunk 服务器并更新系统: ``` apt-get update && apt-get upgrade -y ``` 从 [Splunk 网站](https://www.splunk.com/en_us/download/splunk-enterprise.html) 下载 Splunk Enterprise 的 `.deb` 软件包(免费试用 — Linux `.deb`)。复制 `wget` 下载链接并运行: ``` wget -O splunk.deb '' dpkg -i splunk.deb ``` 启动 Splunk 并完成初始配置: ``` cd /opt/splunk/bin ./splunk start ``` 在提示时设置管理员用户名和密码。在防火墙和 Vultr 的防火墙组中允许端口 `8080`(TCP,端口 `8080`,仅限您的 IP): ``` ufw allow 8080 ``` 在浏览器中访问 `http://:8080` 并使用您的管理员凭据登录。 ### Splunk 初始配置 - **时区:** 用户菜单 → Preferences → Set timezone to `GMT` → Apply - **附加组件:** Apps → Find More Apps → 安装 **Splunk Add-on for Microsoft Windows** - **索引:** Settings → Indexes → New Index → Name: `MyProjAD` → Save - **接收端口:** Settings → Forwarding and Receiving → Configure Receiving → New Receiving Port → `9997` 在主机防火墙中允许转发器端口: ``` ufw allow 9997 ``` ### 在 Windows 端点上安装 Splunk Universal Forwarder 从 [Splunk 网站](https://www.splunk.com/en_us/download/universal-forwarder.html) 下载 Universal Forwarder 并将其安装在 `ADDC01` 和 `TestMac01` 上。 在安装过程中,配置 **Receiving Indexer** 为: | 设置 | 值 | |---|---| | Indexer Host | `` | | Indexer Port | `9997` | ### 配置 `inputs.conf` 导航至 `C:\Program Files\SplunkUniversalForwarder\etc\system\local\` 并以管理员身份打开或创建 `inputs.conf`。添加以下节: ``` [WinEventLog://Security] index = MyProjAD disabled = False ``` 重启 Splunk Forwarder 服务以应用更改: **Services (以管理员身份运行) → SplunkForwarder → Log On → Local System Account → Apply → Restart** 通过运行以下搜索来验证 Splunk 中的日志摄取情况: ``` index=MyProjAD ``` 在域控制器 (`ADDC01`) 上重复进行 Universal Forwarder 的安装和 `inputs.conf` 的配置。 ### 模拟暴力破解 / 未经授权的登录活动 为了模拟真实的攻击流量,临时将 RDP 对公共互联网开放: **Vultr Firewall → 修改 MS RDP 规则 → Allow TCP port `3389` from Anywhere** 这会将端点暴露给外部的登录尝试,从而生成 Splunk 检测查询所使用的 `EventCode 4624`(成功登录)事件。 ### 创建 Splunk 检测告警 导航至 **Apps → Search and Reporting** 并运行以下检测查询: ``` index=MyProjAD EventCode=4624 (Logon_Type=7 OR Logon_Type=10) Source_Network_Address=* Source_Network_Address=40.* | stats count by _time, ComputerName, Source_Network_Address, user, Logon_Type ``` **查询分解:** | 子句 | 目的 | |---|---| | `index=MyProjAD` | 将搜索范围限定在实验室专用的 Splunk 索引中 | | `EventCode=4624` | 仅筛选出 Windows 成功登录的事件 | | `Logon_Type=7 OR Logon_Type=10` | 针对交互式(解锁)和 RDP 登录类型 | | `Source_Network_Address=40.*` | 筛选出外部源 IP(模拟公共互联网流量) | | `stats count by ...` | 根据时间戳、主机名、源 IP、用户和登录类型聚合事件 | 将搜索保存为 Alert(告警)并进行如下配置: | 设置 | 值 | |---|---| | Alert Name | `ADDC01-Unauthorized_Success_Login_Alert` | | Schedule | Cron: `* * * * *` (每分钟) | | Trigger Condition | Per result | | Trigger Action | Add to Triggered Alerts (severity: High) | 在 **Activity → Triggered Alerts** 中监控触发的告警。 ## 第 5 步 — 使用 Shuffle 与 Slack 集成的 SOAR Playbook ### 概述 该 playbook (`MyAutoADSpl`) 在告警触发时执行以下逻辑: ``` Splunk Alert ──► Shuffle Webhook ──► Slack Notification │ SOC Analyst Review │ [Disable User? Yes / No] │ Active Directory (LDAP) Disable Domain Account │ Verify Account Status │ Slack Confirmation Message ``` ### Shuffle 中的工作流设置 1. 登录到 [Shuffle](https://shuffler.io/) 并导航至 **Workflows → Create Workflow**。 2. 将工作流命名为 `MyAutoADSpl` 并保存。 ### 第 5a 步 — Splunk Webhook 触发器 在工作流内部,添加一个 **Webhook** 应用: - 名称:`Splunk-Alert` - 复制生成的 webhook URL。 在 Splunk 中,导航至 **Apps → Search and Reporting → Alerts → ADDC01-Unauthorized_Success_Login_Alert → Edit Alert → Trigger Actions → Add Action → Webhook** → 粘贴 Shuffle webhook URL → Save。 ### 第 5b 步 — Slack 通知 创建一个专用的 Slack 工作区和一个名为 `#alerts` 的私有频道,用于接收 SOC 通知。 在 Shuffle 工作流中,添加 **Slack** 应用: - 通过 OAuth 使用您的 Slack 账户进行身份验证。 - 将应用节点命名为:`SlackAlertNotification`。 - 配置消息的 **Text** 字段以包含来自 Splunk 告警负载的动态值: ``` 🚨 Unauthorized Login Detected Alert: ADDC01-Unauthorized_Success_Login_Alert Time: $exec.result._time User: $exec.result.user Source IP: $exec.result.Source_Network_Address ``` - 将 **Channel** 字段设置为您的 `#` 频道 ID(可从 Slack URL 获取)。 - 在工作流画布中将 **Splunk Webhook** 节点连接到 **SlackAlertNotification** 节点。 ### 第 5c 步 — 分析师决策(用户输入触发器) 添加一个 **User Input** 触发器,以引入人在回路中的审批步骤: - 名称:`User_Action` - 提示:`Would you like to disable this user?` - 输入方式:**Email** → 输入您的分析师电子邮件地址。 - 将 `User_Action` 连接到 `SlackAlertNotification` 节点。 ### 第 5d 步 — Active Directory 集成 (LDAP) 在 Vultr 防火墙中允许来自 Shuffle IP 的 LDAP 流量: **Vultr Firewall → Add rule → TCP → 端口 `389` → From Anywhere → Save** 将 **Active Directory** 应用添加到工作流并进行身份验证: | 字段 | 值 | |---|---| | Server | `` | | Port | `389` | | Domain | `Mylab` | | Username | Domain Admin | | Password | Domain Admin 密码 | | Base DN | *(在 PowerShell 中使用 `Get-ADDomain` 获取 → 复制 `UsersContainer` 值)* | | Use SSL | `False` | 配置 Active Directory 应用节点: - **Action:** `Disable User` - **SamAccountName:** `$exec.result.user` - **Search Base:** `` ### 第 5e 步 — 账户状态验证 添加第二个名为 `Get_User_Attributes` 的 **Active Directory** 应用节点,并将其连接到第一个 AD 节点。这在修复后获取用户的当前属性,以确认账户已被禁用。 添加一个名为 `Check_AD_User` 的 **Shuffle Tools** (Repeat Back to Me) 应用节点: - **Action:** `Repeat back to me` - **Call:** `Get_User_Attributes → UserAccountControl` 将 `Check_AD_User` 连接到 `Get_User_Attributes` 节点。 ### 第 5f 步 — Slack 中的修复确认 添加最后一个 **Slack** 应用节点以发送账户禁用操作的确认信息: - **Text:** `✅ Account $exec.result.user has been DISABLED.` - **Channel:** `<#alerts channel ID>` 使用以下 **线条件** (line condition) 将此节点连接到 `Check_AD_User`: ``` if $get_user_attributes.attributes.userAccountControl Contains "ACCOUNTDISABLED" ``` 这确保了只有在验证了账户在 Active Directory 中确实被禁用后,才会发送确认消息。 ## 工作流摘要 | 步骤 | 组件 | 动作 | |---|---|---| | 1 | Vultr | 配置 3 个云实例 (DC、测试机、Splunk) | | 2 | Vultr VPC + 防火墙 | 在私有网络上隔离实例,限制公共访问 | | 3 | Windows Server / AD | 提升 DC、创建域、加入端点、配置用户 | | 4 | Splunk + UF | 摄取 Windows 安全日志、构建检测查询、创建告警 | | 5 | Shuffle + Slack + AD | 自动化分析师通知和用户账户修复 | ## 安全注意事项 - 尽可能将防火墙规则限制为仅限您的 IP。第 4 步中公开的 RDP 仅为模拟目的而设——请在测试后还原此规则。 - 为所有域账户、Splunk 和 Shuffle 身份验证使用强大且唯一的密码。 - 本实验中的 LDAP 运行在端口 389(未加密)上。在生产环境中,请使用带有有效 SSL 证书的 **LDAPS (端口 636)**。 - 实验完成后轮换所有凭据。 ## 参考文献 - [Splunk 文档](https://docs.splunk.com/) - [Shuffle SOAR 文档](https://shuffler.io/docs) - [Microsoft Active Directory DS 概述](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/get-started/virtual-dc/active-directory-domain-services-overview) - [Vultr 文档](https://docs.vultr.com/) - [Windows 安全事件 ID 参考](https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/)
标签:Active Directory, AD域安全, AMSI绕过, Checkov, Home Lab, IAM, Plaso, SecOps, Shuffle, Slack集成, SOAR, SOC模拟, Terraform 安全, Ubuntu Server, VPC, Vultr, Windows Server 2022, 云安全架构, 云端部署, 受损账户恢复, 威胁检测, 安全运营, 安全运营中心, 家庭实验室, 扫描框架, 日志告警, 日志采集, 未授权登录检测, 目录服务攻击防护, 网络安全实验, 网络安全实验环境, 网络映射, 网络配置, 自动化剧本, 自动化响应, 自动化处置, 身份与访问管理, 违规登录检测, 防御规避检测