amazed007/Adversary-Emulation-and-Detection-Engineering

GitHub: amazed007/Adversary-Emulation-and-Detection-Engineering

一个 SOC 家庭实验室项目,通过 Splunk 和 Sysmon 收集遥测数据,利用 Atomic Red Team 模拟攻击并开发行为检测规则。

Stars: 0 | Forks: 0

# 对抗模拟与检测工程实验室 **课程:** 信息安全与密码学 (CSE-802) **大学:** 达卡大学 **学生姓名:** Md Abdul Mazed **学号:** SH-60038 **注册号:** H-430 **批次:** 6 **助教:** Mukul Ahmed # 项目概述 本项目展示了一个用于对抗模拟和检测工程的安全运营中心 (SOC) 家庭实验室的实现。该实验室的目标是模拟真实世界的网络攻击,收集端点遥测数据,并使用基于行为的分析技术检测恶意活动。 实验室环境由两台虚拟机组成:一台作为受害端点的 Windows Server 2019 机器,以及一台托管 Splunk Enterprise 作为安全信息和事件管理 (SIEM) 平台的 Kali Linux 机器。Microsoft Sysmon 部署在 Windows Server 上以捕获详细的系统事件,而 Splunk Universal Forwarder 将这些日志发送到 Splunk 以进行集中监控和分析。 为了模拟真实的攻击者行为,使用 Atomic Red Team 框架执行了选定的 MITRE ATT&CK 技术,包括计划任务创建、MSHTA 执行、LSASS 凭据转储、PowerShell 下载摇篮执行和注册表修改。检测是使用 Sysmon Event ID 和 Splunk 搜索处理语言 (SPL) 查询来完成的。 # 目录 * 引言 * 背景 * 目标与目的 * 实验室范围 * 实验室环境 * 网络拓扑 * 系统架构 * 工具与技术 * Splunk Enterprise 安装 * Sysmon 安装 * Splunk Universal Forwarder 配置 * 数据收集配置 * 日志验证 * Atomic Red Team 安装 * 攻击模拟 * 检测工程 * SPL 检测查询 * 结果与讨论 * Sysmon 事件总结 * 结论 * 参考文献 # 1. 引言 ## 1.1 背景 网络威胁变得日益复杂,组织必须部署有效的监控和检测解决方案。安全运营中心 (SOC) 在识别恶意活动、分析安全事件以及响应网络安全事件方面发挥着至关重要的作用。 构建 SOC 家庭实验室为了解攻击是如何执行的,以及如何使用现代安全技术检测攻击提供了一个实用的环境。 本项目侧重于设计和实施虚拟 SOC 环境,以模拟对手技术并评估检测能力。 该实验室使用两台虚拟机构建: * Windows Server 2019(受害者机器) * Kali Linux(Splunk SIEM 服务器) 在 Windows Server 上安装了 Microsoft Sysmon 以捕获端点遥测数据,而 Splunk Universal Forwarder 将这些日志传输到 Splunk Enterprise 进行集中分析。 然后使用 Atomic Red Team 模拟多种 MITRE ATT&CK 技术,以生成真实的攻击遥测数据。 该项目没有依赖基于特征的检测,而是演示了如何使用 Sysmon Event ID 和 Splunk 搜索处理语言 (SPL) 进行基于行为的威胁狩猎。 ## 1.2 目标与目的 ### 目标 本项目的目标是建立一个安全运营中心 (SOC) 家庭实验室,能够模拟网络攻击,并通过集中收集日志和基于行为的分析来检测攻击。 ### 目的 * 使用 Oracle VirtualBox 构建一个隔离的 SOC 实验室。 * 部署 Windows Server 2019 和 Kali Linux 虚拟机。 * 安装 Splunk Enterprise。 * 配置 Splunk Universal Forwarder。 * 安装 Microsoft Sysmon。 * 生成端点遥测数据。 * 执行 Atomic Red Team 攻击模拟。 * 使用 Splunk SPL 查询检测攻击行为。 * 将检测结果与 MITRE ATT&CK 框架进行映射。 ## 1.3 实验室范围 本项目的范围包括: * 部署虚拟 SOC 环境 * Windows 端点监控 * 使用 Splunk Enterprise 实施 SIEM * 使用 Sysmon 收集端点遥测数据 * 使用 Atomic Red Team 进行威胁模拟 * 检测工程 * 威胁狩猎 * 日志分析 * MITRE ATT&CK 映射 该项目演示了对抗模拟、遥测收集、集中日志管理和安全监控的完整工作流程。 # 2. 实验室环境 整个实验室环境是使用 Oracle VirtualBox 创建的。 部署了两台虚拟机。 | 虚拟机 | 用途 | | ------------------- | ------------------ | | Windows Server 2019 | 受害端点 | | Kali Linux | Splunk SIEM 服务器 | Windows Server 使用 Microsoft Sysmon 生成遥测数据。 Splunk Universal Forwarder 不断将 Windows 日志转发到 Kali Linux SIEM。 Splunk Enterprise 对日志进行索引,并允许分析师通过 SPL 搜索调查攻击活动。 # 2.1 网络拓扑 两台虚拟机都连接到同一个 VirtualBox NAT 网络。 ``` +----------------------+ | Kali Linux VM | |----------------------| | Splunk Enterprise | | Port 8000 | | Port 9997 | +----------+-----------+ ^ | Splunk Universal Forwarder | v +----------------------+ | Windows Server 2019 | |----------------------| | Sysmon | | Atomic Red Team | +----------------------+ ``` Windows Server 通过端口 **9997** 将 Sysmon 日志转发到 Splunk,而 Splunk Web 界面可通过端口 **8000** 访问。 # 2.2 系统架构 监控工作流程遵循以下步骤: 1. Atomic Red Team 执行攻击技术。 2. Sysmon 记录端点事件。 3. Splunk Universal Forwarder 转发日志。 4. Splunk Enterprise 对遥测数据进行索引。 5. 分析师使用 SPL 查询执行检测。 6. 攻击行为被映射到 MITRE ATT&CK 框架。 ## 该架构演示了在隔离实验室环境中的端到端 SOC 监控和检测工作流程。 # 3. 工具与技术 以下工具和技术用于构建 SOC 家庭实验室。 | 工具 | 用途 | | -------------------------- | ----------------------- | | Oracle VirtualBox | 虚拟化平台 | | Kali Linux | Splunk SIEM 服务器 | | Windows Server 2019 | 受害者机器 | | Splunk Enterprise | SIEM 平台 | | Splunk Universal Forwarder | 日志转发 | | Microsoft Sysmon | 端点监控 | | Atomic Red Team | 攻击模拟 | | PowerShell | 攻击执行 | ## 3.1 Oracle VirtualBox Oracle VirtualBox 被用作虚拟化平台,以创建一个隔离的 SOC 环境。在同一个 NAT 网络内部署了两台虚拟机,以允许受害端点和 SIEM 服务器之间进行安全通信。 **作用** * 硬件虚拟化 * 网络隔离 * 资源管理 ## 3.2 Kali Linux Kali Linux 作为 SIEM 服务器。 在 Kali Linux 上安装了 Splunk Enterprise,用于接收 Windows 遥测数据、索引日志数据以及使用 SPL 查询执行威胁狩猎。 **作用** * Splunk Enterprise 服务器 * 日志收集 * 搜索与分析 ## 3.3 Windows Server 2019 Windows Server 2019 作为受害端点。 所有 Atomic Red Team 模拟都在这台机器上执行。 Sysmon 收集端点遥测数据,而 Splunk Universal Forwarder 将日志传输到 Splunk Enterprise。 **作用** * 受害端点 * 攻击模拟 * 日志生成 ## 3.4 Splunk Enterprise Splunk Enterprise 作为安全信息和事件管理 (SIEM) 平台。 其职责包括: * 接收 Windows 日志 * 索引事件 * 运行 SPL 查询 * 威胁狩猎 * 仪表板可视化 ### 安装 ``` cd ~/Downloads sudo tar xvzf splunk-*-linux-amd64.tgz -C /opt sudo /opt/splunk/bin/splunk start --accept-license sudo /opt/splunk/bin/splunk enable boot-start -user root ``` 启用接收端口 ``` sudo /opt/splunk/bin/splunk enable listen 9997 ``` 创建 Index ``` sudo /opt/splunk/bin/splunk add index win ``` Splunk Web 界面 ``` http://192.168.11.131:8000 ``` ## 3.5 Splunk Universal Forwarder Splunk Universal Forwarder 安装在 Windows Server 2019 上。 其主要职责是将 Windows 事件日志转发到 Splunk Enterprise。 ### 配置 ``` cd "C:\Program Files\SplunkUniversalForwarder\bin" .\splunk.exe add forward-server 192.168.11.131:9997 ``` Forwarder 服务 ``` SplunkForwarder ``` ## 3.6 Microsoft Sysmon Microsoft Sysmon 用于生成详细的端点遥测数据。 Sysmon 记录: * 进程创建 * 注册表修改 * 网络连接 * 进程访问 * 文件创建 * 驱动程序加载 ### 安装 ``` cd C:\Lab\Sysmon .\sysmon64.exe -accepteula -i sysmonconfig.xml ``` 验证安装 ``` Get-Service Sysmon64 ``` Sysmon 事件日志 ``` Microsoft-Windows-Sysmon/Operational ``` ## 3.7 Atomic Red Team Atomic Red Team 用于根据 MITRE ATT&CK 框架模拟攻击者行为。 它会生成可使用 SIEM 检测到的真实端点活动。 # 4. 实验室设置与配置 实验室环境包括: * Windows Server 2019 * Kali Linux * Splunk Enterprise * Sysmon * Universal Forwarder 目标是从 Windows 收集端点遥测数据,并在 Splunk 中进行分析。 # 4.1 安装 Splunk Enterprise Splunk Enterprise 安装在 Kali Linux 虚拟机上。 ### 命令 ``` cd ~/Downloads sudo tar xvzf splunk-*-linux-amd64.tgz -C /opt sudo /opt/splunk/bin/splunk start --accept-license sudo /opt/splunk/bin/splunk enable boot-start -user root ``` 启用接收器 ``` sudo /opt/splunk/bin/splunk enable listen 9997 ``` 创建 Index ``` sudo /opt/splunk/bin/splunk add index win ``` # 4.2 安装 Sysmon Sysmon 安装在 Windows Server 2019 上。 命令 ``` cd C:\Lab\Sysmon .\sysmon64.exe -accepteula -i sysmonconfig.xml ``` 验证 ``` Get-Service Sysmon64 ``` # 4.3 配置 Splunk Universal Forwarder 安装后,配置了 Universal Forwarder 以将遥测数据发送到 Splunk。 配置命令 ``` cd "C:\Program Files\SplunkUniversalForwarder\bin" .\splunk.exe add forward-server 192.168.11.131:9997 ``` # 4.4 配置数据收集 **inputs.conf** 文件配置如下。 ``` [WinEventLog://Microsoft-Windows-Sysmon/Operational] disabled = 0 index = win renderXml = true [WinEventLog://Microsoft-Windows-PowerShell/Operational] disabled = 0 index = win renderXml = true [WinEventLog://Security] disabled = 0 index = win ``` 重启 Forwarder ``` .\splunk.exe restart ``` # 4.5 验证日志收集 执行以下 SPL 查询以验证遥测数据是否成功收集。 ### 验证主机 ``` index=win | stats count by host,sourcetype ``` ### 验证 Event ID ``` index=win | stats count by EventCode ``` ### 验证进程创建 ``` index=win EventCode=1 | table _time Computer Image CommandLine ``` Windows 事件日志在 Splunk 中的成功出现证实了: * Sysmon 正在生成遥测数据。 * Universal Forwarder 正在转发日志。 * Splunk Enterprise 正在对事件进行成功索引。 # 5. Atomic Red Team 安装 Atomic Red Team 是一个开源的对抗模拟框架,提供映射到 MITRE ATT&CK 框架的小型、针对性测试。它允许安全分析师通过安全地模拟常见的攻击者技术来验证检测能力。 ## 5.1 安装 Invoke-AtomicRedTeam 以 **管理员** 身份打开 **Windows PowerShell** 并执行以下命令: ``` Set-ExecutionPolicy Bypass -Scope CurrentUser -Force IEX (IWR 'https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicredteam.ps1' -UseBasicParsing) Install-AtomicRedTeam -getAtomics -Force Import-Module "C:\AtomicRedTeam\invoke-atomicredteam\Invoke-AtomicRedTeam.psd1" -Force ``` ## 5.2 PowerShell 配置 为了允许执行 Atomic Red Team 测试: ``` Set-ExecutionPolicy Bypass -Scope CurrentUser -Force ``` 验证安装: ``` Get-Module Invoke-AtomicRedTeam -ListAvailable ``` ## 5.3 Windows Defender 排除项 某些 Atomic Red Team payload 会被 Windows Defender 检测到。仅用于实验室测试,添加了一个排除路径。 ``` Add-MpPreference -ExclusionPath "C:\AtomicRedTeam" ``` # 6. 攻击模拟 (Red Team) 执行了以下 MITRE ATT&CK 技术以生成攻击遥测数据。 ## 6.1 T1053.005 – 计划任务 (Persistence) ### 描述 该技术创建一个计划任务,在系统重启后自动执行恶意代码以维持 Persistence。 ### 显示测试信息 ``` Invoke-AtomicTest T1053.005 -ShowDetailsBrief ``` ### 执行测试 ``` Invoke-AtomicTest T1053.005 -TestNumbers 1 ``` ### 预期结果 * 创建计划任务 * 生成 Sysmon Event ID 1 * 可通过 `schtasks.exe` 检测 ## 6.2 T1218.005 – MSHTA (Defense Evasion) ### 描述 MSHTA 执行 HTA 应用程序和 JavaScript payload 以绕过应用程序控制机制。 ### 显示测试 ``` Invoke-AtomicTest T1218.005 -ShowDetailsBrief ``` ### 执行测试 ``` Invoke-AtomicTest T1218.005 -TestNumbers 1 ``` ### 预期结果 * 启动 `mshta.exe` * 执行 HTA 或 JavaScript payload * 生成 Sysmon Event ID 1 ## 6.3 T1003.001 – LSASS 内存转储 (Credential Access) ### 描述 该技术尝试转储 LSASS 进程的内存以获取用户凭据。 ### 下载前置条件 ``` Invoke-AtomicTest T1003.001 -TestNumbers 1 -GetPrereqs ``` ### 执行测试 ``` Invoke-AtomicTest T1003.001 -TestNumbers 1 ``` ### 预期结果 * ProcDump 访问 `lsass.exe` * 生成 Sysmon Event ID 10 * 记录可疑的 GrantedAccess 值 ## 6.4 T1059.001 – PowerShell 下载摇篮 (Execution) ### 描述 PowerShell 直接在内存中下载并执行远程脚本。 ### 显示测试 ``` Invoke-AtomicTest T1059.001 -ShowDetailsBrief ``` ### 执行测试 ``` Invoke-AtomicTest T1059.001 -TestNumbers 1 ``` ### 预期结果 * 启动 PowerShell * 已下载远程脚本 * 生成 Sysmon Event ID 1 * 生成 PowerShell Event ID 4104 ## 6.5 T1112 – 注册表修改 (Defense Evasion) ### 描述 修改注册表值以禁用安全控制或建立 Persistence。 ### 显示测试 ``` Invoke-AtomicTest T1112 -ShowDetailsBrief ``` ### 执行测试 ``` Invoke-AtomicTest T1112 -TestNumbers 3,5 ``` ### 预期结果 * 修改注册表值 * 更改 Windows Defender 设置 * 创建受信任站点条目 * 生成 Sysmon Event ID 13 # 测试后清理 完成所有攻击模拟后,执行了清理命令以恢复环境。 ``` Invoke-AtomicTest T1053.005,T1218.005,T1003.001,T1059.001,T1112 -Cleanup ``` # 攻击摘要 | MITRE ID | 技术 | 战术 | 主要检测来源 | | | -------------------------- | ----------------- | ----------------------------------- | | T1053.005 | 计划任务 | Persistence | Sysmon Event ID 1 | | T1218.005 | MSHTA | Defense Evasion | Sysmon Event ID 1 | | T1003.001 | LSASS 转储 | Credential Access | Sysmon Event ID 10 | | T1059.001 | PowerShell 下载摇篮 | Execution | Sysmon Event ID 1 + PowerShell 4104 | | T1112 | 注册表修改 | Defense Evasion | Sysmon Event ID 13 | # 攻击工作流 ``` Atomic Red Team │ ▼ Windows Server 2019 │ ▼ Microsoft Sysmon │ ▼ Splunk Universal Forwarder │ ▼ Splunk Enterprise │ ▼ Threat Detection using SPL Queries ``` # 7. 检测与分析 (Blue Team) 执行 Atomic Red Team 测试后,所有生成的遥测数据均通过 Splunk Universal Forwarder 转发到 Splunk Enterprise。检测是使用基于行为的搜索处理语言 (SPL) 查询完成的,而不是搜索特定的工具名称。 Splunk Add-on for Microsoft Sysmon 将原始 XML 日志解析为可搜索的字段,例如: * Image * CommandLine * ParentImage * TargetImage * TargetObject * GrantedAccess 这些字段实现了对恶意行为的有效检测。 ## 7.1 攻击概述 在单独分析每个攻击之前,执行以下查询以验证 Sysmon 是否已捕获攻击工具。 ``` index=win EventCode=1 (Image="*schtasks.exe" OR Image="*mshta.exe" OR Image="*powershell.exe" OR Image="*reg.exe" OR Image="*cmd.exe") | stats count by Image ``` 此查询确认所有与攻击相关的进程均已成功记录。 # 7.2 计划任务检测 (T1053.005) ### 检测逻辑 检测使用 **schtasks.exe** 创建计划任务。 ### SPL 查询 ``` index=win source="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 Image="*\\schtasks.exe" CommandLine="*/create*" | table _time, Computer, User, Image, CommandLine, ParentImage ``` ### 检测结果 * 进程:schtasks.exe * 已捕获命令行 * 已识别父进程 * 检测到 Persistence 活动 ### 最有用的 Event ID **Sysmon Event ID 1 – 进程创建** # 7.3 MSHTA 检测 (T1218.005) ### 检测逻辑 检测用于绕过应用程序控制的 **mshta.exe** 的执行。 ### SPL 查询 ``` index=win source="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 Image="*\\mshta.exe" | table _time, Computer, User, Image, CommandLine, ParentImage ``` ### 检测结果 * mshta.exe 已执行 * 已识别父进程 * 可见 HTA payload * 检测到 Defense Evasion ### 最有用的 Event ID **Sysmon Event ID 1** # 7.4 LSASS 转储检测 (T1003.001) ### 检测逻辑 检测对 **lsass.exe** 的可疑访问。 ### SPL 查询 ``` index=win source="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=10 TargetImage="*\\lsass.exe" | table _time, Computer, SourceImage, TargetImage, GrantedAccess, CallTrace ``` ### 检测结果 * 已识别源进程 * 已识别目标进程 * 已记录 GrantedAccess 值 * 检测到凭据转储 ### 最有用的 Event ID **Sysmon Event ID 10 – 进程访问** # 7.5 PowerShell 下载摇篮检测 (T1059.001) ### 检测逻辑 检测 PowerShell 正在下载和执行远程脚本。 ### SPL 查询 ``` index=win source="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 Image="*\\powershell.exe" (CommandLine="*DownloadString*" OR CommandLine="*Net.WebClient*" OR CommandLine="*Invoke-WebRequest*" OR CommandLine="*IEX*") | table _time, Computer, User, Image, CommandLine, ParentImage ``` ### 备用 PowerShell 检测 ``` index=win source="XmlWinEventLog:Microsoft-Windows-PowerShell/Operational" EventCode=4104 (ScriptBlockText="*DownloadString*" OR ScriptBlockText="*Net.WebClient*" OR ScriptBlockText="*IEX*") | table _time, Computer, ScriptBlockText ``` ### 检测结果 * 检测到 PowerShell 执行 * 观察到 DownloadString * 观察到 IEX * 检测到远程 payload 执行 ### 最有用的 Event ID * Sysmon Event ID 1 * PowerShell Event ID 4104 # 7.6 注册表修改检测 (T1112) ### 检测逻辑 检测影响 Windows Defender、受信任站点和凭据存储的可疑注册表修改。 ### SPL 查询 ``` index=win source="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=13 (TargetObject="*DisableAntiSpyware*" OR TargetObject="*DisableRealtimeMonitoring*" OR TargetObject="*ZoneMap*" OR TargetObject="*Winlogon*" OR TargetObject="*\\Windows Defender\\*") | table _time, Computer, Image, TargetObject, Details ``` ### 检测结果 * 已捕获注册表路径 * 已捕获注册表值 * 已识别 Image * 检测到 Defense Evasion ### 最有用的 Event ID **Sysmon Event ID 13 – 注册表值设置** # 8. 检测查询总结 | 技术 | 检测查询 | Event ID | | -------------- | -------------------- | ----------------- | | 计划任务 | schtasks.exe | Event ID 1 | | MSHTA | mshta.exe | Event ID 1 | | LSASS 转储 | lsass.exe | Event ID 10 | | PowerShell | DownloadString / IEX | Event ID 1 & 4104 | | 注册表 | TargetObject | Event ID 13 | # MITRE ATT&CK 映射 | 技术 ID | 技术 | 战术 | 检测来源 | | ------------ | -------------------------- | ----------------- | --------------------------------- | | T1053.005 | 计划任务 | Persistence | Sysmon Event ID 1 | | T1218.005 | MSHTA | Defense Evasion | Sysmon Event ID 1 | | T1003.001 | LSASS 转储 | Credential Access | Sysmon Event ID 10 | | T1059.001 | PowerShell 下载摇篮 | Execution | Sysmon Event ID 1 + Event ID 4104 | | T1112 | 注册表修改 | Defense Evasion | Sysmon Event ID 13 | # 检测工作流 ``` Attack Simulation │ ▼ Sysmon Telemetry │ ▼ Universal Forwarder │ ▼ Splunk Enterprise │ ▼ SPL Detection Query │ ▼ Threat Detection │ ▼ MITRE ATT&CK Mapping ``` # 关键检测能力 ✔ 进程创建监控 ✔ 凭据转储检测 ✔ 注册表监控 ✔ PowerShell 监控 ✔ 威胁狩猎 ✔ 基于行为的检测 ✔ MITRE ATT&CK 映射 ✔ 端点可见性
标签:AI合规, Atomic Red Team, Sysmon, 安全实验环境, 安全运营中心, 数据泄露检测, 知识库安全, 管理员页面发现, 网络映射