A self-booting ZIP archive combines a conventional compressed file collection with code that can start a computer. The archive contains its own source and build tools, plus an uncompressed file named ZIPHEAD.COM whose opening bytes form a valid ZIP local-file header and whose contents include executable boot code and a Multiboot header. It can be launched as a kernel by QEMU, written to a floppy image and booted through BIOS, or run on older x86 PCs. Its boot code loads additional sectors, enables the A20 address line, and switches the processor into 32-bit protected mode. Rebuilding the archive requires restoring the build script’s execute permission and installing zlib.
The construction exploits ZIP’s layout: file entries begin with local headers, while a central directory and footer at the end let readers locate and extract files. This makes ZIP suitable for combining with another format, but the footer’s variable-length comment complicates reliable parsing, and crafted archives can appear different to different programs. Many modern ZIP readers avoid such ambiguity by scanning forward and requiring entries to be contiguous, which rules out arbitrary data before or between files. The key is therefore to make every byte serve both purposes: the archive starts with a valid ZIP entry, while the same bytes and embedded code satisfy boot and Multiboot requirements. The result illustrates both ZIP’s polyglot potential and the compatibility limits imposed by stricter readers.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.