<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>apelord's blog</title><link href="https://blog.apelord.net/" rel="alternate"/><link href="https://blog.apelord.net/feeds/all.atom.xml" rel="self"/><id>https://blog.apelord.net/</id><updated>2014-06-05T14:26:00+02:00</updated><subtitle>Reversing, CTF writeups, and web exploit notes by apelord.</subtitle><entry><title>SECUINSIDE CTF Quals 2014 – Reversing 100 yayaya</title><link href="https://blog.apelord.net/secuinside-ctf-quals-2014-reversing-100-yayaya.html" rel="alternate"/><published>2014-06-05T14:26:00+02:00</published><updated>2014-06-05T14:26:00+02:00</updated><author><name>apelord</name></author><id>tag:blog.apelord.net,2014-06-05:/secuinside-ctf-quals-2014-reversing-100-yayaya.html</id><summary type="html">&lt;p&gt;Writeup of SECUINSIDE CTF Quals 2014 Reversing 100 "yayaya" — an SWF file with an embedded ELF that turned out not to need reversing at all. The solution was to screen-capture random-colored Flash frames and stack them with ImageMagick.&lt;/p&gt;</summary><content type="html">&lt;h2&gt;The task&lt;/h2&gt;
&lt;p&gt;This task contains an SWF file with Crossbridge embedded. Additionally there is an ELF file inside that SWF. At the first look I thought that this is really an RE job. But I was wrong (thanks to &lt;strong&gt;nurfed&lt;/strong&gt; — it's his solution). There is no RE, and even a Flash decompiler was not needed. The entire work comprises capturing Flash movie frames with random color blocks.&lt;/p&gt;
&lt;p&gt;Some random frame from the Flash movie:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Random color-block frame from the yayaya Flash movie" src="https://blog.apelord.net/images/yayaya1.png"&gt;&lt;/p&gt;
&lt;h2&gt;Capturing frames&lt;/h2&gt;
&lt;p&gt;These color blocks appeared at some interval, and the solution was to capture these frames and then combine them together. For screen capture I chose &lt;a href="https://github.com/ponty/pyscreenshot"&gt;pyscreenshot&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pyscreenshot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;ImageGrab&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;time&lt;/span&gt;

&lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;z&amp;#39;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;im&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ImageGrab&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;grab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bbox&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;269&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;469&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;im&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;e:&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;sc&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;im_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;.png&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Combining the frames&lt;/h2&gt;
&lt;p&gt;I decided to use PIL to combine screenshots, but nurfed (thanks again) chose an easier way — ImageMagick. So simple:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;convert&lt;span class="w"&gt; &lt;/span&gt;-evaluate-sequence&lt;span class="w"&gt; &lt;/span&gt;add&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;e:\sc\im_*.png&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;out.png
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;The flag&lt;/h2&gt;
&lt;p&gt;And we get the final image:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Stacked-frame composite of the Flash movie revealing the flag" src="https://blog.apelord.net/images/yayaya2.png"&gt;&lt;/p&gt;
&lt;p&gt;Flag is &lt;strong&gt;GANADAHAAH&lt;/strong&gt;.&lt;/p&gt;</content><category term="CTF"/><category term="ctf"/><category term="secuinside-ctf"/><category term="reversing"/><category term="flash"/><category term="swf"/><category term="crossbridge"/><category term="imagemagick"/><category term="python"/></entry><entry><title>ASIS CTF Quals 2014: Trivia 50</title><link href="https://blog.apelord.net/asis-ctf-quals-2014-trivia-50.html" rel="alternate"/><published>2014-05-12T14:28:00+02:00</published><updated>2014-05-12T14:28:00+02:00</updated><author><name>apelord</name></author><id>tag:blog.apelord.net,2014-05-12:/asis-ctf-quals-2014-trivia-50.html</id><summary type="html">&lt;p&gt;Writeup of the ASIS CTF Quals 2014 Trivia 50 challenge — a NES ROM of Battle City that hides the flag inside the game itself. Solved by playing the first level in FCE Ultra.&lt;/p&gt;</summary><content type="html">&lt;h2&gt;The challenge&lt;/h2&gt;
&lt;p&gt;This challenge was fun. It was a NES ROM image that contains the famous game — Battle City. After quick examining the ROM in a hex editor we did not find anything useful, so we decided to run it. Emulator used: &lt;strong&gt;FCE Ultra v0.98.13&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;Booting the ROM&lt;/h2&gt;
&lt;p&gt;Startup screen:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Battle City startup screen in FCE Ultra emulator" src="https://blog.apelord.net/images/asis50_1.jpg"&gt;&lt;/p&gt;
&lt;h2&gt;Finding the flag&lt;/h2&gt;
&lt;p&gt;When we played it we tried to dump ROM memory (trying to find out the flag, but not succeeded). And when the 1st level was done we got the flag:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Battle City end-of-level screen showing the flag text" src="https://blog.apelord.net/images/asis50_2.png"&gt;&lt;/p&gt;
&lt;p&gt;There is a little bit of brute-forcing in the answer because the flag &lt;code&gt;8 bit rules&lt;/code&gt; was not the correct submission. After trying different versions we landed on the flag: &lt;strong&gt;8BIT_RULEZ&lt;/strong&gt;.&lt;/p&gt;</content><category term="CTF"/><category term="ctf"/><category term="asis-ctf"/><category term="nes"/><category term="reversing"/><category term="trivia"/></entry></feed>