Zeecka zeecka

BabyStego

BreizhCTF 2023 - Steganography

BreizhCTF 2023 - BabyStego

Challenge details

EventChallengeCategoryPointsSolves
BreizhCTF 2023BabyStegoSteganography??????

shark

Baby breizh too doo tooo doo doo, Baby breizh too doo tooo doo doo, Baby breizh !

Author: Zeecka

TL;DR

The provided file is a PPM file in its P3 version. The file can be edited with a text editor. Its first lines contain its dimensions (300x300), followed by 400 lines corresponding to the 400 rows of pixels in the image. It is then enough to replace the second value 300 (corresponding to the number of rows) with 400 to reveal the flag.

Methodology

Breizh.png

To begin, we download the file and verify that it has not been altered by computing its signature.

$ md5sum Breizh.ppm

23bdea09b8958d59e716dbcc5639ed1a

The file command lets us check whether the retrieved file’s type matches its extension.

$ file Breizh.ppm

Breizh.ppm: Netpbm image data, size = 300 x 300, pixmap, ASCII text, with very long lines (3600)

The file is therefore a PPM image. A little research on the file format teaches us more about its structure. The file format is relatively simple, with a clear header containing the file version, the image dimensions and the maximum value for each color (respectively P3, 300 300 and 255 for our file).

$ head -n 3 Breizh.ppm

P3
300 300
255

The available formats P1, P2 and P3 provide black-and-white, grayscale and color images respectively. These formats are encoded using the ASCII table but can be compressed with a RAW format (P4, P5 and P6 respectively). The P3 format encoding provides a series of lines corresponding to the rows of the image. Each line is made up of a series of numbers making up the values of each pixel. The file has 400 lines of values, which is inconsistent with the header indicating that the image has 300 rows of pixels. We can therefore adjust the header value accordingly with a text editor: Breizh_corrige.ppm.

$ head -n 3 Breizh_corrige.ppm

P3
300 400
255

Breizh_corrige.png

We now have the entire image, and recover the flag along the way.

Flag

BZHCTF{ppM_Mpp}

Author: Zeecka