Arab Security Cyber WarGames 2020 RE Challenges Writeup

Arab Security Cyber WarGames 2020 RE Challenges Writeup

Featured image

This is the write up of the for the RE challenges in the ASC CTF qualification round. There was 2 RE chellenges.

Check

There are many different approaches to solve this challenge

The guessing one, let’s run ltrace

Now what you need to do is change your HOSTNAME and USER environment variables to match what you found.

Flag : ASCWG{3nv_v4r5_4r3_u53ful}

The static analysis approach

Following the [×] Machine not OK. string you will get to this if statement then printing [o] Machine OK: followed by a string so this string could be our flag.

Now let’s look at the sub11ED function and see what it does with our flag

It just takes the flag and xor it with 0x92, so the process can be repeated manually.

The in depth approach

I renamed some of the variables and functions to make sense. All XOR functions are followed by a number, the number is equal to the number that the data is xored with.

Which means that after the xor the HOSTNAME variable is equal to HOSTNAME and HostnameENV equals the hostname environment variable.

The same as explained above, nothing new here.

Then if the environments variable HOSTNAME, USER are equal to Machine, reenigne respectively.

DOOM

We got a 64-bit ELF, and it just takes the input and does nothing with it

So checking the main you can see that it just print doom and takes an input and that’s all it does

So clearly the flag isn’t there upon checking the other function i was verifyFlag and printFlag which caught my interest, looking at the verifyFlag function as printFlag just print the variable being passed to it in the format flag format, so let’s fouce on verifyFlag.

It has some hard coded data like s and v5 which are used for RC4 decryption i think.

Then it reads data from string.txt

Then it hash the content of string.txt with md5 hash.

And then compare it with the output of the RC4 decryption and then it prints the flag.

Break main and run the program then break verifyFlag and then set the rip to verifyFlag.

Set breakpoint at the address 0x000000000800167a

To check what are the values of the variables being passed

After checking the rax and rdx values with x/16x (why 16? Because we know from the code that they are MD5 Hashes)

FLAG: ASCWG{apocolypsedoomsday}