PolyZip
(Nothing.. is.. Safe..)
PolyZip is a Python 3 command-line tool that embeds ZIP archives into a wide range of media and document formats—PNG, JPEG, GIF, PDF, BMP, WebP, TIFF, WAV, MP3, FLAC, OGG, AVI, MKV, WebM, FLV, ICO, CUR, ICNS, MP4, MOV, M4A, EXE, DLL, ELF, MSI, TTF, OTF, and WOFF —by leveraging each format's trailing-data tolerance or internal chunk/atom structure. For PNG, it injects the ZIP archive into the first IDAT chunk and corrects central directory offsets; for JPEG/GIF/PDF, it appends ZIP data after the EOI/trailer/EOF markers; for RIFF-based formats (BMP, WebP, WAV, AVI), it appends ZIP data beyond the declared chunk size; for TIFF, MP3, FLAC, OGG, ICO/CUR/ICNS, MP4/MOV/M4A, ELF, MSI, and font formats (TTF/OTF/WOFF), it appends after the last valid header/frame/atom and updates ZIP offsets accordingly. The resulting files display normally in standard viewers yet remain fully valid ZIP archives when renamed to .zip or extracted with standard tools.
🆕 NEW: Enhanced with full encryption support! PolyZip 2.1.2 now includes AES-256 encryption for both file hiding and chat functionality. Hide encrypted files or create encrypted chat logs within any supported file format. All encrypted data is completely invisible to external analysis and protected by military-grade encryption using Argon2id password derivation (with Scrypt fallback) or secure key files.
Original PNG+ZIP polyglot technique by DavidBuchanan314; extended multi-format embedding, multi-file packing, extraction, detection, and encrypted chat implementation by InfoSecREDD.
Features
Create polyglot files from multiple formats:
- PNG + ZIP
- JPG + ZIP
- JPEG + ZIP
- GIF + ZIP
- PDF + ZIP
- BMP + ZIP
- WebP + ZIP
- TIFF + ZIP
- WAV + ZIP
- MP3 + ZIP
- FLAC + ZIP
- OGG + ZIP
- AVI + ZIP
- MKV + ZIP
- WebM + ZIP
- FLV + ZIP
- ICO + ZIP
- CUR + ZIP
- ICNS + ZIP
- MP4 + ZIP
- MOV + ZIP
- M4A + ZIP
- EXE + ZIP
- DLL + ZIP
- ELF + ZIP
- MSI + ZIP
- TTF + ZIP
- OTF + ZIP
- WOFF + ZIP
🔒 Comprehensive Encryption System:
- Encrypted File Hiding: Secure file embedding with AES-256-GCM encryption
- Encrypted Chat Logs: Create secure chat logs hidden in any supported file format
- Military-Grade Security: AES-256-GCM encryption with authenticated encryption
- Robust Key Derivation: Argon2id password derivation with Scrypt fallback for maximum compatibility
- Key File Authentication: Auto-generated secure keys with file-based authentication
- Perfect Steganography: Files appear completely normal to external analysis
- Tamper Detection: GCM authentication prevents modification without detection
- Export Options: Chat export to HTML, JSON, or text formats
Automatic detection of embedded content
Extract hidden files from polyglot containers
Support for multiple files in a single container
Automatic virtual environment management
Cross-platform compatibility
Installation
- Clone the repository:
git clone https://github.com/InfoSecREDD/PolyZip.git
cd PolyZip
- Make the script executable:
chmod +x poly.py
- Run the script - it will automatically set up the required environment:
./poly.py
Usage
Packing Files
Embed one or more files into a cover file:
./poly.py pack cover.[format] file1 [file2 ...] output.[format] [--key=file.key|--password=pass]
Basic Examples:
# Hide files without encryption
./poly.py pack cover.png secret.txt output.png
# Hide multiple files
./poly.py pack cover.jpg file1.txt file2.pdf output.jpg
🔒 Encrypted File Hiding:
# Hide files with password encryption
./poly.py pack cover.png secret.txt encrypted.png --password=MySecurePass123
# Hide files with key file encryption (auto-generates key if missing)
./poly.py pack cover.pdf confidential.doc encrypted.pdf --key=mykey.key
# Hide multiple files with encryption
./poly.py pack cover.mp4 file1.txt file2.jpg encrypted.mp4 --password=SecretPass
Extracting Files
Extract hidden files from a polyglot container:
./poly.py extract input.[format] [output_directory] [--key=file.key|--password=pass]
If no output directory is specified, files will be extracted to a directory named after the input file.
Basic Examples:
# Extract unencrypted files
./poly.py extract hidden.png
# Extract to specific directory
./poly.py extract hidden.png extracted_files/
🔒 Encrypted File Extraction:
# Extract password-protected files
./poly.py extract encrypted.png decrypted/ --password=MySecurePass123
# Extract key-protected files
./poly.py extract encrypted.pdf decrypted/ --key=mykey.key
# Extract with automatic directory creation
./poly.py extract encrypted.mp4 --password=SecretPass
Detecting Embedded Content
Scan files for embedded content:
./poly.py detect [input.[png|jpg|jpeg|gif|pdf|bmp|webp|tiff|tif|wav|mp3|flac|ogg|avi|mkv|webm|flv|ico|cur|icns|mp4|mov|m4a|exe|dll|elf|msi|ttf|otf|woff]]
If no file is specified, it will scan the current directory for all supported files.
Example:
./poly.py detect
🔒 Encrypted Hidden Chat System
Creating Encrypted Chats
Create a new encrypted chat hidden in any file format:
With Password Protection:
./poly.py chat create cover.[any] output.[any] "Chat Title" --password=yourpassword
With Key File Authentication:
./poly.py chat create cover.[any] output.[any] "Chat Title" --key=keyfile.key
Examples:
# Create password-protected chat in PNG
./poly.py chat create photo.png secret_chat.png "Team Communications" --password=SecurePass123
# Create key-protected chat in PDF
./poly.py chat create document.pdf secret_chat.pdf "Private Discussion" --key=team.key
# Create unencrypted chat in JPEG
./poly.py chat create image.jpg chat.jpg "Public Chat"
# Works with any file format
./poly.py chat create video.mp4 secret_chat.mp4 "Mission Planning" --password=classified
Adding Messages
Add messages to existing chats:
./poly.py chat add chat.[any] "Sender Name" "Message content" [encryption_option]
Examples:
# Add to password-protected chat
./poly.py chat add secret_chat.png "Alice" "Hello team!" --password=SecurePass123
# Add to key-protected chat
./poly.py chat add secret_chat.pdf "Bob" "Mission status update" --key=team.key
# Add to unencrypted chat
./poly.py chat add chat.jpg "Charlie" "Public message"
Reading Chats
Display chat contents:
./poly.py chat read chat.[any] [--format=terminal|json|html] [encryption_option]
Examples:
# Read password-protected chat
./poly.py chat read secret_chat.png --password=SecurePass123
# Read key-protected chat with JSON format
./poly.py chat read secret_chat.pdf --format=json --key=team.key
# Read with HTML format
./poly.py chat read chat.mp4 --format=html
Exporting Chats
Export chats to files:
./poly.py chat export chat.[any] output.[txt|json|html] [encryption_option]
Examples:
# Export to HTML
./poly.py chat export secret_chat.png backup.html --password=SecurePass123
# Export to JSON
./poly.py chat export secret_chat.pdf backup.json --key=team.key
# Export to text
./poly.py chat export chat.jpg backup.txt
🔐 Security Features
- AES-256-GCM Encryption: Military-grade encryption with authenticated encryption
- Argon2id Password Derivation: Secure password hashing resistant to GPU attacks (with Scrypt fallback for compatibility)
- Key File Authentication: Auto-generated secure keys for file-based authentication
- Perfect Steganography: Hidden data is completely undetectable by external analysis
- Tamper Detection: GCM authentication prevents modification of encrypted data
- No Information Leakage: Even if extracted, encrypted data remains unreadable
💡 Pro Tip: Files with hidden chats can be opened normally in any image viewer, PDF reader, or media player. The hidden chat is completely invisible to external tools and analysis.
Technical Details
Our tool leverages each format's tolerance for extra or embedded data beyond its standard file structure. Most viewers stop reading at defined end markers or fields and ignore trailing bytes, allowing a valid ZIP archive to be appended without affecting normal display.
PNG + ZIP
- Chunk-based format: PNG files begin with an 8-byte signature, followed by a sequence of chunks (4-byte length, 4-byte type, chunk data, 4-byte CRC). IDAT chunks contain compressed image data; decoders concatenate all IDAT payloads based on declared lengths and verify each chunk's CRC. Any extra bytes beyond a chunk's specified length (including our appended ZIP) are ignored by standard PNG parsers.
- Embedding approach: We insert the ZIP archive into the first IDAT chunk after its declared data, update the length and CRC so the image remains valid, and leave IEND untouched. Viewers decode the image normally, while the ZIP central directory offsets point into the embedded data.
JPEG + ZIP
- Marker-based format: JPEG streams consist of markers (
FF D8 SOI, APPn segments, FF DA SOS, compressed scan data, FF D9 EOI). Parsers stop decoding at the EOI marker and ignore any trailing bytes.
- Embedding approach: We split the file at the final
FF D9, write out the image data, then append the ZIP archive. ZIP offsets are fixed so renaming to .zip yields a valid archive, while image viewers ignore the appended data.
GIF + ZIP
- Block-oriented format: GIF files start with a header (
GIF87a/GIF89a), logical screen descriptor, optional color tables, data blocks, and end with a single trailer byte (0x3B).
- Embedding approach: We truncate the file at the trailer, append our ZIP archive, and adjust ZIP pointers. GIF viewers stop at
0x3B and ignore the ZIP data.
PDF + ZIP
- Text-based format: PDF documents end with a
%%EOF marker (often followed by a newline). PDF readers scan backwards to locate the last %%EOF and ignore any content that follows.
- Embedding approach: We write out the PDF up to and including the final
%%EOF, then append the ZIP archive. PDF viewers load the document normally, while ZIP tools see a playable archive.
BMP + ZIP
- Header-driven format: BMP files start with 'BM', followed by a 4-byte file size field at offset 2 (little-endian), reserved fields, and a pixel-data offset pointer. Readers rely on the declared file size or pixel-data offset to load image data, ignoring trailing data.
- Embedding approach: We append the ZIP archive after the pixel data, then fix ZIP offsets. Standard image loaders read only the declared bytes and dismiss extra content.
WebP + ZIP / WAV + ZIP / AVI + ZIP
- RIFF container: These formats use a RIFF header (
RIFF, 4-byte total size, format tag) followed by sub-chunks (e.g., WEBP, WAVE, AVI ). Parsers read chunks based on length fields and ignore bytes beyond the container size.
- Embedding approach: We append the ZIP archive after the declared RIFF data and update ZIP offsets so the archive remains valid.
TIFF + ZIP
- Tagged format: TIFF files begin with an endianness marker (
II/MM), magic number 42, and an offset to the first Image File Directory (IFD). Readers traverse IFD pointers and image data strips; trailing bytes are never referenced.
- Embedding approach: We append the ZIP archive at the end, then update ZIP offsets. TIFF viewers ignore the extra data.
MP3 + ZIP
- Frame-based format: MP3 audio is composed of sequential frames, each with a frame sync header (
0xFFF) and payload. Decoders process frames until no valid header remains; any extra bytes at the end are ignored.
- Embedding approach: We append the ZIP archive after the last frame and fix ZIP offsets; audio players play all frames and disregard the ZIP.
FLAC + ZIP
- Block-based format: FLAC files start with
fLaC, followed by metadata blocks (ending with the LAST-METADATA-BLOCK flag) and audio frames. Decoders read until the last audio frame and ignore trailing data.
- Embedding approach: We append the ZIP archive after the final frame and adjust ZIP offsets.
ICO + ZIP / CUR + ZIP
- Directory-entry format: Icon/Cursor files begin with an ICONDIR header (entry count) and ICONDIRENTRY array (each with image data offset and size). Readers load images based on these offsets and ignore data beyond.
- Embedding approach: We append the ZIP archive after all image entries and fix ZIP offsets.
MP4 + ZIP / MOV + ZIP
- ISO BMFF container: MP4/MOV files are organized in boxes (4-byte size, 4-byte type, data). Parsers read each box based on its size field and disregard any extra bytes after the final box.
- Embedding approach: We append the ZIP archive after the last atom and update ZIP offsets so renaming to
.zip yields a valid archive.
EXE + ZIP / DLL + ZIP