Let's start by downloading the attached file. Trying to run it, we see that it asks us to guess a number:
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.
Here we can see that a series of read/compare are made to verify the information entered.
The first check is as follows:
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:
We can now clearly see that it compares the user input with the value 314159265
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:
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
.
We can find the entire value of this string by double-clicking on the variable ...
... or inside the Strings
section of Binary Ninja
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
We can now verify that these values allow us to get the flag both locally ...
... and remotely