How does one find the start of the “Central Directory” in zip files?

后端 未结 4 1780
说谎
说谎 2021-02-05 04:20

Wikipedia has an excellent description of the ZIP file format, but the \"central directory\" structure is confusing to me. Specifically this:

This orderin

4条回答
  •  伪装坚强ぢ
    2021-02-05 04:39

    My condolences, reading the wikipedia description gives me the very strong impression that you need to do a fair amount of guess + check work:

    Hunt backwards from the end for the 0x06054b50 end-of-directory tag, look forward 16 bytes to find the offset for the start-of-directory tag 0x02014b50, and hope that is it. You could do some sanity checks like looking for the comment length and comment string tags after the end-of-directory tag, but it sure feels like Zip decoders work because people don't put funny characters into their zip comments, filenames, and so forth. Based entirely on the wikipedia page, anyhow.

提交回复
热议问题