Transformation - PicoCTF
November 16, 2021•202 words
Translate the string into unicode and insert it into a variable, then treat the encryption as a mathematical function and try to obtain a reverse formula. Imagine that A and B are the characters that, when mixed as described in the challenge description, generate the first character of the encoded text.
To retrieve A, just push the encoded character 8 places to the right, so to clean all values that were influenced by the value of B.
To retrieve B, you now have the encoded value and A itself: what you can do is shift A back 8 places to the right and remove its influence from the overall value by subtracting it from the encoded character. What's left? B. Retrieve it and put the flag back together.
The following code is the realization of the steps described. To retrieve the flag in a comfortable way, pipe the output of this code into this command:
tr -d "\n"
flag= u'\u7069\u636F\u4354\u467B\u3136\u5F62\u6974\u735F\u696E\u7374\u3334\u645F\u6F66\u5F38\u5F65\u3730\u3362\u3438\u367D'
for i in range(0, len(flag)):
a= chr(ord(flag[i])>>8)
print(a)
print(chr((ord(flag[i]) - (ord(a)<<8))))