<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Vm on bitfriends' blog</title><link>https://b17fr13nds.github.io/tags/vm/</link><description>Recent content in Vm on bitfriends' blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 24 Nov 2024 14:53:47 +0100</lastBuildDate><atom:link href="https://b17fr13nds.github.io/tags/vm/index.xml" rel="self" type="application/rss+xml"/><item><title>TOY/2 - SECCON CTF 13</title><link>https://b17fr13nds.github.io/posts/seccon_toy2/</link><pubDate>Sun, 24 Nov 2024 14:53:47 +0100</pubDate><guid>https://b17fr13nds.github.io/posts/seccon_toy2/</guid><description>&lt;h2 id="toy2"&gt;
 &lt;strong&gt;TOY/2:&lt;/strong&gt;
 &lt;a class="heading-link" href="#toy2"&gt;
 &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;
 &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;
 &lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;This weekend we played as P1G SEKAI and managed to qualify to the finals. TOY/2 was a challenge I solved.&lt;/p&gt;
&lt;p&gt;In this challenge we&amp;rsquo;re given a C++ binary that emulates some 16-bit architecture.&lt;/p&gt;
&lt;p&gt;It had several instructions, one of them included an OOB bug:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff7b72"&gt;case&lt;/span&gt; &lt;span style="color:#a5d6ff"&gt;13&lt;/span&gt;&lt;span style="color:#ff7b72;font-weight:bold"&gt;:&lt;/span&gt; &lt;span style="color:#8b949e;font-style:italic"&gt;/* STT */&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; mem_write(_regs.a &lt;span style="color:#ff7b72;font-weight:bold"&gt;&amp;amp;&lt;/span&gt; (size() &lt;span style="color:#ff7b72;font-weight:bold"&gt;-&lt;/span&gt; &lt;span style="color:#a5d6ff"&gt;1&lt;/span&gt;), _regs.t);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ff7b72"&gt;break&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is bad code, since we write two bytes but the &lt;code&gt;AND&lt;/code&gt; let&amp;rsquo;s us place those one byte before the emulator memory ends → one-byte OOB write.&lt;/p&gt;</description></item></channel></rss>