Solution #

You will be given the following file, enc.

1
2
$ bat resources/enc -p
灩捯䍔䙻ㄶ形楴獟楮獴㌴摟潦弸彤㔲挶戹㍽

The problem description says

1
2
I wonder what this really is...
''.join([chr((ord(flag[i]) << 8) + ord(flag[i + 1])) for i in range(0, len(flag), 2)])

The enc file should contain the encrypted flag. The flag is encrypted by the following algorithm.

1
2
def encrypt(flag):
    return "".join([chr((ord(flag[i]) << 8) + ord(flag[i + 1])) for i in range(0, len(flag), 2)])

Thus, we need to decrypt the flag. The following script decrypts the flag.

1
2
def decrypt(flag):
    return "".join([chr((ord(flag[i]) >> 8) + ord(flag[i + 1])) for i in range(0, len(flag), 2)])

Yeah, we’ve got the flag.

1
2
$ python scripts/transformation.py
picoCTF{16_bits_inst34d_of_8_d52c6b93}

Acknowledgement #

Thank you, CMU security and privacy experts, for creating this challenge.

References #