$ cat writeup.md…
$ cat writeup.md…
tjctf
Task: grayscale PNG where RGB triplets were flattened into single grayscale pixels, with original dimensions hidden in EXIF Comment. Solution: read EXIF for original size, reshape flat grayscale data back into (H, W, 3) RGB array using NumPy.
I was messing around with my image and it got really messed up... I see patterns...
Given: chall.png — a 1888×1888 8-bit grayscale PNG (~2.5 MB). The goal is to recover the original image and find the flag.
Running exiftool on the image reveals key metadata:
Image Width : 1888
Image Height : 1888
Color Type : Grayscale
Bit Depth : 8
Comment : 2000x594
The image is grayscale (mode 'L'), but the EXIF Comment field contains 2000x594 — the original image dimensions. This is the first critical clue.
The challenge name "triplets" hints at groups of three — specifically RGB color channels. Each pixel in the original RGB image has 3 values (R, G, B). The encoding process was:
The description "it got really messed up" and "I see patterns" confirms the image was transformed — the patterns are the interleaved R, G, B values appearing as grayscale stripes.
The reversal is straightforward:
#!/usr/bin/env python3 from PIL import Image import numpy as np # Load the grayscale challenge image img = Image.open('chall.png') data = np.array(img).flatten() # Original dimensions from EXIF Comment: 2000x594 W, H = 2000, 594 # Take first W*H*3 values and reshape as RGB rgb_data = data[:W * H * 3].reshape((H, W, 3)).astype(np.uint8) result = Image.fromarray(rgb_data, 'RGB') result.save('restored_rgb.png')
The restored image shows Thomas Jefferson High School for Science and Technology with the flag written in the upper-left corner.
$ cat /etc/motd
Liked this one?
Pro unlocks every writeup, every flag, and API access. $9/mo.
$ cat pricing.md$ grep --similar