<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CTF on irq5 test</title><link>https://irq5-7854a1fdb9f4.pages.dev/tag/ctf/</link><description>Recent content in CTF on irq5 test</description><language>en-us</language><lastBuildDate>Mon, 07 Jan 2019 23:40:00 +0000</lastBuildDate><atom:link href="https://irq5-7854a1fdb9f4.pages.dev/tag/ctf/feed/" rel="self" type="application/rss+xml"/><item><title>35C3 CTF Write-up: php</title><link>https://irq5-7854a1fdb9f4.pages.dev/2019/01/35c3-ctf-write-up-php/</link><pubDate>Mon, 07 Jan 2019 23:40:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2019/01/35c3-ctf-write-up-php/</guid><description>&lt;h1 id=php-web>php (web)&lt;/h1>&lt;blockquote>&lt;p>PHP&amp;rsquo;s unserialization mechanism can be exceptional. Guest challenge by jvoisin.&lt;/p>&lt;p>Files at &lt;a href=https://35c3ctf.ccc.ac/uploads/php-ff2d1f97076ff25c5d0858616c26fac7.tar rel=noopener target=_blank class="external rawurl">https://35c3ctf.ccc.ac/uploads/php-ff2d1f97076ff25c5d0858616c26fac7.tar&lt;/a>.
Challenge running at: &lt;code>nc 35.242.207.13 1&lt;/code>&lt;/p>&lt;/blockquote>&lt;p>This challenge exposes a service written in PHP,
and as you can guess, it has something to do with &lt;em>unserialization&lt;/em>.&lt;/p>&lt;p>The single source file is straightforward to understand:&lt;/p>&lt;div class=highlight role=region aria-label="code block" translate=no>&lt;pre tabindex=0 class=chroma>&lt;code class=language-fallback data-lang=fallback>&lt;span class=line>&lt;span class=cl>&amp;lt;?php
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>$line = trim(fgets(STDIN));
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>$flag = file_get_contents(&amp;#39;/flag&amp;#39;);
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>class B {
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> function __destruct() {
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> global $flag;
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> echo $flag;
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> }
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>}
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>$a = @unserialize($line);
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>throw new Exception(&amp;#39;Well that was unexpected…&amp;#39;);
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>echo $a;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Your goal is to get the flag printed by somehow getting the destructor of class B to execute.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2019/01/35c3-ctf-write-up-php/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Flare-On 2017 Write-up: "pewpewboat.exe"</title><link>https://irq5-7854a1fdb9f4.pages.dev/2017/10/flare-on-2017-write-up-pewpewboat.exe/</link><pubDate>Sat, 14 Oct 2017 23:30:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2017/10/flare-on-2017-write-up-pewpewboat.exe/</guid><description>&lt;h3 id=flare-on-2017-challenge-5----pewpewboatexe>Flare-On 2017 Challenge #5 &amp;ndash; pewpewboat.exe&lt;/h3>&lt;p>As usual, the first thing to do when tackling the challenge is to run the binary first, to see what it does.
You will soon learn that it&amp;rsquo;s not actually a Windows executable,
but rather a 64-bit Linux ELF.&lt;/p>&lt;div class=highlight role=region aria-label="code block" translate=no>&lt;pre tabindex=0 class=chroma>&lt;code class=language-fallback data-lang=fallback>&lt;span class=line>&lt;span class=cl>$ ./pewpewboat.exe
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>Loading first pew pew map...
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> 1 2 3 4 5 6 7 8
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> _________________
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>A |_|_|_|_|_|_|_|_|
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>B |_|_|_|_|_|_|_|_|
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>C |_|_|_|_|_|_|_|_|
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>D |_|_|_|_|_|_|_|_|
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>E |_|_|_|_|_|_|_|_|
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>F |_|_|_|_|_|_|_|_|
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>G |_|_|_|_|_|_|_|_|
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>H |_|_|_|_|_|_|_|_|
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>Rank: Seaman Recruit
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>Welcome to pewpewboat! We just loaded a pew pew map, start shootin&amp;#39;!
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>Enter a coordinate:&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>So this is a &lt;a href=https://en.wikipedia.org/wiki/Battleship_%28game%29 rel=noopener target=_blank class=external>Battleship game&lt;/a>.
Playing manually for a bit, I see the &amp;ldquo;ships&amp;rdquo; form up in the shape what looked like a letter.
Hmm could this be the flag?&lt;/p>&lt;p>It&amp;rsquo;s now time to read the code.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2017/10/flare-on-2017-write-up-pewpewboat.exe/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>LabyREnth 2017: Binary 4</title><link>https://irq5-7854a1fdb9f4.pages.dev/2017/07/labyrenth-2017-binary-4/</link><pubDate>Thu, 27 Jul 2017 23:59:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2017/07/labyrenth-2017-binary-4/</guid><description>Hint: Send me this identifier together with your $$$$ to decrypt your file: da91e949f4c2e814f811fbadb3c195b8
Binary4 is a Mach-O binary, nothing IDA Pro can&amp;rsquo;t handle.
You will notice it has some obfuscated names, like wshwfknafsknfadj, pojklfasd, etc.
Looking at the main() function, IDA Pro&amp;rsquo;s decompiler produces the following pseudo-C code:
memset(&amp;v17, 0, 0x400uLL); v17 = 46; LODWORD(v3) = wshwfknafsknfadj(&amp;v17, 0LL); v15 = v3; LODWORD(v4) = bmasdfiukjwe(&amp;v17); v14 = v4; if ( 999 !&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2017/07/labyrenth-2017-binary-4/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>LabyREnth 2017 Write-up: "EzDroid"</title><link>https://irq5-7854a1fdb9f4.pages.dev/2017/07/labyrenth-2017-write-up-ezdroid/</link><pubDate>Thu, 27 Jul 2017 20:49:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2017/07/labyrenth-2017-write-up-ezdroid/</guid><description>Mobile track #1 - EzDroid Provided is an Android app package EzDroid.apk.
I typically use an Android emulator for testing, it&amp;rsquo;s free and easy to install on all major platforms, so it&amp;rsquo;s pretty much a no brainer.
After installation, it looks like it maanges to start but exits shortly after, for some unknown reason. Looks like it is time to inspect the code.
I like looking at high-level languages, so let&amp;rsquo;s start with that first.&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2017/07/labyrenth-2017-write-up-ezdroid/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>LabyREnth 2016 Write-up: "bowie.pl"</title><link>https://irq5-7854a1fdb9f4.pages.dev/2016/08/labyrenth-2016-write-up-bowie.pl/</link><pubDate>Wed, 03 Aug 2016 15:31:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2016/08/labyrenth-2016-write-up-bowie.pl/</guid><description>Unix track #1 - bowie.pl This is a Perl script which is really large (3MB). When you open it up, you&amp;rsquo;ll see it request input from STDIN, then compares it against these concatenated chars like so:
my $input = &amp;lt;STDIN>; $input = trim($input); if ($input eq (chr(5156 - 5035) . chr(-4615 - -4716) . chr(3162 - 3047))) { ... It then has a lot of MIME::Base64::decode() statements, which seem to be building up data in variable $a.&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2016/08/labyrenth-2016-write-up-bowie.pl/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>LabyREnth 2016 Write-up: "Regex"</title><link>https://irq5-7854a1fdb9f4.pages.dev/2016/08/labyrenth-2016-write-up-regex/</link><pubDate>Wed, 03 Aug 2016 15:31:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2016/08/labyrenth-2016-write-up-regex/</guid><description>Random track #2 - Regex This is a challenge involving regular expressions. It reads the huge expression from the file omglob_what_is_dis_crap.txt. The code that reads and evaluates this expression will only provide you with the key if you provide it with an input that doesn&amp;rsquo;t match this expression. Of course the program runs on a remote server, so you don&amp;rsquo;t have direct access to the flag.
Inspecting the expression, there&amp;rsquo;s a lot of &amp;ldquo;OR&amp;rdquo; conditions, and splitting them into lines gets you something like this:&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2016/08/labyrenth-2016-write-up-regex/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>X-CTF 2016 Badge Firmware</title><link>https://irq5-7854a1fdb9f4.pages.dev/2016/07/x-ctf-2016-badge-firmware/</link><pubDate>Tue, 19 Jul 2016 00:29:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2016/07/x-ctf-2016-badge-firmware/</guid><description>&lt;p>As promised, we are releasing &lt;a href=https://github.com/geekman/badger rel=noopener target=_blank class=external>the source code for the X-CTF badge&lt;/a>,
about 1 month after the event to give interested participants the chance to take a crack at it.
If you are interested in the badge design process,
check out &lt;a href=https://irq5-7854a1fdb9f4.pages.dev/2016/06/designing-the-x-ctf-2016-badge/ rel=noopener>my previous post on the hardware aspects&lt;/a>.&lt;/p>&lt;p>Jeremias and Jeremy gave a talk at one of the Null Security meetups.
&lt;a href=https://docs.google.com/presentation/d/1ZF4eMINOdhXUD4hn7NA8P-Roj7itxtIWvhx3lzXDboI/pub rel=noopener target=_blank class=external>Check out the slides&lt;/a> if you haven&amp;rsquo;t already.
In one part, Jeremy talks about the custom firmware he wrote for his badge and the
additional challenges he set up for partipants to get more points.
The 2nd part of the talk covers the electronic badge and challenges.&lt;/p>&lt;h2 id=the-challenges>The Challenges&lt;/h2>&lt;p>The challenges try to exploit the nature of being a self-contained electronic device.
Rather than trying to replicate more CTF puzzles and simply placing them into the badge, we specially designed them for the badge.&lt;/p>&lt;p>You can find the answers to the badge puzzles (and the main CTF puzzles) in the
&lt;a href=https://github.com/quanyang/x-ctf-2016-finals rel=noopener target=_blank class=external>X-CTF GitHub repo&lt;/a>,
which was released shortly after the event.&lt;/p>&lt;p>Since there&amp;rsquo;s only a single entry point into the set of challenges (meaning you must solve each puzzle before getting to the next),
the puzzles must be designed with increasing levels of difficulty;
too difficult and the participants will totally give up.&lt;/p>&lt;p>&lt;strong>Stage 1: Catch Me If You Can&lt;/strong>&lt;/p>&lt;p>&lt;picture>&lt;img src=https://irq5-7854a1fdb9f4.pages.dev/posts/2016/img/badge-catchme-anim.gif alt="animation of challenge 1" width=589 height=59>&lt;/picture>&lt;/p>&lt;p>I particularly like this one. Unlike a program running on the computer, you can&amp;rsquo;t easily snapshot the state of the program, nor try to influence (slow down) its execution.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2016/07/x-ctf-2016-badge-firmware/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Designing the X-CTF 2016 Badge</title><link>https://irq5-7854a1fdb9f4.pages.dev/2016/06/designing-the-x-ctf-2016-badge/</link><pubDate>Wed, 22 Jun 2016 00:29:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2016/06/designing-the-x-ctf-2016-badge/</guid><description>&lt;p>&lt;picture>&lt;img src=https://c2.staticflickr.com/8/7711/27521379400_bd686d27ae_o.jpg alt="X-CTF 2016 badge with Lithium-ion battery attached">&lt;/picture>&lt;/p>&lt;p>I had the opportunity to collaborate with some NUS students to design the
electronic badge for their X-CTF event this year.&lt;/p>&lt;p>The purpose of the badge was to inspire more people to take an interest in hardware hacking,
or to get them started on electronics.
With so much hype on the Internet-of-Things (IoT) these days,
what better idea than to let participants take home their very own IoT device.
The super low cost WiFi chip, Expressif&amp;rsquo;s ESP8266, made this possible.
We also wanted it to be shaped like a gaming device, with a D-pad and an LCD.&lt;/p>&lt;p>You can see the final badge design above:
a ESP8266-based board with a backlit monochrome Nokia LCD, D-pad and a SELECT button.
Powered by a lithium-ion battery, charged via the USB port,
which also provides a serial connection to the ESP8266.&lt;/p>&lt;p>I was inspired by the SyScan 2015 badge.
It was so simple and spartan: a monochrome LCD, an LED,
a 5-way joystick switch and a 32-bit ARM processor (on the back).
As the regulator was built-in and it runs all the way down to 2.4V,
there was no need for an external regulator.&lt;/p>&lt;p>&lt;picture>&lt;img src=https://c2.staticflickr.com/8/7609/27699054572_e19061de3a_b.jpg alt="SyScan 2015 electronic badge">&lt;/picture>&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2016/06/designing-the-x-ctf-2016-badge/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>32C3 CTF Write-up: gurke</title><link>https://irq5-7854a1fdb9f4.pages.dev/2015/12/32c3-ctf-write-up-gurke/</link><pubDate>Wed, 30 Dec 2015 20:29:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2015/12/32c3-ctf-write-up-gurke/</guid><description>gurke (misc) For this challenge, you are provided with a Python-based service that accepts a pickle and displays the result. You will need to coerce it to display the flag though, which is initialized at the start of the service.
The service can be succinctly represented as follows:
class Flag(object): def __init__(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("172.17.0.1", 1234)) self.flag = s.recv(1024).strip() s.close() flag = Flag() ... data = os.read(0, 4096) try: res = pickle.&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2015/12/32c3-ctf-write-up-gurke/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>32C3 CTF Write-up: config.bin</title><link>https://irq5-7854a1fdb9f4.pages.dev/2015/12/32c3-ctf-write-up-config.bin/</link><pubDate>Wed, 30 Dec 2015 20:28:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2015/12/32c3-ctf-write-up-config.bin/</guid><description>config.bin (forensics) You are provided with what they say is &amp;ldquo;a configuration backup of an embedded device&amp;rdquo;, and that &amp;ldquo;it seems to be encrypted&amp;rdquo;.
Opening the file with a hex editor to look for any magic identifiers:
00: 4346 4731 0000 32d0 ef92 7ab0 5ab6 d80d CFG1..2...z.Z... 10: 3030 3030 3030 0000 0005 0003 0000 0000 000000.......... 20: 6261 47c3 d43b af2f 9300 bcaf adf4 5c8c baG..;./......\. 30: 3d02 9ea5 0bb7 3ce0 00f4 c5b3 901e d5fb =.&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2015/12/32c3-ctf-write-up-config.bin/#more">Continue reading…&lt;/a>&lt;/p></description></item></channel></rss>