
Developer Creates a 100% Valid ZIP File That Boots From BIOS and Doubles as a Multiboot OS Image
David Oberhollenzer, aka Goliath, created a 100% valid ZIP archive that can also boot through BIOS or a Multiboot-compatible loader, using an uncompressed first file and carefully chosen header bytes.
Developer David Oberhollenzer, aka Goliath, created a 100% valid ZIP archive that is also a BIOS-bootable image and a Multiboot-compatible operating system image. The archive can be unpacked like a normal ZIP file, booted with Linux's GRUB, QEMU, or another Multiboot-compatible loader, or written to a floppy and booted directly from BIOS on a compatible PC. The trick relies on ZIP metadata being stored at the end of the archive and on an uncompressed first file named ZIPHEAD.COM.
How the ZIP stays valid
Unlike many file types, a ZIP archive keeps its file directory metadata at the end, while the data consists of files in sequence. Each file entry begins with 'PK' followed by bytes 03 04, then metadata such as the name and extra or comment fields, followed by the file's contents. Any file can be stored uncompressed, and Goliath used that option for the first file, ZIPHEAD.COM, which sits at the start of the archive.
Multiboot support
Goliath said it was 'easy' to make the ZIP a valid Multiboot system image. A valid image only needs bytes 0x1BADB002 in the first 8 KiB, followed by flags and a checksum. He placed that value in ZIPHEAD's data, along with the location of the bootloader. GRUB or QEMU then use that initialization information, while the actual bootloader is in ZIPHEAD's uncompressed data.
BIOS boot trick
Making the same archive bootable through a standard PC BIOS took more work. The BIOS reads the first exact 512 bytes of a disk and treats it as bootable if those bytes end with 0x55AA, then starts executing from the first byte. Goliath placed 0x55AA at position 510 of the ZIP, inside ZIPHEAD's contents, without corrupting the Multiboot image.
Turning headers into instructions
When the BIOS runs code starting from the first byte, the ZIPHEAD header is not simply unusable. The first four bytes represent CPU instructions that do not write anything to memory, aside from a push to the stack. Goliath then adjusted metadata values so they represented either harmless instructions or operations useful for setting up the boot process, including using modification time bytes as instructions to jump further down the data. Choosing bytes that are valid CPU instructions, useful boot code, and a valid ZIP file header at the same time is far trickier than the individual steps suggest.
Sources: Tom's Hardware
SiTech — AI-powered web development
We build fast, modern websites and bring AI into real business workflows. Have a project or a question? We'd love to help.