Runtime Environment 2
Challenge Description
This time it HAS to be harder.
MD5 (hasbeen.tar.gz) = 46ff7d24975679901d8f8d769e567b09
rootkid
Challenge Details
Oh god, the moment I see the challenge description, I knew I'm in for a hell ride. This challenge took me 3 painful days to solve (ofc I gave up a few times to go solve other challenges XDDDDDDD)
Why? I realised the challenge was written in Haskell, a language that I did not know how to read/write, much less understand how GHC compiles Haskell code into executables. The way functions work is pAin but oh wells I decided to bite the nail and try to solve it.
Like RE 1, we were given a binary and an encoded file. However, this time the encoded file is not readable:

And by looking at the disassembler, I can confirm that the program is written in Haskell due to the presence of hs_main being called in main:

When i ran the program, I realised that the program gave different outputs for the same input, meaning that there is something else involved during the encoding process:

From there, I ran hsdecomp on the program to attempt to decompile the program back to the original haskell code and figure out what happens during the program:
At first, I did not really understand the decompiled code as I was not really good in haskell. However, at first glance, I can confirm that:
Program gets current time to be used for the encryption process
Input/time will be xored with each other
Bit shifting is also involved.
After putting some breakpoints in IDA and a painful debugging process, I finally managed to figure out the encryption function:
In essence, the program will take input from the user and current time whereby the time goes through the following process before xoring with a letter of the user:
Left shift by 13 and keep signed value of the result
Right shift by 17
Left shift by 5
The resulting time will be saved for the next letter until the entire string is encrypted.
Challenge Solution:
To solve the challenge, simply get the modified time of the file and run the encryption process again since it is a simple xor function that can be undone by xoring the encrypted output:
Flag: grey{Funct1on41_P4rad1s3_iZ_Fun}
Last updated