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

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.

Leave a Comment