[GH-ISSUE #2314] 7z formats enhancement #1546

Closed
opened 2026-10-15 04:19:47 +07:00 by bsakaguchi · 14 comments
Owner

Originally created by @magnumripper on GitHub (Oct 31, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2314

  1. Drop the silly BIG_ENOUGH macro and allocate dynamically instead. This is trivial but leads to 2:
  2. Change to dyna salt for self-tests to pass.
  3. Import 7z2hashcat.pl from https://github.com/philsmd/7z2hashcat and have it replace 7z2john.py

These steps seem to add support for "multiple unpack-sizes" as well as files without header encryption (apparently the limitations are in our current 7z2john.py, not the format)!

Originally created by @magnumripper on GitHub (Oct 31, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2314 1. Drop the silly `BIG_ENOUGH` macro and allocate dynamically instead. This is trivial but leads to 2: 2. Change to dyna salt for self-tests to pass. 3. Import 7z2hashcat.pl from https://github.com/philsmd/7z2hashcat and have it replace 7z2john.py These steps seem to add support for "multiple unpack-sizes" as well as files without header encryption (apparently the limitations are in our current 7z2john.py, not the format)!
Author
Owner

@magnumripper commented on GitHub (Oct 31, 2016):

Note: For the new 7z2john.pl (derived from 7z2hashcat.pl), we need to change a few bits: Add a "username" which is the basename of the archive file, and possibly some "gecos" metadata for additional keywords found (eg. file name(s) seen within archive). Both for single-mode cracking. Also, we need to ensure license and credits go to @philsmd properly.

<!-- gh-comment-id:257191388 --> @magnumripper commented on GitHub (Oct 31, 2016): Note: For the new 7z2john.pl (derived from 7z2hashcat.pl), we need to change a few bits: Add a "username" which is the basename of the archive file, and possibly some "gecos" metadata for additional keywords found (eg. file name(s) seen within archive). Both for single-mode cracking. Also, we need to ensure license and credits go to @philsmd properly.
Author
Owner

@magnumripper commented on GitHub (Oct 31, 2016):

Note 2: We should also drop the $SEVEN_ZIP_HASHCAT_MAX_DATA variable (and its use) from new 7z2john.pl since we no longer have any limit for input data size.

<!-- gh-comment-id:257191554 --> @magnumripper commented on GitHub (Oct 31, 2016): Note 2: We should also drop the `$SEVEN_ZIP_HASHCAT_MAX_DATA` variable (and its use) from new 7z2john.pl since we no longer have any limit for input data size.
Author
Owner

@magnumripper commented on GitHub (Oct 31, 2016):

With some luck this also fixes #2120. If it doesn't, we should fix it and submit upstream.

<!-- gh-comment-id:257191713 --> @magnumripper commented on GitHub (Oct 31, 2016): With some luck this also fixes #2120. If it doesn't, we should fix it and submit upstream.
Author
Owner

@magnumripper commented on GitHub (Nov 1, 2016):

@kholia after a7dd209 and 1c2bad4 our 7z2john accepts "multiple unpacksizes" but we don't seem to crack them (false negative) unless there happens to be enough padding. I'm not quite sure why?

<!-- gh-comment-id:257556515 --> @magnumripper commented on GitHub (Nov 1, 2016): @kholia after a7dd209 and 1c2bad4 our 7z2john accepts "multiple unpacksizes" but we don't seem to crack them (false negative) unless there happens to be enough padding. I'm not quite sure why?
Author
Owner

@magnumripper commented on GitHub (Nov 1, 2016):

I'm trying to follow Hashcat's workflow for 7z but can't see anything special.

<!-- gh-comment-id:257556977 --> @magnumripper commented on GitHub (Nov 1, 2016): I'm trying to follow Hashcat's workflow for 7z but can't see anything special.
Author
Owner

@magnumripper commented on GitHub (Nov 1, 2016):

Here's a test vector (cleartext is "magnum")

$7z$0$19$0$$16$5f6729e973323494dd32b91fb524869a$121810819$16$12$87eb588f2bdb074b9c5027686fae4662

Margin is just 4 so padding test doesn't apply. Hashcat does crack the above, we do not. Our CRC ends up incorrectly.

(EDIT: Hashcat relies on padding check for margin >= 4 but it does work even if I comment that out)

<!-- gh-comment-id:257558705 --> @magnumripper commented on GitHub (Nov 1, 2016): Here's a test vector (cleartext is "magnum") ``` $7z$0$19$0$$16$5f6729e973323494dd32b91fb524869a$121810819$16$12$87eb588f2bdb074b9c5027686fae4662 ``` Margin is just 4 so padding test doesn't apply. Hashcat does crack the above, we do not. Our CRC ends up incorrectly. (EDIT: Hashcat relies on padding check for margin >= 4 but it _does_ work even if I comment that out)
Author
Owner

@magnumripper commented on GitHub (Nov 1, 2016):

I really don't get this. Using the aforementioned test vector our code come up with a CRC of 0xfff73193 for the correct plain, while the expected (121810819 in decimal) is 0x0742af83. So we don't get a match but a false negative. Hashcat sees and calculates the same two values yet somehow it does detect a match and show it as cracked. Due to bitmaps and other magic I fail to see where and how!?

<!-- gh-comment-id:257612321 --> @magnumripper commented on GitHub (Nov 1, 2016): I really don't get this. Using the aforementioned test vector our code come up with a CRC of 0xfff73193 for the correct plain, while the expected (121810819 in decimal) is 0x0742af83. So we don't get a match but a false negative. Hashcat sees and calculates the **same two values** yet somehow it does detect a match and show it as cracked. Due to bitmaps and other magic I fail to see where and how!?
Author
Owner

@kholia commented on GitHub (Nov 3, 2016):

I took a brief look at hashcat's source code but I couldn't figure out how the 7-Zip cracking code works.

<!-- gh-comment-id:258101329 --> @kholia commented on GitHub (Nov 3, 2016): I took a brief look at hashcat's source code but I couldn't figure out how the 7-Zip cracking code works.
Author
Owner

@magnumripper commented on GitHub (Nov 14, 2016):

Added bug label since we currently get some false negatives 😢

<!-- gh-comment-id:260266156 --> @magnumripper commented on GitHub (Nov 14, 2016): Added bug label since we currently get some false negatives 😢
Author
Owner

@magnumripper commented on GitHub (Jan 12, 2017):

@philsmd has figured this out. See https://github.com/philsmd/7z2hashcat/issues/4

After the hash format syntax is decided / implemented, we need to add simple and fast LZMA and LZMA2 code (perhaps including early rejection logic like we have in RAR and pkzip) in our format.

<!-- gh-comment-id:272236704 --> @magnumripper commented on GitHub (Jan 12, 2017): @philsmd has figured this out. See https://github.com/philsmd/7z2hashcat/issues/4 After the hash format syntax is decided / implemented, we need to add simple and fast LZMA and LZMA2 code (perhaps including early rejection logic like we have in RAR and pkzip) in our format.
Author
Owner

@magnumripper commented on GitHub (Jan 12, 2017):

7z2john.pl is fixed now. Still to do: Read that flag and add a step of LZMA/LZMA2 decompression right before calculating CRC, according to the flag.

<!-- gh-comment-id:272278442 --> @magnumripper commented on GitHub (Jan 12, 2017): 7z2john.pl is fixed now. Still to do: Read that flag and add a step of LZMA/LZMA2 decompression right before calculating CRC, according to the flag.
Author
Owner

@philsmd commented on GitHub (Jan 13, 2017):

I'm sure this might interest you too (the POC) and furthermore it seems that we need to adapt the hash format for the 7-zip hash mode again: https://github.com/hashcat/hashcat/issues/965#issuecomment-272499461

<!-- gh-comment-id:272517824 --> @philsmd commented on GitHub (Jan 13, 2017): I'm sure this might interest you too (the POC) and furthermore it seems that we need to adapt the hash format for the 7-zip hash mode again: https://github.com/hashcat/hashcat/issues/965#issuecomment-272499461
Author
Owner
<!-- gh-comment-id:272697603 --> @magnumripper commented on GitHub (Jan 15, 2017): https://github.com/hashcat/hashcat/issues/968 https://github.com/philsmd/7z2hashcat/issues/5
Author
Owner

@magnumripper commented on GitHub (Jan 17, 2017):

After 738734bc4 and 453589b8 the formats are pretty solid. Very good work by @philsmd, thanks a lot!

<!-- gh-comment-id:273203157 --> @magnumripper commented on GitHub (Jan 17, 2017): After 738734bc4 and 453589b8 the formats are pretty solid. Very good work by @philsmd, thanks a lot!
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#1546
No description provided.