3 ms·
I've written my own zip and unzipping code. Basically the "top level" zip file section lives at the end of the zip file and contains pointers back into the fil
by danielvf 8y ago
I've written my own zip and unzipping code.
Basically the "top level" zip file section lives at the end of the zip file and contains pointers back into the file for the actual data. This is so that you can keep adding to a zip file without having to rewrite anything you have done previously - just append a few more files and then your updated directory at the end.
JPEG segments contain two special opening bytes, maybe a length, and then the actual data. So it would be trivial to have the last jpeg section in a jpeg file end with zip directory bytes. This directory could point back to data in other sections of the jpeg.
..my guess, anyway.
- plaguuuuuu 8y agoI can't exactly remember what JPG and ZIP look like, but yeah pretty much, I've done it before. What's surprising is that it works on Twitter. I tried the same thing with image hosts and the data got scrubbed. I guess they don't re-encode small images but I dunno.
- Laforet 8y agoIn other words twitter's backend did not sanitize image uploads properly.