0x01 背景介绍

某企业的攻防演练,通过fofa找到该单位某系统,登陆界面进行测试,在返回包中发现了比较奇怪的cookie字段,remember-me,看到该字段推断大概率是shiro,被人为修改了cookie字段的默认值。
image.png

0x02 工具修改
目前用的比较多的shiro工具像shiro_attack、shiroexploit V3.0等,检测shiro都是发送rememberMe=1,然后检测返回包是否存在rememberMe=deleteMe来判断是否使用shiro框架,此处的shiro rememberMe字段被修改为remember-me,并且返回的字段不包含deleteMe,这就使得这些工具目前无法检测key。

由于对java不是很熟,此处选择一款python工具进行修改,工具地址:
https://github.com/Ares-X/shiro-exploit
全局替换rememberMe为remember-me,然后全局替换deleteMe为空,即可检测key

0x03 Bypass Waf
waf拦截shiro反序列化利用主要是两个地方,第一个是拦截rememberMe cookie
的长度,绕过方法就是缩小payload体积,具体参考:https://xz.aliyun.com/t/10824

第二个拦截策略是waf会解密rememberMe cookie,解密后查看是否存在恶意行为,bypass的策略就是防止cookie被解密,由于shiro的加解密方式用到的是base64+aes,只需要再payload中加入某些特殊字符,即可绕过waf,可用的字符为!、@、#(只要不出现BASE编码中可能出现的字符就行)。

修改shiro-exploit
增加混淆函数

def Bypass_waf(str_origin):
    str_list = list(str_origin)    # 字符串转list
    str_list.insert(20, '@')  # 在指定位置插入字符串
    str_list.insert(30, '@')
    str_out = ''.join(str_list)    # 空字符连接
    return  str_out

然后全局替换:
base64_ciphertext.decode() --> Bypass_waf(base64_ciphertext.decode())

Q.E.D.