Let’s look at another challenge from 34C3 Junior CTF called top.
Let’s take look at the source code provided in the challenge.
Firstly, I’d like to analyze the code by recreating it with other variables. Let’s use python console for that.
I’m using one of the flags provided in the faq section. Now we can check what happens during the encryption process. Firstly, cur_time variable is appended to the msg, which is our flag.
Then 0x88 value is being multiplied by the length of cur_time variable.
After that we’re ready to show the actual encryption process.
The most important flaw of this script is that we are able to get the cur_time variable by xoring last n elements of the encrypted message. We know the key used with this, which is 0x88 so let’s reverse this scheme.
These is encrypted part of a message that should represent cur_time variable.
After completing the process for whole message, we get the cur_time - which is 1513719133.8728752. Now as we know whis value, and random number generator is seeded with this value, we can generate the same numbers as during the generation of the key for the challenge.
This is our key. Now let’s write a script that will xor values of the message and the key.
And here’s our flag.
If you have any suggestions regarding this post or just want to chat together check out these ways to reach out to me.