Önkiadó ZIP-archívumok megvalósítása

David Oberhollenzer, a developer of the squashfs-tools-ng toolkit, proposed the concept of self-booting ZIP archives. The project adapts the mechanism of self-extracting ZIP archives to use a ZIP file as a bootable image, requiring no separate extraction to boot the system contained in this image. Furthermore, the image remains a complete ZIP archive that can be validated with the command "unzip -t."

Unlike TAR or CPIO formats, the ZIP format starts with only a small header, while the directory of all files and their offsets is stored at the end of the file, allowing arbitrary data to be placed almost at the beginning of the archive. In the presented project, the parameters of the ZIP archive header are tailored so that they can be used as a boot sector for MBR.

The first bytes of the archive "PK\03\04" are interpreted by the x86 processor as machine code corresponding to the 16-bit instructions of the i8086 processor "push %ax; dec %bx; add (%si),%ax." This is followed by a header containing version, flags, compression method, and modification time, which can be set so that during execution, the content corresponds to harmless instructions and an unconditional jump command jmp, transferring control to the main bootloader code.

The ZIP file also indicates the signature "1BADB002," which is recognized by bootloaders that support Multiboot as a sign of a compatible boot image (kernel). Because of this, the ZIP image can be booted using GRUB or with the option "-kernel" specified in QEMU. In this case, the bootloader extracts the uncompressed binary file, loads it into memory according to the header, and hands over control in 32-bit protected mode. The ZIP image can also be written to the first sector of the hard drive; in this case, the first 512 bytes are treated as a classic MBR.

Az összes kezdő betöltő kód, beleértve a ZIP és Multiboot fejlécet, a GDT táblázatot, a tartalom memóriába történő betöltésének logikáját és a védett módba való átállást, 817 bájtra sikerült zsúfolni. A ZIP-archívumban található fájlok tömörítés nélkül kerültek elhelyezésre (a tömörítési módszer mezőjében 0 szerepel), így a ZIP-archívum memóriába történő betöltése után közvetlenül hozzáférhetünk az archívumban található fájlokhoz, a ZIP-archívum végén található index (Central Directory) felhasználásával a legegyszerűbb fájlrendszer szimulálásához.

Forrás: opennet.ru

Megbízható hosting vásárlása weboldalak számára, DDoS védelemmel, VPS VDS szerverek. 🔥 Megbízható webtárhely vásárlása DDoS védelemmel, VPS VDS szerverek | ProHoster