[GH-ISSUE #275] zip2john produces infiles that can only be cracked with a same-endian build of John. #36

Closed
opened 2026-10-14 02:50:19 +07:00 by bsakaguchi · 16 comments
Owner

Originally created by @magnumripper on GitHub (Apr 18, 2013).
Original GitHub issue: https://github.com/openwall/john/issues/275

Some of the hex fields (integers) are in machine's endianness.

We need to test all xx2john programs for this issue, there are likely more of them.

Originally created by @magnumripper on GitHub (Apr 18, 2013). Original GitHub issue: https://github.com/openwall/john/issues/275 Some of the hex fields (integers) are in machine's endianness. We need to test all xx2john programs for this issue, there are likely more of them.
bsakaguchi 2026-10-14 02:50:19 +07:00
Author
Owner

@magnumripper commented on GitHub (Feb 16, 2014):

Note to self: How on earth is it that the format passes self-test on BE while the test vectors are in LE?!

Is my initial observation correct at all?

<!-- gh-comment-id:35176223 --> @magnumripper commented on GitHub (Feb 16, 2014): Note to self: How on earth is it that the format passes self-test on BE while the test vectors are in LE?! Is my initial observation correct at all?
Author
Owner

@kholia commented on GitHub (Nov 18, 2014):

@jfoug any ideas about this ticket?

<!-- gh-comment-id:63466838 --> @kholia commented on GitHub (Nov 18, 2014): @jfoug any ideas about this ticket?
Author
Owner

@jfoug commented on GitHub (Nov 18, 2014):

The output should be in LE format. Ther is a function to get an LE uint32 and get and LE uint16, and the hash is expected to be in that format. If the zip2john is outputting the numbers in BE on a BE system, then there should be no jtr build that would crack it.

<!-- gh-comment-id:63469957 --> @jfoug commented on GitHub (Nov 18, 2014): The output should be in LE format. Ther is a function to get an LE uint32 and get and LE uint16, and the hash is expected to be in that format. If the zip2john is outputting the numbers in BE on a BE system, then there should be no jtr build that would crack it.
Author
Owner

@jfoug commented on GitHub (Nov 18, 2014):

zip2john also uses fget32LE(fp); and fget16LE(fp); so I think it 'should' be right. I will do some hash making today, and check. It should get same hash on BE as on LE.

@magnumripper did you have a .zip file that was showing thus BE issue, or do all of them show this?

<!-- gh-comment-id:63470588 --> @jfoug commented on GitHub (Nov 18, 2014): zip2john also uses fget32LE(fp); and fget16LE(fp); so I think it 'should' be right. I will do some hash making today, and check. It should get same hash on BE as on LE. @magnumripper did you have a .zip file that was showing thus BE issue, or do all of them show this?
Author
Owner

@magnumripper commented on GitHub (Nov 18, 2014):

I can't remember but I believe I did some BE tests with input files created on LE and nothing was cracked. Do we have zip in TS?

Hmm but how is this not a problem with the internal test vectors?

<!-- gh-comment-id:63481735 --> @magnumripper commented on GitHub (Nov 18, 2014): I can't remember but I believe I did some BE tests with input files created on LE and nothing was cracked. Do we have zip in TS? Hmm but how is this not a problem with the internal test vectors?
Author
Owner

@jfoug commented on GitHub (Nov 18, 2014):

we have no zip in TS.

I have build zip 3.0 with encryption on my sparc. I created a pass.zip on the sparc side (compressing unix.o). I then created a pass-d.zip using command line pkzip25 (version 2.5 pkzip). Here are the dumps from a LE machine.

$ ../run/zip2john ../pass.zip
ver 14  efh 5455  efh 7875  pass.zip->unix.o PKZIP Encr: 2b chk, TS_chk, cmplen=4444, decmplen=9984, crc=5041262D
pass.zip:$pkzip2$1*2*3*0*115c*2700*5041262d*0*40*8*b*5041*5195*../pass.zip*$/pkzip2$:::::../pass.zip

$ ../run/zip2john ../pass-d.zip
ver 14  pass-d.zip->unix.o PKZIP Encr: cmplen=4436, decmplen=9984, crc=5041262D
pass-d.zip:$pkzip2$1*1*3*0*1154*2700*5041262d*0*48*8*d*5041*5196*../pass-d.zip*$/pkzip2$:::::../pass-d.zip

here is the zip2john dumps with zip2john from the BE side

bash-3.2$ ../run/zip2john pass.zip
ver 14  efh 5455  efh 7875  pass.zip->unix.o PKZIP Encr: 2b chk, TS_chk, cmplen=4444, decmplen=9984, crc=5041262D
pass.zip:$pkzip2$1*2*3*0*115c*2700*5041262d*0*40*8*8*5041*5195*pass.zip*$/pkzip2$:::::pass.zip
bash-3.2$ ../run/zip2john pass-d.zip
ver 14  pass-d.zip->unix.o PKZIP Encr: cmplen=4436, decmplen=9984, crc=5041262D
pass-d.zip:$pkzip2$1*1*3*0*1154*2700*5041262d*0*48*8*a*5041*5196*pass-d.zip*$/pkzip2$:::::pass-d.zip
<!-- gh-comment-id:63500472 --> @jfoug commented on GitHub (Nov 18, 2014): we have no zip in TS. I have build zip 3.0 with encryption on my sparc. I created a pass.zip on the sparc side (compressing unix.o). I then created a pass-d.zip using command line pkzip25 (version 2.5 pkzip). Here are the dumps from a LE machine. ``` $ ../run/zip2john ../pass.zip ver 14 efh 5455 efh 7875 pass.zip->unix.o PKZIP Encr: 2b chk, TS_chk, cmplen=4444, decmplen=9984, crc=5041262D pass.zip:$pkzip2$1*2*3*0*115c*2700*5041262d*0*40*8*b*5041*5195*../pass.zip*$/pkzip2$:::::../pass.zip $ ../run/zip2john ../pass-d.zip ver 14 pass-d.zip->unix.o PKZIP Encr: cmplen=4436, decmplen=9984, crc=5041262D pass-d.zip:$pkzip2$1*1*3*0*1154*2700*5041262d*0*48*8*d*5041*5196*../pass-d.zip*$/pkzip2$:::::../pass-d.zip ``` here is the zip2john dumps with zip2john from the BE side ``` bash-3.2$ ../run/zip2john pass.zip ver 14 efh 5455 efh 7875 pass.zip->unix.o PKZIP Encr: 2b chk, TS_chk, cmplen=4444, decmplen=9984, crc=5041262D pass.zip:$pkzip2$1*2*3*0*115c*2700*5041262d*0*40*8*8*5041*5195*pass.zip*$/pkzip2$:::::pass.zip bash-3.2$ ../run/zip2john pass-d.zip ver 14 pass-d.zip->unix.o PKZIP Encr: cmplen=4436, decmplen=9984, crc=5041262D pass-d.zip:$pkzip2$1*1*3*0*1154*2700*5041262d*0*48*8*a*5041*5196*pass-d.zip*$/pkzip2$:::::pass-d.zip ```
Author
Owner

@jfoug commented on GitHub (Nov 18, 2014):

I see no problem here? PEBCAK

<!-- gh-comment-id:63501270 --> @jfoug commented on GitHub (Nov 18, 2014): I see no problem here? PEBCAK
Author
Owner

@magnumripper commented on GitHub (Nov 18, 2014):

Well I do see a difference so if it's PEBCAK, you have a problem 😆

<!-- gh-comment-id:63536400 --> @magnumripper commented on GitHub (Nov 18, 2014): Well I do see a difference so if it's PEBCAK, you have a problem :laughing:
Author
Owner

@magnumripper commented on GitHub (Nov 18, 2014):

Are you saying you did not diff them and could not see any difference?
First file has *8*b*5041* in LE, *8*8*5041* in BE.
Second file has *8*d*5041* in LE, *8*a*5041* in BE.

<!-- gh-comment-id:63536968 --> @magnumripper commented on GitHub (Nov 18, 2014): Are you saying you did not diff them and could not see any difference? First file has `*8*b*5041*` in LE, `*8*8*5041*` in BE. Second file has `*8*d*5041*` in LE, `*8*a*5041*` in BE.
Author
Owner

@magnumripper commented on GitHub (Nov 18, 2014):

Original thread on ML: http://www.openwall.com/lists/john-dev/2013/04/13/5

<!-- gh-comment-id:63538178 --> @magnumripper commented on GitHub (Nov 18, 2014): Original thread on ML: http://www.openwall.com/lists/john-dev/2013/04/13/5
Author
Owner

@jfoug commented on GitHub (Nov 18, 2014):

I was not looking at 1 byte items. How the hell would they be wrong?? Let me look at the code, find out what the byte is, and why it is broken on a BE build.

I was looking for endianity issue. a 1 byte (or partial byte), should not be.

<!-- gh-comment-id:63540321 --> @jfoug commented on GitHub (Nov 18, 2014): I was not looking at 1 byte items. How the hell would they be wrong?? Let me look at the code, find out what the byte is, and why it is broken on a BE build. I was looking for endianity issue. a 1 byte (or partial byte), should not be.
Author
Owner

@jfoug commented on GitHub (Nov 18, 2014):

This is the field: DL Length of the DA data.

Note, that the file names are different, so expect this length to be different (the embedded file name IS the DA data). If you look at the command line I used to build them, you will see the difference. My CWD was different between the 2 systems.

So that byte IS appropriate to be different. So again, this is back to what I asked before, PEBCAK ?

<!-- gh-comment-id:63541529 --> @jfoug commented on GitHub (Nov 18, 2014): This is the field: `DL Length of the DA data.` Note, that the file names are different, so expect this length to be different (the embedded file name IS the DA data). If you look at the command line I used to build them, you will see the difference. My CWD was different between the 2 systems. So that byte IS appropriate to be different. So again, this is back to what I asked before, PEBCAK ?
Author
Owner

@magnumripper commented on GitHub (Nov 19, 2014):

Why are we storing length of terminated fields? Anyway I very much doubt it was a PEBCAK. I bet the bug was "unknowingly" fixed in 528e6bc or something.

<!-- gh-comment-id:63569242 --> @magnumripper commented on GitHub (Nov 19, 2014): Why are we storing length of terminated fields? Anyway I very much doubt it was a PEBCAK. I bet the bug was "unknowingly" fixed in 528e6bc or something.
Author
Owner

@magnumripper commented on GitHub (Nov 19, 2014):

BTW you should probably test a "winzip" file too. I'm not sure this was the pkzip format, it was more likely the zip aka winzip format. If winzip files are good now too, we can close this.

<!-- gh-comment-id:63569808 --> @magnumripper commented on GitHub (Nov 19, 2014): BTW you should probably test a "winzip" file too. I'm not sure this was the pkzip format, it was more likely the zip aka winzip format. If winzip files are good now too, we can close this.
Author
Owner

@frank-dittrich commented on GitHub (Nov 19, 2014):

On 11/19/2014 01:00 AM, magnum wrote:

Why are we storing length of terminated fields?

I agree. Storing the same information twice isn't a good idea.
We have the same problem with LUKS, where the iteration count is stored
twice.
Do you silently drop hashes as invalid if the two places that should
contain the same information disagree?
Do you warn the user on stderr? Or just crash as LUKS does (assert ...)?

This only makes fuzzing (and thus trying to find bugs triggered by
"arbitrary" input) harder.

(BTW: LUKS has many other problems, see
https://github.com/magnumripper/JohnTheRipper/issues/557
(But LUKS can still be fixed before we finally release current
bleeding-jumbo code, because it isn't included in any released version,
so we wouldn't need to support the current hash representation and a
fixed one in the long run.)

<!-- gh-comment-id:63591705 --> @frank-dittrich commented on GitHub (Nov 19, 2014): On 11/19/2014 01:00 AM, magnum wrote: > Why are we storing length of terminated fields? I agree. Storing the same information twice isn't a good idea. We have the same problem with LUKS, where the iteration count is stored twice. Do you silently drop hashes as invalid if the two places that should contain the same information disagree? Do you warn the user on stderr? Or just crash as LUKS does (assert ...)? This only makes fuzzing (and thus trying to find bugs triggered by "arbitrary" input) harder. (BTW: LUKS has many other problems, see https://github.com/magnumripper/JohnTheRipper/issues/557 (But LUKS can still be fixed before we finally release current bleeding-jumbo code, because it isn't included in any released version, so we wouldn't need to support the current hash representation and a fixed one in the long run.)
Author
Owner

@jfoug commented on GitHub (Nov 19, 2014):

Sorry, but I am not changing the zip signature (again).

Here is the run from a winzip file (128 and 256 bit aes)

LE 
wz256-pass.zip:$zip2$*0*3*0*52fc58dca24882796b80c43ad1507e2e*420f*2ef5*ZFILE*wz256-pass.zip*0*4d*d6871abc56c6b4c5b523*$/zip2$:::::wz256-pass.zip
wz-pass.zip:$zip2$*0*1*0*7191de6b36e9fc3b*015f*2ef5*ZFILE*wz-pass.zip*0*45*11b80e79c258c12b895a*$/zip2$:::::wz-pass.zip

BE
bash-3.2$ ../run/zip2john wz*
wz256-pass.zip:$zip2$*0*3*0*52fc58dca24882796b80c43ad1507e2e*420f*2ef5*ZFILE*wz256-pass.zip*0*4d*d6871abc56c6b4c5b523*$/zip2$:::::wz256-pass.zip
wz-pass.zip:$zip2$*0*1*0*7191de6b36e9fc3b*015f*2ef5*ZFILE*wz-pass.zip*0*45*11b80e79c258c12b895a*$/zip2$:::::wz-pass.zip

Identical results on both sides. I made sure to run in same dir this time.

<!-- gh-comment-id:63594917 --> @jfoug commented on GitHub (Nov 19, 2014): Sorry, but I am not changing the zip signature (again). Here is the run from a winzip file (128 and 256 bit aes) ``` LE wz256-pass.zip:$zip2$*0*3*0*52fc58dca24882796b80c43ad1507e2e*420f*2ef5*ZFILE*wz256-pass.zip*0*4d*d6871abc56c6b4c5b523*$/zip2$:::::wz256-pass.zip wz-pass.zip:$zip2$*0*1*0*7191de6b36e9fc3b*015f*2ef5*ZFILE*wz-pass.zip*0*45*11b80e79c258c12b895a*$/zip2$:::::wz-pass.zip BE bash-3.2$ ../run/zip2john wz* wz256-pass.zip:$zip2$*0*3*0*52fc58dca24882796b80c43ad1507e2e*420f*2ef5*ZFILE*wz256-pass.zip*0*4d*d6871abc56c6b4c5b523*$/zip2$:::::wz256-pass.zip wz-pass.zip:$zip2$*0*1*0*7191de6b36e9fc3b*015f*2ef5*ZFILE*wz-pass.zip*0*45*11b80e79c258c12b895a*$/zip2$:::::wz-pass.zip ``` Identical results on both sides. I made sure to run in same dir this time.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#36
No description provided.