Wargames.my 2016 writeups
Challenge 9: Test your skill EP02
to begin, instead of going through the binary step by step and dive through functions, let us skim through the main routine at 0x009E12A0. we can identify that the binary expecting 1 argument
we also can identify the “good-boy” block which will print “Yeah” when the condition is met
now we can analyse the main routine
1 | main(argc, argv) { |
reverse the algorithm to get the expected output from the check function
1 | x = 0x68616559; |
now let’s dive into the check function. after going through the function step by step, the only block that caught my interest is a loop that start at 0x009E2CF6
simplified algorithm of the loop:
1 | result = 0; |
from there, we can identify the argument need to be passed to the binary in order to produce the result == 2642612375. the argument is… 2642612375. trolled hard!
Challenge 12: Test your skill EP03
i didn’t manage to solve this during the competition because i was too focused on another challenge. not to mention the binary is heavily obfuscated which brings out the laziness in me. 500 points would be sweet to secure the victory though. anyway, the binary expected one argument to be passed. we can see a local call to 0x0040117b after the entrypoint where the stack is updated with:
- WORD nulls
- BYTE values
- WORD values
- a few others
then, the binary jump to 0x00401000 with our argument as the first parameter (esp+4). let us put a memory breakpoint on the argument to pinpoint where it will be accessed
continue the program (F9) and we can see there are 2 lines that access the argument, 0x004010B7 and 0x004010C6
from there, we can understand how the checking algorithm works
1 | 004020AF MOV EDX,DWORD PTR DS:[EAX] ; edx = &arg |
note that our argument are passed through a loop where every characters are shifted to the left by 2 bit and compared to a value extracted from the stack segment. the extracted values are the same WORD values which is stored in the stack during the beginning of the program:
1 | 3C 01 B8 01 B0 01 E4 01 7C 01 98 01 BC 01 C8 01 7C 01 D0 01 A0 01 94 01 7C 01 88 01 C8 01 84 01 D8 01 94 01 7C 01 BC 01 B8 01 94 01 CC 01 |
simple python code to decode it:
1 | from struct import unpack |