hn.today

Creating a self booting ZIP archive

goliath32.com73 points11 comments
Screenshot of Creating a self booting ZIP archive

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.

Read on goliath32.com11 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Aristotle Expands into Rust

Aristotle Expands into Rust

Aristotle has expanded its formal verification platform to Rust, allowing developers to prove code meets specifications and contains no undefined behavior, including in unsafe blocks. It can also verify that Rust rewrites behave like their original C code, targeting critical software such as smart contracts and infrastructure. (harmonic.fun)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.