A PDF that is also a ZIP. Companion PoC for the article "Why Gmail Blocks Your EXE (And How I Sent One Anyway)".
One file, two formats. Gmail sees a PDF and applies PDF scanning logic. 7-Zip, WinRAR, and every other standard archive tool see a ZIP and extract its contents. Both readings are correct.
This is the code used for my blog post.
Authorized testing only. Only run this against systems you own or have explicit written permission to test. Do not use it to send unsolicited attachments to anyone.
The generated file starts with %PDF- and ends with a valid ZIP
end-of-central-directory record (PK\x05\x06). Depending on what opens
it:
| Opened with | Sees |
|---|---|
| Any PDF viewer | A bank statement with a balance and an instruction note |
| 7-Zip / WinRAR / Explorer | A ZIP containing Statement_Launcher.bat, payload.exe, and README.txt |
The detailed statement PDF is not stored as a separate file in the ZIP.
It is base64-encoded inside Statement_Launcher.bat and materializes in
%TEMP% only when the launcher runs.
Email scanners classify attachments by reading the first few bytes of the
file. They see %PDF- and apply PDF scanning logic, which does not look
past the PDF structure. The ZIP portion — appended after the %%EOF
marker — is never treated as an archive, so its contents are never
inspected.
The trick is in the ZIP offsets. After concatenating the PDF and the ZIP, every offset in the ZIP central directory has to be shifted by the length of the PDF. Without that patch, most extractors fail. With it, the file is genuinely dual-natured.
Requires Python 3.8 or later.
pip install reportlabpython bank_stmt_polyglot.py -p payload.exe -o statement.pdf| Flag | Description |
|---|---|
-p, --payload |
File to embed in the ZIP (required) |
-o, --output |
Output filename, e.g. statement.pdf (required) |
--bank |
Bank name shown in the PDF (default: Adversary Craft Bank) |
--name |
Account holder name (default: Rajesh Kumar) |
--theme |
Base color for the document (see Themes below) |
# Default navy theme
python bank_stmt_polyglot.py -p payload.exe -o statement.pdf
# Named theme preset
python bank_stmt_polyglot.py -p payload.exe -o statement.pdf --theme red
# Custom hex color
python bank_stmt_polyglot.py -p payload.exe -o statement.pdf --theme "#1b5e20"
# Custom bank name (spaces allowed, use double quotes)
python bank_stmt_polyglot.py -p payload.exe -o statement.pdf \
--bank "Dummy Bank" --theme purpleAll colors are derived from a single base color.
| Name | Hex |
|---|---|
navy |
#0a2e5c |
blue |
#004c8f |
orange |
#f58220 |
red |
#8b0000 |
crimson |
#a6192e |
maroon |
#97144d |
green |
#1b5e20 |
teal |
#00518f |
purple |
#4a148c |
indigo |
#22409a |
You can also pass any #RRGGBB value directly.
After generation, confirm the file is valid in both formats.
As a PDF:
start statement.pdfOpens in the default PDF viewer with the expected theme and balance.
As a ZIP:
7z l statement.pdfExpected listing:
Statement_Launcher.bat
payload.exe
README.txt
Full chain (in a lab):
7z x statement.pdf -oextracted
cd extracted
Statement_Launcher.batThe detailed statement opens, and the payload runs in the background.
Statement_Launcher.bat contains a base64-encoded copy of the detailed
statement PDF. When executed it:
- Writes the base64 blob to a temp file in
%TEMP% - Reconstructs the PDF with
certutil -decode - Deletes the base64 staging file
- Opens the PDF in the default viewer
- Runs
payload.exesilently withstart "" /b
The launcher does not write outside of %TEMP%.
janus-file/
├── README.md
├── LICENSE
└── bank_stmt_polyglot.py
- Python 3.8+
- ReportLab for PDF generation
- 7-Zip or WinRAR on the test host to extract the archive portion
MIT. See LICENSE for the exact text.
This is research code. It exists to help defenders understand a specific class of email attachment scanner bypass. Running it against systems you do not own or have written permission to test is illegal in most jurisdictions and is not what this project is for.