The Quantum Scrambler is a reverse engineering challenge from picoCTF 2025. It may seem challenging — but once broken down, it is much more simpler. Let’s begin the writeup!
Analyzing the Program:
After we connect to the program and run it, we are met with a bunch of hexadecimals in a list.
Press enter or click to view image in full size
We were also given the python source code, let’s analyze it to see what happened.
Join Medium for free to get updates from this writer.
In this snippet of code, the program calls two functions which obtains the flag and scrambles it. Then, it outputs the scrambled flag which is the list full of hexadecimals we saw earlier.
Press enter or click to view image in full size
The get_flag() function opens a file with the flag and gets it. It then get rid of any trailing whitespace with flag.strip(). The for loop takes every character in the flag and turns it into a hexadecimal (ex: ‘0x70’).
Press enter or click to view image in full size
Press enter or click to view image in full size
It may seem intimating to understand what is going on, however, we can substitute random values for the flag to see what changes and what does not. For instance, let’s pretend the flag is: fakeflag
I printed out the normally encoded values and the scrambled values so we can see the pattern. The encoded flag can be seen having the original values at the start and end. The values in the middle could be ignored.
Press enter or click to view image in full size
Since we understand how the program functions, we know will explore how to decrypt it and find the flag.
Solving the Challenge:
This program gets the first and last value from each of the list because the values in the middle do not matter. Then it changes the hexadecimal to a normal string.
encryptedList = theEncryptedOutputHere!
flag = []
for x in encryptedList:
flag.append(str(x[0]))
flag.append(str(x[-1]))for x in flag:
print(str(chr(eval(x))), end='')
The output for me was: picoCTF{python_is_weird6ed1aaf0}
(A parentheses may be missing, don’t forget to add it!)