rakhaaryaramadhan/SOC-HOMELAB-MINI
GitHub: rakhaaryaramadhan/SOC-HOMELAB-MINI
基于 VirtualBox 和 Splunk SIEM 搭建的 SOC 家庭实验室,模拟从攻击发起、日志收集、威胁检测到告警分类与事件报告的完整安全运营工作流。
Stars: 0 | Forks: 0
# SOC 家庭实验室 — Splunk SIEM 与威胁检测
## 项目概述
本项目模拟了一个完全在个人笔记本电脑上使用 VirtualBox 搭建的真实安全运营中心(SOC)环境。该实验室展示了端到端的 SOC L1 工作流:使用 Kali Linux 发起攻击,通过 Splunk Universal Forwarder 收集日志,在 Splunk SIEM 中检测威胁,对告警进行分类,并将发现记录在事件报告中——重现了 SOC L1 分析师核心的日常任务。
## 目标
- 使用免费和开源工具搭建一个功能完备的 SOC 家庭实验室
- 在受控环境中模拟真实攻击(暴力破解、端口扫描)
- 将来自多个端点的安全日志收集并集中到 Splunk SIEM 中
- 在 Splunk 中创建自动化检测规则(告警)
- 检测、分类并将告警划分为 True Positive 或 False Positive
- 使用行业标准的事件报告格式记录发现
- 将检测到的攻击映射到 MITRE ATT&CK 框架
## 实验室架构
```
+-------------------+ Attacks +----------------------+
| Kali Linux | --------------------> | Ubuntu 22.04 |
| 192.168.100.10 | | 192.168.100.30 |
| (Red Team / | Logs | Splunk Enterprise |
| Attacker) | <-------------------- | (SIEM / Defender) |
+-------------------+ +----------------------+
| ^
| Attacks | Logs (port 9997)
v |
+-------------------+ +----------------------+
| Windows 10 | --------------------> | |
| 192.168.100.20 | Splunk UF (logs) | |
| (Endpoint) | | |
+-------------------+ +----------------------+
Network: VirtualBox Internal Network — all VMs isolated and interconnected
```
## 工具与技术
| 工具 | 版本 | 用途 |
|---|---|---|
| VirtualBox | 7.x | 虚拟化平台 |
| Kali Linux | 2024.x | 攻击机 / Red Team |
| Windows 10 | 21H2 | 端点 / 日志源 |
| Ubuntu Desktop | 22.04 LTS | Splunk SIEM 服务器 |
| Splunk Enterprise | 9.2.1 | SIEM — 日志收集与分析 |
| Splunk Universal Forwarder | 10.4.0 | Windows 上的日志转发 agent |
| Hydra | 9.6 | 暴力破解模拟工具 |
| Nmap | 7.98 | 网络探测模拟 |
## 环境配置
### 网络配置
所有三台虚拟机均通过 VirtualBox 内部网络连接,以实现隔离通信。
**Kali Linux(攻击机)**
```
sudo ip addr add 192.168.100.10/24 dev eth0
sudo ip link set eth0 up
ip a
ping 192.168.100.20 # verify connectivity to Windows
ping 192.168.100.30 # verify connectivity to Ubuntu
```
**Windows 10(端点)**
- 打开网络设置 → 更改适配器选项 → IPv4 属性
- 静态 IP:`192.168.100.20` | 子网掩码:`255.255.255.0`
**Ubuntu(Splunk 服务器)**
```
sudo ip addr add 192.168.100.30/24 dev enp0s3
sudo ip link set enp0s3 up
```
## 安装与配置
### 1. 在 Ubuntu 上安装 Splunk Enterprise
```
curl -L -o splunk.deb "https://download.splunk.com/products/splunk/releases/9.2.1/linux/splunk-9.2.1-78803f08aabb-linux-2.6-amd64.deb"
sudo dpkg -i splunk.deb
sudo /opt/splunk/bin/splunk start --accept-license
# Dashboard: http://localhost:8000
```
### 2. 启用接收与监控日志源
```
# 启用端口 9997 以接收来自 forwarders 的日志
sudo /opt/splunk/bin/splunk enable listen 9997 -auth admin:yourpassword
# 监控 Ubuntu SSH 身份验证日志
sudo /opt/splunk/bin/splunk add monitor /var/log/auth.log \
-index main -sourcetype linux_secure -auth admin:yourpassword
sudo /opt/splunk/bin/splunk restart
```
### 3. 在 Windows 10 上安装 Splunk Universal Forwarder
从 splunk.com 下载 `splunkforwarder-10.4.0.msi`,并使用以下配置进行安装:
- 接收索引器 (Receiving Indexer):`192.168.100.30:9997`
配置 Windows 事件日志转发(以管理员身份运行 PowerShell):
```
cd "C:\Program Files\SplunkUniversalForwarder\bin"
$content = @"
[WinEventLog://Security]
disabled = 0
index = main
[WinEventLog://System]
disabled = 0
index = main
[WinEventLog://Application]
disabled = 0
index = main
"@
$content | Out-File -FilePath "C:\Program Files\SplunkUniversalForwarder\etc\system\local\inputs.conf" -Encoding ASCII
.\splunk add forward-server 192.168.100.30:9997 -auth admin:yourpassword
Start-Service SplunkForwarder
```
### 4. 验证日志接入
```
index=main sourcetype="WinEventLog*"
```
**结果:** 成功接入 14,000+ 条 Windows 事件 ✅
## 攻击模拟与检测
### 攻击 1 — SSH 暴力破解 (MITRE T1110.001)
**目标:** 模拟暴力破解攻击并在 Splunk 中进行检测。
**在 Ubuntu 上启用 SSH:**
```
sudo apt install openssh-server -y
sudo systemctl start ssh && sudo systemctl enable ssh
```
**从 Kali Linux 执行:**
```
sudo gunzip /usr/share/wordlists/rockyou.txt.gz
hydra -l ubuntu -P /usr/share/wordlists/rockyou.txt 192.168.100.30 ssh -t 4
```
**检测查询:**
```
index=main "Failed password" | stats count by host | sort -count
```
**结果:** 检测到来自 `192.168.100.10` 的 **2,586 次失败登录尝试** ✅
### 攻击 2 — 网络探测 / 端口扫描 (MITRE T1046)
**目标:** 模拟攻击者在发起攻击前的探测行为。
**从 Kali Linux 执行:**
```
nmap -sS -p 1-1000 192.168.100.30
```
**结果:**
```
PORT STATE SERVICE
22/tcp open ssh
999 ports closed
```
**发现:** 攻击者发现了开放的 22 端口 (SSH) —— 作为后续暴力破解攻击的基础。这展示了完整的攻击链:探测 (Reconnaissance) → 凭证获取。
## 自动化告警 — 检测规则
创建了 Splunk 定时告警,以自动检测暴力破解活动:
| 设置 | 值 |
|---|---|
| 告警名称 | Brute Force SSH Detected |
| 计划任务 | Cron:`5 * * * *`(每小时的第 5 分钟) |
| 时间范围 | 过去 5 分钟 |
| 查询 | `index=main "Failed password" earliest=-5m \| stats count by host \| where count > 10` |
| 触发条件 | 结果数 > 0 |
| 严重程度 | 高 |
| 操作 | 添加到 Triggered Alerts |
**告警触发时间:** 2026-06-10 04:05:03 ✅
## 告警分类流程
当告警触发时,执行完整的 L1 分类流程:
### 第一步 — 确认来源 IP
```
index=main "Failed password" | rex "from (?\d+\.\d+\.\d+\.\d+)" | stats count by src_ip | sort -count
```
**发现:** `192.168.100.10` — 尝试 2,586 次
### 第二步 — 检查是否存在成功的登录
```
index=main "Accepted password" | rex "from (?\d+\.\d+\.\d+\.\d+)" | stats count by src_ip
```
**发现:** ⚠️ 来自攻击者 IP 的 2 次成功登录 —— **系统已被攻破**
### 第三步 — 获取确切的时间戳
```
index=main "Accepted password" | rex "from (?\d+\.\d+\.\d+\.\d+)" | table _time, src_ip, host
```
**发现:** 成功登录的时间为 `03:39:02` 和 `04:07:43`
### 最终结论
| 字段 | 值 |
|---|---|
| 告警分类 | **True Positive** |
| 系统已被攻破 | **YES** |
| 决策 | **升级至 L2** |
## 事件报告
完整事件报告请见:[`reports/incident-report-001.md`](reports/incident-report-001.md)
**摘要:**
- **事件 ID:** IR-2026-001
- **严重程度:** HIGH
- **攻击类型:** SSH 暴力破解 — 尝试 2,586 次
- **结果:** 系统被攻破 — 2 次未经授权的登录
- **MITRE ATT&CK:** T1110.001 (Brute Force), T1046 (Network Service Discovery), T1133 (External Remote Services)
- **行动:** 升级至 L2
## Splunk SPL 查询参考
```
# 所有日志
index=main
# SSH 登录失败
index=main "Failed password"
# 按源 IP 统计的失败登录
index=main "Failed password" | rex "from (?\d+\.\d+\.\d+\.\d+)" | stats count by src_ip | sort -count
# 成功登录
index=main "Accepted password" | rex "from (?\d+\.\d+\.\d+\.\d+)" | table _time, src_ip, host
# Windows 登录失败 (EventCode 4625)
index=main EventCode=4625
# Windows 登录成功 (EventCode 4624)
index=main EventCode=4624
# Brute force 检测规则
index=main "Failed password" earliest=-5m | stats count by host | where count > 10
```
## 核心结果
| # | 攻击类型 | 攻击者 IP | 目标 | 事件数 | 是否成功 | MITRE | 结论 |
|---|---|---|---|---|---|---|---|
| 1 | SSH 暴力破解 | 192.168.100.10 | 192.168.100.30:22 | 2,586 | YES (2次) | T1110.001 | True Positive — 已升级 |
| 2 | 端口扫描 | 192.168.100.10 | 192.168.100.30 | 发现 22 端口 | N/A | T1046 | True Positive |
## 展现的技能
- 虚拟化多虚拟机 SOC 实验室搭建
- Splunk Enterprise 部署与配置
- 接入来自 Windows (Splunk UF) 和 Linux (auth.log) 的日志
- 编写用于威胁检测的 SPL 查询
- 自动化告警的创建与调度
- 告警分类 — True Positive 与 False Positive 分析
- 事件记录与升级决策
- MITRE ATT&CK 框架映射
- 使用 Hydra 和 Nmap 进行攻击模拟
## 项目结构
```
SOC-HomeLab-Splunk/
├── README.md
├── screenshots/
│ ├── splunk-dashboard.png
│ ├── windows-logs-14k-events.png
│ ├── brute-force-2586-events.png
│ ├── triggered-alert.png
│ ├── triage-source-ip.png
│ ├── successful-logins.png
│ └── nmap-scan-result.png
├── configs/
│ ├── inputs.conf
│ └── splunk-queries.spl
└── reports/
└── incident-report-001.md
```
## 作者
**Rakha Arya Ramadhan**
信息技术专业毕业生 — 信息工程(网络安全)
雅加达国立科学与技术学院 (Institut Sains dan Teknologi Nasional Jakarta)
- LinkedIn:https://www.linkedin.com/in/rakha-arya-ramadhan-
- GitHub:https://github.com/rakhaaryaramadhan
标签:AMSI绕过, CTI, OPA, 威胁检测, 安全运营, 安全运营中心, 库, 应急响应, 扫描框架, 插件系统, 网络映射, 靶场