提取嵌入的 zip 文件后找不到中央目录签名的结尾

逆向工程 解密 十六进制
2021-06-23 12:39:33

我正在学习速记并找到了这个例子

我已经按照说明操作,但是当我在更改文件内的文件名后写出一个新的 zip 文件时,我得到了这个:

unzip nospaces.zip
Archive:  nospaces.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
note:  nospaces.zip may be a plain executable, not an archive
unzip:  cannot find zipfile directory in one of nospaces.zip or
        nospaces.zip.zip, and cannot find nospaces.zip.ZIP, period.

我发现我可以zip -FF --out用来“修复” zip 文件并提取嵌入的内容,但想了解在 0x504B0304 和 0x506B0506 之间保存原始文件的内容时我可能做错了什么

我在 WinHex(32 位 Windows 10 VM)和 HexFiend(OSX 10.10.5 - 64 位)中得到了相同的结果。

谁能建议我在编辑文件时可能做错了什么?

在此处输入图片说明

在此处输入图片说明

1个回答

如果您考虑实际的 PKZipformat 每个 PKZIP trealer 由 0x506B0506 和后跟 18 个字节组成,处理其他信息,如磁盘数量、中央目录总数、它们的大小......)所以要正确雕刻 zip 文件,您应该复制块从偏移量 0xCB8E: ZIP 文件的开头

偏移 0xFA16

PKZip 文件的结尾

结果是一个有效的 ZIP 文件。