RED picoCTF Writeup The Best Way to Reveal Hidden Secrets in Images

🚩 Uncover the Secrets Hidden in Images! A Beginner’s Guide to CTF Steganography

In the world of CTF (Capture The Flag), image forensic challenges are deceptive. What looks like a simple picture often hides a secret message beneath its pixels. This article walks beginners through the “Image Forensics” workflow, using tools like file, exiftool, and zsteg to move from a curious observer to a flag-capturing pro!


🔍 Introduction

In security competitions, “Steganography” is the art of hiding data within other non-secret data. This guide demonstrates how to analyze a file named red.png by inspecting metadata, deciphering hidden clues, and performing LSB (Least Significant Bit) analysis to retrieve the final flag.

  • Tools Used: file, exiftool, zsteg, Python3
  • Objective: Identify a hidden Base64 string within an image and decode it.
  • Target Audience: CTF beginners and anyone interested in command-line forensics.

📝 Challenge Overview

Our target is a file called “red.png”.

  • Appearance: A simple 128×128 red square.
  • Condition: The only hint provided is: “Appearances can be deceiving; information is hidden somewhere inside.”

We will go beyond just “opening” the image and dive into the binary structure to find the truth.


🛠 Tools Used

Here are the powerful tools we will use for our investigation:

  • file: A basic command to reveal the true identity of a file.
  • exiftool: A tool to read metadata—the “resume” of a digital file.
  • zsteg: A specialized steganography tool that automatically detects hidden data in PNGs and BMPs.
  • Python3: Used for final data conversion (Base64 decoding).

🚀 Step 1: Verifying the File Type

First, we check if the file extension (.png) is legitimate or just a disguise.

Bash

$ file red.png
red.png: PNG image data, 128 x 128, 8-bit/color RGBA, non-interlaced

💡 Explanation:

The file command doesn’t trust extensions. Instead, it inspects the magic bytes (binary signature) at the start of the file. This confirms our target is indeed a valid PNG image.


🚀 Step 2: Inspecting Metadata

Next, we look for “hidden attributes” or comments attached to the image file.

Bash

$ exiftool red.png
...
Poem : Crimson heart, vibrant and bold,.
Hearts flutter at your sight..
Evenings glow softly red,.
Cherries burst with sweet life..
Kisses linger with your warmth..
Love deep as merlot..
Scarlet leaves falling softly,.
Bold in every stroke.

💡 Explanation:

exiftool displays metadata such as creation dates, GPS info, or custom comments. Here, we found a suspicious “Poem” field. In a CTF, anything unusual is a deliberate clue.


More information about exiftool can be found here.
exiftool in CTF: How to Analyze Metadata and Find Hidden Data


🚀 Step 3: Extracting the Hidden Clue

Look closely at the poem. If we take the first letter of each line, a message emerges:

  • Crimson
  • Hearts
  • Evenings
  • Cherries
  • Kisses
  • Love
  • Scarlet
  • Bold

Combined, it spells: “CHECKLSB”.

💡 Explanation:

LSB (Least Significant Bit) is a technique where the last bit of a pixel’s color value is changed to hide data. It’s invisible to the human eye but easily readable by tools. The poem was a direct hint on what to do next.


🚀 Step 4: LSB Analysis with zsteg

Since we know to check the LSB, we use zsteg. It isn’t installed by default, so here is how to set it up:

Installation:

Bash

$ sudo apt update
$ sudo apt install ruby ruby-dev imagemagick libmagickwand-dev
$ sudo gem install zsteg

Run Analysis:

Bash

$ zsteg red.png
...
b1,rgba,lsb,xy .. text: "cGljb0NURntyM2RfMXNfdGgzX3VsdDFtNHQzX2N1cjNfZjByXzU0ZG4zNTVffQ=="

💡 Explanation:

zsteg scans various bit planes of the image to find patterns. It successfully found a Base64-encoded string hidden in the LSB of the RGBA channels.


More information about zsteg can be found here.
zsteg in CTF: Detect and Extract Hidden Data from Images


🚀 Step 5: Decoding Base64

Finally, we translate the string cGljb0NURntyM2RfMXNfdGgzX3VsdDFtNHQzX2N1cjNfZjByXzU0ZG4zNTVffQ== into human-readable text.

Python

import base64
cipher = "cGljb0NURntyM2RfMXNfdGgzX3VsdDFtNHQzX2N1cjNfZjByXzU0ZG4zNTVffQ=="
plain = base64.b64decode(cipher).decode()
print(plain)

Result:

picoCTF{r3d_1s_th3_ult1m4t3_cur3_f0r_54dn355_}

💡 Explanation:

Base64 represents binary data using 64 different characters. It is easily identified by the = or == padding at the end. Python’s base64 library makes short work of decoding this.


🚩 Capture the Flag

We found the flag!

Final Flag:

picoCTF{r3d_1s_th3_ult1m4t3_cur3_f0r_54dn355_}

This challenge was a classic two-step puzzle: find the hint in the metadata, then apply that hint to analyze the pixel data.


📊 Summary

StepToolPurposeKey Result
1fileIdentify file typeConfirmed valid PNG
2exiftoolRead metadataFound hidden “Poem”
3(Manual)Decipher clueExtracted “CHECKLSB”
4zstegLSB AnalysisFound Base64 string
5python3Data DecodingRevealed the final flag

📖 Short explanations for commands/techniques used

  • file: Inspects the header of a file to determine its actual format.
  • exiftool: Accesses the “properties” of an image (author, camera specs, comments).
  • LSB (Least Significant Bit): A method of hiding data by altering the smallest unit of color info in a pixel.
  • Base64: A common encoding scheme in CTFs used to represent data as text.

💡 Beginner Tips

  • Watch for “=”: If a string ends with =, it is almost certainly Base64. Use tools like CyberChef or Python to decode it immediately.
  • Trust No Extension: Always use the file command first. Hackers love hiding zip files inside .jpg files.
  • Context Matters: If you find a random poem or weird comment, it’s rarely there for decoration. Treat every oddity as a potential key.

🎓 What you learn (takeaways)

  • Multi-layered Thinking: You learned how to pivot from one clue (metadata) to the next technique (LSB).
  • Tool Orchestration: You combined Linux commands, specialized Ruby gems, and Python scripts to solve a problem.
  • Forensic Foundations: You now understand the logic of how data is hidden and retrieved in digital forensics.

📚 Further Reading

Here are related articles from alsavaudomila.com that complement this challenge:

  1. Corrupted file picoCTF Writeup: How to Use Secret Binary Tactics for Direct Success
  2. Scan Surprise picoCTF Writeup: The Best Way to Reveal Hidden QR Secrets
  3. Ph4nt0m 1ntrud3r picoCTF Writeup: How to Master Secret Network Forensics and Succeed Fast