Description
Find the correct entry.
Write-Up
To solve this reverse challenge, let’s open our favorite reverse engineering tool : for me it is IDA.
The first step is to find the main function to get an overview of the binary.
|
|
As you can see, main is quite simple: there are checks on the input passed as a binary argument. Now, we rename variables, set types and add comments.
|
|
So, the input must be size 81 and the check_func function must not return 0. Let’s take a look at the check_func()
.
|
|
The function is not that long but we can see many loop and verification. Let’s rename variables and split the code.
First, there is an important buffer byte_2020
:
|
|
And the first part of the code :
|
|
There is some condition to check that each character of the input is between ‘a’ and ’e’ and that the index of the current character is greater than the number of iterations of the current buffer character in the buffer
Next part :
|
|
This part is quiet complexe : this code is used to check a special condition similar to Sudoku: characters cannot appear twice in the same group: they must be unique in each group (a group represents all the cells with the same value in the buffer seen above).
And finally the last part :
|
|
This condition verifies that two characters are not identical if they are neighbors in the matrix (including the diagonals).
Looking at the composition of the groups, we notice that group 0x11 is made up of just one square. So, according to the condition `if ( current_char - 96 > (int)count_itteration(buffer_current_char) )``, this cell must contain the character ‘a’.
We therefore have a list of conditions that our input must meet to validate the challenge:
- The character at index [8][2] is a ‘a’
- Each character must be between ‘a’ and ’e’
- Neighboring characters must not be identical
- Characters in the same group must not be identical
We can now write a z3 script to find the perfect input that match all the conditions.
|
|
Let’s execute the script :
|
|
The flag is the md5 of this input.
Flag
ECW{5e438f1fd92d68afe17d89f8004b8ea7}