rgbCTF-2020

CTF Writeup - https://ctf.rgbsec.xyz/

Home Other writeups of rgbCTF-2020
15 July 2020

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 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}
tags: