Pieces
by AnandSaminathan
My flag has been divided into pieces :( Can you recover it for me?
Files
Solution
The divide
function in the given code replaces each character ch
in the parameter string with two other characters:
- The character whose ASCII is half (integer division) of the ASCII of
ch
. -
’ ’ if ASCII of ch
is even and ‘/’ otherwise.
The flag will be printed if the input to divide
results in the string "9|2/9/:|4/7|8|4/2/1/2/9/"
, we just have to reverse the divide
function with this string as the parameter to get the input/flag.
str='9|2/9/:|4/7|8|4/2/1/2/9/'
idx = 0
ans = ''
while idx < len(str):
a = ord(str[idx])
if str[idx+1] == '|':
ans += chr(a*2) # the original characters ASCII is even
else:
ans += chr(a*2 + 1) # the original characters ASCII is odd
idx += 2
print('rgbCTF{' + ans + '}')
Flag
rgbCTF{restinpieces}