Writeups PicoCTFReverse EngineeringEncodingUnicode

Transformation Writeup - PicoGym

Writeup for the Transformation challenge from PicoCTF PicoGym.

Contents

Category: Reverse Engineering

Difficulty: Easy

Points: 20

Description

An encrypted file enc is provided. A comment in the source reveals the encoding scheme. The task is to reverse it.

Overview

Background: Bit Packing

Solution

Step 1: Read the Encoding Comment

# code : ''.join([chr((ord(flag[i]) << 8) + ord(flag[i + 1])) for i in range(0, len(flag), 2)])

Step 2: Reverse the Encoding

result = ""
for d in data:
    result += chr(ord(d) >> 8)           # high byte: first original char
    result += chr(d.encode("utf-16be")[-1])  # low byte: second original char

Flag

picoCTF{16_bits_inst34d_of_8_26684c20}

← Back to Blog