Skip to content

Instantly share code, notes, and snippets.

@SalScotto
Last active May 10, 2022 18:30
Show Gist options
  • Save SalScotto/1f00dea279cc5cf7f1eab99e8743dcbf to your computer and use it in GitHub Desktop.
Save SalScotto/1f00dea279cc5cf7f1eab99e8743dcbf to your computer and use it in GitHub Desktop.
Writeup "Number Game" - Angstrom CTF 2022

Number Game

Introduction

Introduction

Solution

Let's start by downloading the attached file. Trying to run it, we see that it asks us to guess a number:

First_Run

Since we do not have the crystal ball, we get the value to guess from the binary code. Let's now disassemble the executable using Binary Ninja so that we can analyze the main and better understand its behaviour.

Binary_Ninja Open_Main

Here we can see that a series of read/compare are made to verify the information entered.

The first check is as follows:

Main_RAW

It's not that clear to read, so we can use Binary Ninja's disassembler to get closer to the original code and rename some variables:

Disassembled_Main Rename Renamed_field Display_as

We can now clearly see that it compares the user input with the value 314159265

First_check

Let's continue with the tree, renaming the variables as before, and see the next comparison.

To help us better understand the code, we can also add some comments:

Add_comments Second_check

We see that (after moving the variables a couple of times) it compares the value just entered added to the previous one with 513371337

So, subtracting the previous value from this one, we get: 513371337 - 314159265 = 199212072

Finally, the last check compares the entered string with the string contained in the variable data_2150.

Third_check

We can find the entire value of this string by double-clicking on the variable ...

double_click

... or inside the Strings section of Binary Ninja

Strings

Thus we see that the string being compared to is the airspeed velocity of an unladen swallow.

Once this check is valid, the print_flag() function is called

Last_then

We can now verify that these values ​​allow us to get the flag both locally ...

Local_flag

... and remotely

Flag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment