A PNG image contains a ZIP file hidden inside it. We detect it with binwalk, extract it, and the flag is in the hidden folder.
| Platform | PicoCTF 2023 |
| Category | Forensics |
| Points | 100 pts |
| Difficulty | Beginner |
| Tools | binwalk file unzip |
The challenge provides a flag.png image and simply asks:
"Someone hid a flag in this image. But can you find it?"
The image opens normally in a viewer — it displays a regular image. Nothing suspicious at first glance. That's where the magic of forensics tools comes in.
Steganography is the practice of hiding data inside other files. Unlike cryptography, which encrypts data, steganography conceals it.
A common CTF technique: hiding a ZIP file at the end of a PNG image. The image viewer ignores everything that comes after the end of the image (IEND), but a ZIP file read from the end of the file is perfectly valid.
We always start with the file command to confirm the nature of the file:
$ file flag.png
flag.png: PNG image data, 512 x 512, 8-bit/color RGBA, non-interlaced
It is indeed a PNG. But let's dig deeper with binwalk.
binwalk is a tool that scans a file looking for known file signatures (ZIP, ELF, JPEG, etc.) hidden inside.
$ binwalk flag.png
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
0 0x0 PNG image, 512 x 512, 8-bit/color RGBA, non-interlaced
39739 0x9B3B Zip archive data, at least v1.0 to extract
39906 0x9BE2 Zip archive data, at least v2.0 to extract, name: secret/flag.png
40202 0x9D0A End of Zip archive, footer signature
Bingo. binwalk detects a ZIP file embedded at offset 39739, which itself contains a secret/flag.png file.
We automatically extract all detected files with the -e flag:
$ binwalk -e flag.png
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
0 0x0 PNG image...
39739 0x9B3B Zip archive data...
$ ls
flag.png _flag.png.extracted/
$ ls _flag.png.extracted/
9B3B.zip secret/
$ ls _flag.png.extracted/secret/
flag.png
We open the extracted image secret/flag.png in an image viewer — the flag is displayed there as text.
$ eog _flag.png.extracted/secret/flag.png
# or: xdg-open, feh, display...
The flag is deliberately hidden — follow the method, you've earned it. 💪
This challenge teaches two fundamental reflexes in CTF forensics:
file to verifybinwalk before any other analysisIn a real security context, this technique is used in malware to exfiltrate data hidden inside seemingly innocent images.
# Debian / Ubuntu / Kali
$ sudo apt install binwalk
# macOS
$ brew install binwalk
# pip
$ pip install binwalk
Manipulating HTTP cookies to enumerate hidden values and capture the flag. Technique: IDOR via a sequential cookie.
Discuss this writeup with the community on the CTFdojo Discord.
Join the Discord →