Alpi157/soc-threat-detection-repo
GitHub: Alpi157/soc-threat-detection-repo
基于 Splunk 的微型 SOC 实验室,演示多源日志采集、攻击检测与事件响应的完整流程。
Stars: 0 | Forks: 0
# 使用 Splunk 进行 SOC 威胁检测与调查
**作者**:Alpar Arman
**日期**:2025 年 4 月
## 项目目的
在单台笔记本电脑规模的实验室中构建一个微型 SOC,以展示以下能力:
- 使用 Splunk 采集多平台日志(Windows Sysmon + Apache)
- 生成真实的攻击(SSH 暴力破解、Web 枚举、POST 数据外泄)
- 在实时仪表板中检测并可视化这些攻击
- 触发自动警报并概述逻辑事件响应工作流
## 高级架构
VirtualBox 网络 `192.168.56.0/24`(Host-Only)+ 用于更新的 NAT:
| 机器 | 软件详情 |
|----------------------|-----------------------------------------------------------|
| **Ubuntu 22.04** | Splunk Enterprise 9.4 (indexer) |
| | - Universal Forwarder:在 TCP 9997 端口接收 |
| | - Apache 2.4:访问 / 错误日志 → UF → Splunk |
| | - IP: 192.168.56.105 |
| **Windows 10 Home** | Sysmon 15.15 (SwiftOnSecurity 配置) |
| | - OpenSSH Server:安全 + Sysmon → UF → Splunk |
| | - IP: 192.168.56.106 |
| **Kali 2024.1** | Hydra 9.5, Gobuster 3.6, curl, nmap |
| | - IP: 192.168.56.103 |
**所有日志均以 `index=main` 在 Splunk 中建立索引,其 sourcetypes 如下**:
- `WinEventLog:Security`
- `XmlWinEventLog:Microsoft-Windows-Sysmon/Operational`
- `apache:access`
- `apache:error`
## 快速入门
### 前置条件
- 已启用 Host-Only 网络的 VirtualBox ≥7
- 3 个虚拟机(VM)需要 8 GB 的可用内存(RAM)
- Splunk Enterprise Linux `.deb` 安装程序(免费许可证)
### 克隆仓库
```
git clone https://github.com//soc-splunk-lab.git
```
导入三个 OVA 模板或从 ISO 构建,然后按照 `docs/setup-steps.txt` 进行操作。
### 在 Ubuntu 上启动 Splunk
```
sudo /opt/splunk/bin/splunk start --accept-license
sudo /opt/splunkforwarder/bin/splunk start
```
*(在 Windows 和 Ubuntu 上均适用于 forwarder)*
### 验证数据流
转到 Splunk UI → Search & Reporting → 并运行:
```
index=main | stats count by sourcetype
```
确认数据正在正确流入 Splunk。
## 攻击模拟
- **SSH 暴力破解**:
hydra -l arman -P rockyou.txt ssh://192.168.56.106
- **Web 目录爆破**:
gobuster dir -u http://192.168.56.105/ -w /usr/share/wordlists/dirb/common.txt
- **POST 洪水(数据外泄)**:
for i in {1..500}; do curl -X POST -d "ex$i" http://192.168.56.105/; done
## 检测逻辑(核心 SPL 代码片段)
- **登录失败激增**:
index=main EventCode=4625
| bin _time span=5m
| stats count
| where count>100
- **404 激增**:
index=main sourcetype=apache:access status=404
| bin _time span=5m
| stats count
- **POST 激增**:
index=main sourcetype=apache:access "POST"
| bin _time span=1m
| stats count
## 仪表板和警报
### 仪表板:SOC 威胁检测
- **面板 1**:受攻击次数最多的用户名(柱状图)
- **面板 2**:随时间变化的 404 错误(折线图)
- **面板 3**:随时间变化的可疑 POST 请求(折线图)
### 警报(SavedSearches)
- **检测到暴力破解**:
- 计划:每 5 分钟一次(`cron */5 * * * *`)
- 触发条件:5 分钟内 EventCode 4625 计数 >100
- **404 洪水**:
- 计划:每 5 分钟一次
- 触发条件:5 分钟内状态码 404 计数 >20
## 事件响应重点
- 在 Windows 上使用 `netsh advfirewall` 封禁暴力破解 IP
- 在 Ubuntu 上使用 `iptables` 丢弃枚举 IP
- 使用 Apache `mod_evasive` 对 POST 大小进行限流
- 完整的响应步骤记录在 `IR_Playbook.md` 中
## 仓库结构图
```
dashboards/ # JSON exports of all Splunk panels
spl/ # All SPL queries (detections, alerts)
evidence/ # Screenshots of alerts and dashboards
IR_Playbook.md # Detailed incident-response steps
README.md # This file
SOC_Threat_Detection_Report.md # Formal report
```
## 经验总结
- 自定义字段提取对于准确的 Apache 分析是**强制性的**。
- Sysmon 需要**完整的握手**;IDS 或 Zeek 更适合处理 SYN 扫描噪声。
- 在向招聘人员演示时,**小型、专注的仪表板**的表现优于庞大、复杂的仪表板。
- 如果裁剪掉不必要的 Windows 日志,**500 MB/天**的免费 Splunk 许可证就足够了。
标签:AMSI绕过, 入侵与防御, 威胁检测, 安全实验室, 安全运营中心, 密码管理, 日志收集, 网络映射