5 ms·
Repairing Corrupted ZIP Files by Brute Force Scanning in C
- eps 15y ago+1 for questioning or ignoring commonly accepted assumptions. Such as that compressed archives are hard if possible at all to repair. Or, say, that the optimal encoding is a very hard problem... something that David Huffman simply didn't know when he came up with his coding algorithm.
- daeken 15y agoVery cool article. If you are going to have a bunch of packed structs, though, it's often easier to wrap all the structs in #pragma pack(0)/pack() rather than putting the attribute on each member. This is an MSism, but it works in gcc.
- zx2c4 15y agoThanks a lot for this tip! Saves a lot of writing. I knew there had to be a better way... Ideally, I guess I wouldn't read directly into a struct, though, and instead use the right functions from endian.h to make the code portable, but ah! such is life when you're scrambling to save a zip and the post-graduation nostalgia is high and the post-coffee-crash caffeination is low.
- Garbage 15y agoThat's a real hacker's work! :) Though I recommend to read the nice post, here is the direct link to the code: http://git.zx2c4.com/BruteZip/tree/read.c http://git.zx2c4.com/BruteZip/tree/read.c
- VMG 15y agoWhen I use my hacking skills for something like this, I sometimes fear that I am wasting time and a normal person would have solved this problem faster and easier because he isn't focused on programming all the time. Nice to see that the fun way is the right way in this case.
- ZoFreX 15y agoI'mn afraid your blog post is almost completely unreadable in Chrome and Opera on Windows 7.
- dmn001 15y agoJust install the readbility firefox addon or go to: https://www.readability.com/read?url=http://blog.zx2c4.com/605 https://www.readability.com/read?url=http://blog.zx2c4.com/6...
- RyanKearney 15y agoHe said Chrome, so a Firefox addon won't do him much good.
- dmn001 15y agoIt looks bad on Firefox too. I also gave a link which works on any browser, and that includes Chrome.
- DisposaBoy 15y agoJust increase the font-size (ctrl + plus/equal). It's big, but look normal then.
- hmottestad 15y agoSeems ok in IE though. The page looks like it's a latex export.
- timdoug 15y agoActually, it's just a standard WordPress blog using the Latin Modern Roman typeface, which is based upon Computer Modern, the default in [La]TeX. (I dig the TeX-lookalike WP theme, but it should really use other @font-face formats for compatibility, e.g., WOFF and EOT; that might make it look better in other browsers.)
- zx2c4 15y ago
- bshep 15y agoJust out of curiosity, how long did it take to process the huge zip file?
- zx2c4 15y agoTook about 35 minutes.
- zdw 15y agoIt would be a great service to a whole lot of people for this method to be integrated into commonly used zip utilities.
- deleted 15y ago[deleted]
- sehugg 15y agoI'm surprised that zip -FF wouldn't work. Sounds like it needs your patch, although it looks from the InfoZip source that the fix functionality is spread throughout the zip parsing code rather than isolated into a small routine like this one. What would be interesting is a utility that could fix archives uploaded via FTP with ASCII mode accidentally turned on. This page claims to have a method: http://bukys.com/services/recovery/examples/ http://bukys.com/services/recovery/examples/
- nitrogen 15y agoThis must be a problem that a lot of hackers have solved, as I've written about how to solve that same problem in my (unpublished) idea archive.
- jewpiterjones 15y agoGUI plz
- kragen 15y agoHow is this different from what PKZIPFIX.EXE does?
- zx2c4 15y agohttp://blog.zx2c4.com/605#comment-5889 http://blog.zx2c4.com/605#comment-5889
- kragen 15y agoThe original author responded to my comment above with the link http://blog.zx2c4.com/605#comment-5889 http://blog.zx2c4.com/605#comment-5889, which is to a comment that claims that PKZIPFIX does the same thing. Unfortunately it's been [dead]ed.