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))
Bagel_Cannon

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



Barun

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

Get IoT Security Training

IoT Pentesting Exploitation Training

Tags

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

Instagram