<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>cpp | Adrien Suau</title><link>https://adrien.suau.me/tag/cpp/</link><atom:link href="https://adrien.suau.me/tag/cpp/index.xml" rel="self" type="application/rss+xml"/><description>cpp</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Wed, 05 May 2021 00:00:00 +0000</lastBuildDate><image><url>https://adrien.suau.me/media/sharing.png</url><title>cpp</title><link>https://adrien.suau.me/tag/cpp/</link></image><item><title>botofu</title><link>https://adrien.suau.me/project/botofu/</link><pubDate>Wed, 05 May 2021 00:00:00 +0000</pubDate><guid>https://adrien.suau.me/project/botofu/</guid><description>&lt;p>I started the Botofu project during my PhD (even though it had &lt;strong>nothing&lt;/strong> to do with it) back in 2020. My goal was to practice my C++ while building open-source tools that would be interesting for some people. At that time, I was still talking regularly with a community of people on a forum dedicated to automated tooling around a famous French game called &lt;a href="https://www.dofus.com/en/mmorpg/discover" target="_blank" rel="noopener">Dofus&lt;/a>. For most of them, the goal was to build bots that would extract interesting information from the game such as regularly getting the prices of some items in the player-driven market in order to have a database that could then be used to uncover some patterns and make virtual money in the game.&lt;/p>
&lt;p>In order to build an automated tool, two main ways were explored:&lt;/p>
&lt;ol>
&lt;li>Taking a man-in-the-middle (MITM) approach: the game client was launched, but the software would intercept all its communication, analyse them, and potentially forge some of them to automate some acitons.&lt;/li>
&lt;li>Implement a full software that would act as the official game client, but without launching the game client itself.&lt;/li>
&lt;/ol>
&lt;p>Both approach require you to be able to understand how the game client communicates with the game server, so that your tool can read and understand the messages sent by the server, and potentially forge some without the game client too. It turns out that the game client needs to know that information too, so all the information that was needed was already available&amp;hellip; except that it was hard to read!
Turns out that the game client was written using the Action Script 3.0 programming language and was packaged as a SWF file. That means that, just like Java, the code was compiled into bytecode (which is an intermediate step between the code human can write and the machine code the CPU can read and understand) and executed by a virtual machine (a program running on your computer) called the ActionScript Virtual Machine 2 (AVM2).&lt;/p>
&lt;p>Most people wanting to understand the protocol (how to read and forge packets of data to communicate with the server) were uncompiling the bytecode into relatively unreadable (because of obfuscation) code using a decompiler (often the &lt;a href="https://github.com/jindrapetrik/jpexs-decompiler" target="_blank" rel="noopener">JPEXS decompiler&lt;/a> which was the most used at the time), that would then need to be parsed and understood by a human.&lt;/p>
&lt;figure id="figure-example-of-the-jpexs-decompiler-user-interface-from-their-wikihttpsgithubcomjindrapetrikjpexs-decompilerwikifeatureabc-explorer">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="Example of the JPEXS decompiler user interface from [their wiki](https://github.com/jindrapetrik/jpexs-decompiler/wiki/Feature.ABC-Explorer)." srcset="
/project/botofu/jpexs_example_huc98b2500fab6916f7be5c07e2603af65_73740_457c57d5c454294d132500c54cadd662.webp 400w,
/project/botofu/jpexs_example_huc98b2500fab6916f7be5c07e2603af65_73740_92fe98559c1f77601733b2c35134aee8.webp 760w,
/project/botofu/jpexs_example_huc98b2500fab6916f7be5c07e2603af65_73740_1200x1200_fit_q75_h2_lanczos_3.webp 1200w"
src="https://adrien.suau.me/project/botofu/jpexs_example_huc98b2500fab6916f7be5c07e2603af65_73740_457c57d5c454294d132500c54cadd662.webp"
width="760"
height="412"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption>
Example of the JPEXS decompiler user interface from &lt;a href="https://github.com/jindrapetrik/jpexs-decompiler/wiki/Feature.ABC-Explorer" target="_blank" rel="noopener">their wiki&lt;/a>.
&lt;/figcaption>&lt;/figure>
&lt;p>Botofu was my attempt at circumventing uncompilation and making that step of getting the game protocol faster, less error-prone and more human friendly.&lt;/p>
&lt;p>In that project I:&lt;/p>
&lt;ul>
&lt;li>Developped &lt;a href="https://gitlab.com/botofu/botofu/-/blob/dev/src/botofu/ios/core/README.md" target="_blank" rel="noopener">binary readers and writers&lt;/a> that are used in the other libraries.&lt;/li>
&lt;li>Developped a &lt;a href="https://gitlab.com/botofu/botofu/-/blob/dev/src/botofu/swf/parser/README.md" target="_blank" rel="noopener">partial parser for SWF files&lt;/a> following the &lt;a href="https://open-flash.github.io/mirrors/swf-spec-19.pdf" target="_blank" rel="noopener">SWF File Format Specification Version 19&lt;/a>.&lt;/li>
&lt;li>Used the SWF file parser to &lt;a href="https://gitlab.com/botofu/botofu/-/blob/dev/src/botofu/protocol/parser/README.md" target="_blank" rel="noopener">extract the interesting data&lt;/a> (the protocol) directly from the bytecode, without any decompilation, and output it in a JSON format.&lt;/li>
&lt;/ul>
&lt;p>As far as I can tell, the software is still used 6 years after its inception, and is still working as expected after 5 years without maintenance, which means I probably was right in my diagnostic that this was an interesting tool for people.&lt;/p></description></item></channel></rss>