Flare-On 6 CTF WriteUp (Part 1)

. 4 min read

Flare-On is a CTF style reverse engineering challenge organized by the FLARE team at FireEye Labs annually. There are a series of 12 challenges with increasing difficulty. This year the challenges covered a variety of domains ranging from Windows to Linux and even the NES (Nintendo Entertainment System).

In this series of blog posts, we will try to go through the challenges one at a time. There may be multiple ways to solve a problem. The techniques presented here just reflects the views of the author.

1 - Memecat Battlestation [Shareware Demo Edition]

The challenge reads...

Welcome to the Sixth Flare-On Challenge!

This is a simple game. Reverse engineer it to figure out what "weapon codes" you need to enter to defeat each of the two enemies and the victory screen will reveal the flag. Enter the flag here on this site to score and move on to the next level.

This challenge is written in .NET. If you don't already have a favorite .NET reverse engineering tool I recommend dnSpy

** If you already solved the full version of this game at our booth at BlackHat  or the subsequent release on twitter, congratulations, enter the flag from the victory screen now to bypass this level.

The challenge consists of a Windows executable - MemeCatBattlestation.exe. Running, we are greeted with the following window.

Figure 1: We need a weapon arming code
Figure 1: We need a weapon arming code

At the bottom half of the window, there's a text box which requests us to input a "Weapon Arming Code". Entering a random string says "Invalid Weapon Code". Our objective in Stage-1 is to get the correct arming code. That challenge description already mentions that this was written in .NET. So let's analyze the executable in dnSpy.

Once the binary is loaded in dnSpy, right-click on MemeCatBattlestation and chose "Go to Entrypoint" as shown in Figure 2. The Entrypoint is the code from where execution starts. This is like the main function we have in a C or C++ program.

Figure 2: Let's go the entrypoint
Figure 2: Let's go the entrypoint

The entrypoint is located in the Program class. The decompiled code looks like.

Figure 3: The decompiled code of Main
Figure 3: The decompiled code of Main

The application creates four forms - LogoForm, Stage1Form, Stage2Form and VictoryForm as we can see in Figure 3. Initially, only Stage1Form is shown. We proceed to Stage2Form only after we provide the correct arming code. There's also a VictoryForm after Stage2Form. This suggests this challenge may consists of two stages both of which requires a weapon code to proceed. For now, let's have a look at Stage1Form.

A .NET GUI application can have event handlers attached to the various controls. For example, there can be a button click handler attached to a button control which will be called whenever we click on that button. Going through the decompiled code we can find an event handler for the fire button.

Figure 4: The button click handler in Stage1Form
Figure 4: The button click handler in Stage1Form

As we can see, the code compares the input in the textbox to the string RAINBOW. If it matches it starts a victory animation timer. This must be the correct weapon arming code for passing Stage 1.

Stage 2

Figure 5: We're in Stage 2
Figure 5: We're in Stage 2

The second stage also requires us to input a weapon arming code. Without further ado, let's check the decompiled code of the form.

Figure 6: The button click handler in Stage 2 Form
Figure 6: The button click handler in Stage 2 Form

In stage 2, our input string in the textbox is passed to a method isValidWeaponCode, which as it's name suggest, must check whether the code is valid or not.

Figure 7:  Checking whether the weapon code is correct
Figure 7: Checking whether the weapon code is correct

Unlike the check in Stage 1, there's no direct string comparison here. Instead, it converts the string to a character array and Xor's each element in the array with the character A. The SequenceEqual method, compares two arrays for equality and returns True if they match. In other words, after Xoring each element with A, the resultant array must match with the given array.

Finding the original array is easy. We just need to Xor the given array with 'A' again.

>>> target = [u'\x03', ' ', '&', '$', '-', u'\x1e', u'\02', ' ', '/', '/', '.', '/']

>>> ''.join(map(lambda x:chr(ord(x)^ord('A')), target))

Typing, Bagel_Cannon as the arming code, we win the level and get the flag.

Figure 8: We win!
Figure 8: We win!

Flag: Kitteh_save_galixy@flare-on.com


Reverse Engineer with an interest in low level stuff and anything about security.

Get IoT Security Training

IoT Pentesting Exploitation Training


Android android application security android hands on security and exploitation training android security Apktool application auditing application security auditing appsec usa appwatch attify attify badge attify training binwalk blackberry pentesting blackhat ble BLE hacking and exploitation BLE sniffing box brut Exception chroot cloud based mobile application security scanner consulting CTF Damn Vulnerable iOS App devops dumping memory embedded hacking exploitation exploiting smart devices Firmware hacking frida hackfest hacking smart devices how to secure iot device IDA internet of things Internet of Things Security ios application security ios security iot iot device IoT Exploitation iot hacking iot pentest iot pentesting iot security iot security training iotsecurity jtag jtag debugging mobile app mobile application security mobile application security testing mobile security ninja recon technique offensive iot exploitation ola cabs owasp owasp appsec penetration testing pentesting pentesting mobile apps powerofcommunity PrinterSecurity qemu quizup radio communication protocol radio coomunication Reversing sdr secure coding guidelines security security issue security services security training security vulnerability smart devices social networking spi threat modeling training uart vulnerability writeups xposed hooking zigbee zigbee exploitation zigbee security zwave firmware reverse engineering firmware emulation firmware analysis toolkit firmadyne getting started with firmware hacking iot penetration testing iot attacks recent iot attacks cyber attacks iot hacks biggest iot attacks of all time hacked smart devices iot bots, malwares latest iot attacks BtleJuice bleah retail iot challenges in iot retail security issues faced by e-retailers network security in retail DDoS attacks phishing attacks how retail can prevent cyber attacks security challenges in retail IoT Flare-on radio waves hacking arduino nano how to hack radio waves analog modulation digital modulation capture radio traffic bluetooth technology BLE vulnerabilities BLE attacks BLE dangers BLE security issues exploiting ble how to exploit ble tools to exploit ble privacy protection iot threats protect against iot threats dangers of iot smart user security how to protect iot devices monitor iot devices internet security safety measures to protect privacy healthcare iot iot threats to healthcare industry how can healthcare fight iot threats healthcare cyber security prevent cyber attacks on healthcare measures to prevent cyber attacks on healthcare organisations steps to prevent iot attacks on healthcare healthcare business protection against iot threats security in healthcare iot recent cyber attacks recent ARM attacks ARM course ARM Training ARM binaries Exploit ARM devices IoT hacks on ARM devices ARM gadgets learn ARM exploitation Mirai Botnet vulnerable ARM devices arm ARM exploitation book ARM exploitation video training guide to ARM exploitation cybersecurity why you should be a cybersecurity expert professional expert career in cybersecurity why choose career in cybersecurity growth potential penetration testers hackers profession What is a Mirai Botnet? virus How Mirai botnet infects your device Understanding Mirai Botnet How Mirai works setup mirai history IoT Devices What is mirai botnet? IP cameras security cameras CCTV cameras hacked security IP cameras surveillance cameras hijacked vulnerabilities in internet connected cameras recent security camera attacks vulnerabilities discovered in popular IoT IP cameras IoT security guidelines Mozilla NIST GSMA best security practices automotive security V2V V2I Car security ECU hacking GozNym Bank account hack customer privacy banking malware