Post

COMPFEST CTF 2023 - not simply corrupted

Description

Category: Forensic

My friend loves to send me memes that has cats in it! One day, he sent me another cat meme from his 4-bit computer, this time with “a secret”, he said. Unfortunately, he didn’t know sending the meme from his 4-bit computer sorta altered the image. Can you help me repair the image and find the secret?

Author: notnot

Attachments:

Resolution

1. Decoding

The file consists only of 0 and 1:

Hex

A hint from the description is 4-bit computer.

If we convert the 4 first bits 1000 to hex we got 8 and the next 4 ones 1001 is 9, and 89 is the first byte of the PNG header (89 50 4E 47).

Here is the script to convert it to bytes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
f = open('cat.png', 'rb').read()

# We read the file as bytes, we need to convert them to 0s and 1s
# f[0] = 16 = 1*16 + 0*16 -> 10

B = ""

for byte in f:
    B += hex(byte)[2:].zfill(2)
    
# Now we convert from bin (0-1) to hex (0-15)
# 1000 -> 8

H = ""

for bits in [B[i:i+4] for i in range(0, len(B), 4)]:
    H += hex(int(bits, 2))[2:]


# Finally we convert the hex to "real" bytes
f = open('out.png', 'wb')

import binascii
f.write(binascii.unhexlify(H))

We decoded the file and got this picture:

Cat

2. LSB Steganography

We can’t see any flag on the picture, it must be hidden.

We use AperiSolve to find any hidden information.

We found the flag hidden in the LSB of the red channel:

Red LSB

COMPFEST15{n0t_X4ctlY_s0m3th1n9_4_b1t_1nn1t_f08486274d}

Additional resources

LSB Image Steganography Using Python - Devang Jain

This post is licensed under CC BY 4.0 by the author.