<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>MIPS on PseudorandomDog&#39;s Blog</title>
    <link>https://binarydog.top/tags/mips/</link>
    <description>Recent content in MIPS on PseudorandomDog&#39;s Blog</description>
    <generator>Hugo</generator>
    <language>zh-CN</language>
    <lastBuildDate>Mon, 11 Nov 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://binarydog.top/tags/mips/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>强网杯S8</title>
      <link>https://binarydog.top/posts/ctf/%E5%BC%BA%E7%BD%91%E6%9D%AFs8/</link>
      <pubDate>Mon, 11 Nov 2024 00:00:00 +0000</pubDate>
      <guid>https://binarydog.top/posts/ctf/%E5%BC%BA%E7%BD%91%E6%9D%AFs8/</guid>
      <description>&lt;h2 class=&#34;heading&#34; id=&#34;mips&#34;&gt;&#xA;  mips&#xA;  &lt;a class=&#34;anchor&#34; href=&#34;#mips&#34;&gt;#&lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Someone has found the mips binary, along with an emulator to execute it. What can you find in them?&#xA;&#xA;USAGE：./emu ./mips_bin&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;32 位大端 mips 程序，拖到 IDA 里即可&lt;/p&gt;&#xA;&lt;p&gt;程序会在 0x23000 处开辟一个可执行空间，写入解密的机器码，然后执行&lt;/p&gt;&#xA;&lt;p&gt;这样得到的 flag 是 &lt;code&gt;flag{dynamic_reverse}&lt;/code&gt;，是个假的 flag，交不上&lt;/p&gt;&#xA;&lt;p&gt;一开始的想法是 emu 在加载时动态修改了程序，故修补程序使之在结束时打印字节码的内容，没有收获，但有个意外发现：在跳到 0x23000 前的 write 函数可以调用成功，之后的所有 patch 全都失效了&lt;/p&gt;&#xA;&lt;p&gt;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&lt;figure class=&#34;&#34;&gt;&#xA;&#xA;    &lt;div class=&#34;img-container&#34; &gt;&#xA;        &lt;img loading=&#34;lazy&#34; alt=&#34;&#34; src=&#34;https://binarydog.top/images/image-1763913623463.webp&#34; &gt;&#xA;    &lt;/div&gt;&#xA;&#xA;    &#xA;&lt;/figure&gt;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;所以推测是 emu 在 0x23000 或那条 if 语句处下了钩子&lt;/p&gt;&#xA;&lt;p&gt;IDA 打开 emu 直接搜索 0x23000 立即数&lt;/p&gt;&#xA;&lt;p&gt;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&lt;figure class=&#34;&#34;&gt;&#xA;&#xA;    &lt;div class=&#34;img-container&#34; &gt;&#xA;        &lt;img loading=&#34;lazy&#34; alt=&#34;&#34; src=&#34;https://binarydog.top/images/image-1763913777897.webp&#34; &gt;&#xA;    &lt;/div&gt;&#xA;&#xA;    &#xA;&lt;/figure&gt;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;定位到 hook 的地方，这里有一个独立的检测，对 encrypt 的参数下交叉引用可以找到检测 flag 前缀的代码，推测出参数就是输入&lt;/p&gt;&#xA;&lt;p&gt;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&lt;figure class=&#34;&#34;&gt;&#xA;&#xA;    &lt;div class=&#34;img-container&#34; &gt;&#xA;        &lt;img loading=&#34;lazy&#34; alt=&#34;&#34; src=&#34;https://binarydog.top/images/image-1763913914588.webp&#34; &gt;&#xA;    &lt;/div&gt;&#xA;&#xA;    &#xA;&lt;/figure&gt;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;encrypt 函数是一个稍微有点绕的魔改 RC4，KSA 部分使用乘以常数来优化了除法，实际上 KSA 和标准实现一致（见注释），PRGA 也一致，只是最后的加密多做了一些 XOR&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
