mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #467] pkzip format fails on ChristmasGIFts.zip #186
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#186
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @magnumripper on GitHub (Jan 6, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/467
Originally assigned to: @jfoug on GitHub.
http://www.openwall.com/lists/john-users/2013/12/23/1
http://corkami.googlecode.com/files/ChristmasGIFts.zip
Solar: "I think zip2john might be confused by the very first entry in the .zip file being a directory, or it could be some other issue."
@magnumripper commented on GitHub (Jan 6, 2014):
Had a look. The directory entry is not a problem. Using -nm and/or -co does not seem to help but I do not know the correct password for the file.
@magnumripper commented on GitHub (Jan 6, 2014):
-costores simple.com, simple.exe and simple.pdf-nmstores macho.asm, elf.asm and and simple.com, last one inline.Of all above, simple.com is stored, the rest are compressed.
I'm starting to think it's actually a bug (eg. false early reject) in the format, not in zip2john.
@magnumripper commented on GitHub (Jan 6, 2014):
OK, password was 123456 (doh! How could I not try that!?)
Bug fixed in
829ea4c, maybe in a coarse way: Two early-rejection tests had to be disabled. Hopefully @jfoug can re-enable them after investigation and tuning.@jfoug commented on GitHub (Jun 11, 2014):
Looking into this issue again. I reopened it.
NOTE, the hash in question has 3 hashes in it. The 3rd is a 0x2a .com file, that is STORED. If you remove that hash, then pkzip detects the 123456 password just fine. SO, the logic appears to be in stored files. THAT MAKES SENSE, since we are not dealing with an implode stream. All of the quick out logic was for an implode stream. If certain bit patterns were seen there, then it could NOT be a valid stream. But for a stored object, this would not make sense (also a shrunk type, i.e. older zip, but I do not think those can be encrypted).
I will be continuing this, but it MAY be that we can re-enable, and simply change the zip2john to NOT insert stored blobs. The nice thing about stored blobs was that if it was a small one, then we could put the whole thing in the file, and 'know' that we had a good decode.
It has been so long since i worked on pkzip, I will have to dig in deeper, and simply remember what I did.
@jfoug commented on GitHub (Jun 14, 2014):
814c81efixes some of the issues. I moved the check for if((C&6)==6) bail_fail to after the detection of a stored file. Checking a byte like this in a stored file, can not be done. I also added ability to have 0 byte checksum test (the first test). There were 2 an 1. It looks like version 0x314 is made with 7z, and it looks like it does not use check sum detection. HOWEVER, the ChristmasGIFts.zip file was a 'normal' 0x14 version, and it did not use checksum test code either :( I added new switches to zip2john to allow forcing 0 bytes. Unfortunately, there is no way to know in advance, unless you are able to crack one of the .zip's in some set, and know the rest have been built that way. I do not have a work around at this time. It may be that there is some hardening project for some *nix distro, that has removed the checksum validation, and that is what ChristmasGIFts.zip was made with. I would like to be able to auto-detect this, and set a 0 byte amount to test for checksums, but I do not know how to do it at this time.The code does work better, BUT it still is not fully correct. I added ability to choose a single file (in zip2john), to force set 2 byte or 0 byte checksum logic, and a few other things. With that logic in there, I was able to crack every file within ChristmasGIFts.zip EXCEPT bin/simple.zip That one still has inflate problems within the code. It trips the if((C&6)==6) bail_fail, but even if you comment that out, it still fails, falling down into the fixed lookup table section, and failing. I need to dig into the code, and also look at zip dumps for this non-encrypted, to just SEE wtf this zip-blob is doing. I have not started on that yet.
But I did want to get these fixes out there. They get past a lot of the issues. Even with the original code (commented out), this failure would have been there (the bin/simple.zip failing). But these quick out tests are back. I just have to figure out HOW to detect when checksum tests are not used.
@jfoug commented on GitHub (Jun 15, 2014):
Found all problems.
When I get these changes tested, pkzip will have the quick checks BACK in, AND the zip2john has many more flags for force creating different things (singleton files, 2 byte, 0 byte check sums, etc, and forcing getting the checksum data from timestamp). NOW the problem is when presented with an unknown zip file, where you do not know where it was created. zip2john likely will not have enough smarts to always create the zip data properly.
What we MAY have to do, is to change the structure of the .zip blob. We may have to put out the timestamp AND crc blob as a checksum, and simply check both of them. If either match, we assume we have a checksum match. BUT this will change the signature of the .zip blob. I guess I could do a
pkzipv2signature, or something like that, and have zip_fmt handle both types?I was going to close this bug out, but now I think I have to leave it for a while :(
@jfoug commented on GitHub (Jun 15, 2014):
Speed went from:
$ ../run/john -test=5 -form=pkzip
Benchmarking: PKZIP [32/32]... DONE
Many salts: 1688K c/s real, 1688K c/s virtual
Only one salt: 1825K c/s real, 1841K c/s virtual
to
$ ../run/john -test=5 -form=pkzip
Benchmarking: PKZIP [32/32]... DONE
Many salts: 5941K c/s real, 5957K c/s virtual
Only one salt: 4160K c/s real, 4160K c/s virtual
That checksum test is huge. It eliminates 255 out of 256 (or 65535 out of 65536 for 2 byte checksums). The 2nd test eliminated 1/2 of anything left over. Those 2 tests are the big ones for speed.
@jfoug commented on GitHub (Jun 15, 2014):
b7a49aeshould fix it all. There is only 1pkzip2item within our test data, and it is from the ChristmasGIFts.zip data. I used 2 byte checksum, since that file IS 2 byte checksum. It was simply using the timestamp data, and NOT the crc.Within john2zip, I removed a lot of the extra options (not needed). I did keep -f2 (force 2 byte). Now zip2john simply makes
pkzip2hashes, which contain both type of checksums (top of crc32 and the timestamp). pkzip_fmt will test them both.pkzip_fmt still uses the
pkziphashes. In that case, it will simply copy the checksum data into checksum2, so that the if logic will simply test the same value twice.This bug is now close, as far as I can tell.