技术博客作者展示了一项名为“boot.zip”的技术实验,该文件既是合法的ZIP压缩归档,也是可自启动的x86引导程序 1。这一多语言混合(polyglot)实现利用了ZIP文件头中的字段(如时间戳和标志位)恰好对应有效8086机器码的特性 1。具体而言,设计者利用Phil Katz名字首字母“PK”(十六进制0x50, 0x4B)在x86架构下分别对应“push ax”和“dec bx”指令的特性 1。此外,ZIP本地文件头的修改时间字段被用于放置跳转指令(0xEB),以跳转到实际的引导代码 1。
该文件遵循Multiboot规范,Magic Value为0x1BADB002,且包含其自身的源代码 1。在实际部署方面,boot.zip支持通过QEMU直接内核启动,命令为 qemu-system-i386 -kernel boot.zip 1;也支持写入软盘镜像并通过BIOS传统方式启动,命令为 dd if=boot.zip of=floppy.img conv=notrunc 1。已测试兼容硬件包括Pentium MMX、i486 DX2和Am386DX-40 1。
A technical experiment known as "boot.zip" demonstrates that a single file can function simultaneously as a valid ZIP archive and an executable x86 bootloader 1. The creator achieved this polyglot status by exploiting specific fields within the ZIP file header, such as timestamps and flags, which coincidentally map to valid 8086 machine code instructions 1. For instance, the "PK" signature associated with Phil Katz translates to the assembly commands push ax and dec bx on x86 architectures, while the modification time field in the local file header is repurposed to hold a jump instruction (0xEB) that directs execution to the actual boot code 1.
The resulting file strictly adheres to the Multiboot specification, identified by the magic value 0x1BADB002, and notably contains its own source code within the archive structure 1. Users can launch the kernel directly using QEMU with the command qemu-system-i386 -kernel boot.zip, or emulate traditional BIOS booting by writing the image to a floppy disk via dd if=boot.zip of=floppy.img conv=notrunc 1. Testing confirms compatibility with legacy hardware platforms, including Pentium MMX, i486 DX2, and Am386DX-40 processors 1.
评论
还没有评论,欢迎留下第一条。