Technology1 min read

Creating a self booting ZIP archive

By · Published by Everything Blog

In short

The boot.zip medium integrates a valid 512-byte boot sector alongside standard archive signatures to initialize hardware and switch to 32-bit protected mode. In addition to loading the internal ZIPHEAD.COM binary, the system outputs the contents of an embedded MESSAGE.TXT file during the launch phase. Rebuilding the package requires extracting its contents, configuring execution permissions on the included build script, and utilizing an installed Zlib library.

Key points

  • The archive contains the complete source code and necessary tools required to rebuild its…: The archive contains the complete source code and necessary tools required to rebuild itself from scratch.
  • Standard INT 13h BIOS calls allow the software to query geometry and execute directly fro…: Standard INT 13h BIOS calls allow the software to query geometry and execute directly from hard drives.
  • The uncompressed boot/ZIPHEAD.COM executable inside the archive incorporates a Multiboot…: The uncompressed boot/ZIPHEAD.COM executable inside the archive incorporates a Multiboot header for system compatibility.

Sources checked by our analysis pipeline: 1

So, after a debugging session the other day, I was having some shower thoughts regarding early userspace and initrd.

Linux initramfs supports unpacking CPIO, a stupid, simple, standardized format. In the discussion on whether to support TAR instead, much emphasize has been put on the fact that CPIO is standardized and less fragmented.

Luckily, Linux (the kernel) includes its own tool to produce the specific variant of the standard that it happens to implement. The standard CPIO tool is possibly the most cursed archiver under the SUN.

In the old DOS/WinDOS world, ZIP was probably the most wide spread and well known archive format, being displaced to some extend by the rise of RAR during the 2000s.

Because of the design of the format, ZIP lends itself to all kinds of polyglot trickery. Way back when, self extracting ZIP archives where a thing, EXE/ZIP polyglots that can be run and unpack themselves, which is useful if you don't have an archiver installed.

I don't think I need to explain where I am going with this, here is the resulting ZIP…

Technology