Description
Every file gets a flag.
The SOC analyst saw one image been sent back and forth between two people. They decided to investigate and found out that there was more than what meets the eye here.
Setup
Download the flag.png file from the artifacts server.
wget https://artifacts.picoctf.net/c/260/flag.pngSolution
- Step 1Analyze the PNG file with binwalkRun binwalk to identify embedded data in the PNG file. The output shows a ZIP archive embedded at offset 0x9B7C containing a secret/flag.png file:
binwalk flag.pngDECIMAL HEX DESCRIPTION 0 0x0 PNG image, 512 x 504, 8-bit/color RGBA, non-interlaced 41 0x29 Zlib compressed data, compressed 39739 0x9B3B Zip archive data, at least v1.0 to extract, name: secret/ 39804 0x9B7C Zip archive data, at least v2.0 to extract, compressed size: 2944, uncompressed size: 3095, name: secret/flag.png 42983 0xA7E7 End of Zip archive, footer length: 22 Learn more
binwalk is a firmware and file analysis tool that scans a binary for known magic-byte signatures. It recognizes hundreds of file formats - ZIP, gzip, PNG, ELF, JPEG, and more - by comparing byte patterns at every offset against its signature database. When it finds a match, it reports the decimal and hexadecimal offset along with a human-readable description.
This technique works because most file formats are self-delimiting: they start with a recognizable header (a "magic number") and often end with a trailer. A ZIP archive begins with the bytes
PK\x03\x04; a PNG starts with\x89PNG\r\n\x1a\n. Concatenating a valid PNG with a valid ZIP produces a file that image viewers display correctly (they stop at the PNG IEND chunk) while ZIP-aware tools see the appended archive. This is a classic polyglot file technique used in both steganography and malware delivery.In digital forensics, binwalk is routinely applied to firmware dumps, memory images, and suspicious attachments to surface embedded executables, configuration files, or compressed archives. The
-eflag extracts all recognized components automatically, making it a powerful first step in any file analysis workflow. - Step 2Extract the embedded ZIP archiveUnzip the PNG file directly (you could also use binwalk -e flag.png):
unzip flag.pngLearn more
Because the PNG file is simultaneously a valid ZIP archive (a polyglot), standard tools that look for the ZIP central directory at the end of the file will happily extract it.
unzipfinds the end-of-central-directory record regardless of what precedes it, sounzip flag.pngworks exactly likeunzip archive.zip.Alternatively,
binwalk -e flag.pngcarves out all detected archives and writes them to a_flag.png.extracted/directory. Both methods achieve the same result; the directunzipcall is slightly faster since binwalk would need to re-scan. In real forensic workflows,binwalk -eis preferred because it handles nested archives (archives within archives) and formats other than ZIP automatically. - Step 3Navigate and view the flagChange to the secret directory and open the flag image:
cd secreteog flag.pngNote:eogis a Linux image viewer and can be installed withsudo apt install eogLearn more
The extracted
secret/flag.pngis a separate, independent image file that contains the flag rendered as visible text. This two-layer approach - hiding a file-within-a-file, where the inner file is itself an image - is a straightforward demonstration of steganography by appending (distinct from bit-plane steganography where data is hidden within pixel values).On headless servers or WSL environments where GUI tools aren't available, you can still read image-embedded flags using
strings secret/flag.pngif the text is stored literally, or convert to text withtesseract secret/flag.png stdout(OCR). If the flag is purely visual, transferring the file to a local machine withscpand opening it there is the most reliable approach.
Related guides
Steganography Techniques for CTF Competitions
A systematic guide to stego triage: file-within-file extraction, LSB analysis, metadata inspection, and audio spectrograms.
How to Read and Analyze Hex Dumps
Appended files show up as unexpected bytes in a hex dump. Learn to spot magic bytes and use binwalk to extract embedded content.
Flag
picoCTF{Hiddinng_An_i...678a337}
The flag is displayed in the image and can be seen with an image viewer.