Blacksun Software logo
Blacksun Software

Hidden in Plain Sight

The Art and Logic of Binary File Concatenation & Steganography

Imagine sending a harmless picture of a kitten to a friend, while hidden silently inside that exact same file is a complete .zip archive containing documents, code, or private data. To a standard image viewer, it is just a picture. To an archive manager like 7-Zip, it is a fully functional zip file.

This is not sci-fi—it is a classic steganographic technique known as creating a polyglot file (a single file that remains completely valid under two different file format specifications simultaneously). Below is a complete guide covering how to use it, its practical applications, and the structural logic that makes it possible.

Part 1: How to Create a Polyglot File

Creating a polyglot file requires no specialized software or complex scripting. You can construct one using only native command-line utilities built directly into your operating system.

1. On Windows (Command Prompt)

Place your cover image (e.g., cover.png) and the archive you wish to hide (e.g., secret.zip) into the same working directory, open cmd, and run:

copy /b cover.png + secret.zip output.png
Important: The /b switch is critical. It explicitly instructs Windows to process the inputs as raw binary data rather than text streams.

2. On macOS & Linux (Terminal)

Open Terminal, navigate to your target folder, and use the cat (concatenate) command:

cat cover.png secret.zip > output.png

Part 2: Accessing the Hidden Data

Once generated, output.png functions seamlessly across multiple contexts depending on the tool used to open it:

📷 Viewing as an Image
Double-clicking output.png will open it in standard image viewers (Windows Photos, Apple Preview, web browsers). The image renders perfectly without error.
📦 Extracting the Hidden ZIP
Launch an archive manager (like 7-Zip or WinRAR), select File > Open, and choose output.png. The application will bypass the image wrapper and reveal the zipped archive contents ready for extraction. Alternatively, renaming the extension to output.zip allows standard OS unzipping tools to process it directly.

Practical Use Cases

Part 3: The Underlying Logic

How can two separate programs read the exact same file and both determine it is 100% valid? It comes down to fundamental differences in parser traversal directions.

1. Top-Down Reading (The Image Parser)

Image viewers read files sequentially from byte 0x00 downwards. A PNG parser parses metadata blocks until it reaches the official End-of-File marker—the IEND chunk. Upon encountering IEND, the renderer halts execution and ignores all subsequent bytes sitting at the tail end of the file.

2. Bottom-Up Reading (The ZIP Parser)

Archive extractors operate in reverse. Rather than starting at byte zero, a ZIP parser jumps directly to the very end of the file and scans backward to locate the Central Directory structure. Because secret.zip was appended to the end, its trailer and directory index remain fully intact at the file's tail.

Golden Rule of Concatenation:
Polyglot File = [Top-Down Format (PNG/JPG)] + [Bottom-Up Format (ZIP)]