[GH-ISSUE #1039] Review pass_gen.pl (and then re-generate TS files) #639

Closed
opened 2026-10-14 03:16:26 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @magnumripper on GitHub (Jan 29, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1039

github.com/magnumripper/JohnTheRipper@368f19d867 (commitcomment-9428963)

We should review pass_gen.pl so it outputs in a standardized format - and also is as brief as possible: When generating 100,000,000 hashes (I do things like that when testing) all unneeded stuff on each row take a crazy amount of space.

In fact, we should have a function do this output, so any change (or option) will reflect all formats (at least all but l0phtcrack et al).

While at it, we could have options for just doing things like

hash1
hash2

vs.

u1:hash1
u2:hash2

vs.

u1:hash1:::cleartext1
u2:hash2:::cleartext2

or perhaps

cleartext1:hash1
cleartext2:hash2

The last format would be good for TS knowing we actually cracked the right cleartext for a hash.

Originally created by @magnumripper on GitHub (Jan 29, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1039 https://github.com/magnumripper/JohnTheRipper/commit/368f19d86770f19fb4d37ae1359c89c48feae276#commitcomment-9428963 We should review pass_gen.pl so it outputs in a standardized format - and also is as brief as possible: When generating 100,000,000 hashes (I do things like that when testing) all unneeded stuff on each row take a crazy amount of space. In fact, we should have a function do this output, so any change (or option) will reflect all formats (at least all but l0phtcrack et al). While at it, we could have options for just doing things like ``` hash1 hash2 ``` vs. ``` u1:hash1 u2:hash2 ``` vs. ``` u1:hash1:::cleartext1 u2:hash2:::cleartext2 ``` or perhaps ``` cleartext1:hash1 cleartext2:hash2 ``` The last format would be good for TS knowing we actually cracked the _right_ cleartext for a hash.
bsakaguchi 2026-10-14 03:16:26 +07:00
Author
Owner

@jfoug commented on GitHub (Jan 29, 2015):

I find the last method to be the best. However, there ARE formats that we also should test with a real user name. That is why the u1:hash1:::clear1: 'might' be the best option. This is not 'that' far off of existing layout.

Part of the issue we have, is that many of the hashes were generated with 'unique' scripts built just to make the hash. The script had to know how pass_gen.pl expects salt data, and the type of data, and it's length. Then the script will ask for a specific number of passwords, all generated with same salt. Then it asks for the same passwords changing the salt, etc. So in this case, I can use 150 passwords, and have 10 unique salts. Or 30 passwords with 50 salts, etc.

Another part of the issue, is that within pass_gen, each format type generates it's own FULL output line. I think what we should do, is change pass_gen.pl so that each hash function returns the hash, and any other REQUIRED fields (like user name). Then we have a common code outputting function.

But yes, I really think we should standardize the inputs, in some manner. Keeping in mind, that some were NOT made with pass_gen. So we may also want to add a field to the jtrts.dat file listing that the data is in 'canonical' pass_gen.pl format, or not. Even if made with non-standard methods (say, using 7z and 7z2john), IF the final result file is put into correct format, we could list that it was. Well, even better than listing it is IN canonical format, we could simply say it is v1 format. Then if later we change the format, and re-gen the data files, then we still know that 7z_tst.in is in v1. It is a 'known' format, even if not the most current.

Sorry, my thoughts were wandering a bit.

<!-- gh-comment-id:72112281 --> @jfoug commented on GitHub (Jan 29, 2015): I find the last method to be the best. However, there ARE formats that we also should test with a real user name. That is why the u1:hash1:::clear1: 'might' be the best option. This is not 'that' far off of existing layout. Part of the issue we have, is that many of the hashes were generated with 'unique' scripts built just to make the hash. The script had to know how pass_gen.pl expects salt data, and the type of data, and it's length. Then the script will ask for a specific number of passwords, all generated with same salt. Then it asks for the same passwords changing the salt, etc. So in this case, I can use 150 passwords, and have 10 unique salts. Or 30 passwords with 50 salts, etc. Another part of the issue, is that within pass_gen, each format type generates it's own FULL output line. I think what we should do, is change pass_gen.pl so that each hash function returns the hash, and any other REQUIRED fields (like user name). Then we have a common code outputting function. But yes, I really think we should standardize the inputs, in some manner. Keeping in mind, that some were NOT made with pass_gen. So we may also want to add a field to the jtrts.dat file listing that the data is in 'canonical' pass_gen.pl format, or not. Even if made with non-standard methods (say, using 7z and 7z2john), IF the final result file is put into correct format, we could list that it was. Well, even better than listing it is IN canonical format, we could simply say it is v1 format. Then if later we change the format, and re-gen the data files, then we still know that 7z_tst.in is in v1. It is a 'known' format, even if not the most current. Sorry, my thoughts were wandering a bit.
Author
Owner

@jfoug commented on GitHub (Jan 30, 2015):

Ok, shortly I will turn in a 'phase-1' of this. Phase-1 will have all hashes simply return the hash (and possibly set a couple of globals). Then there will be a single function that outputs ALL lines.

Here is that function (NOTE, it is simple now, we can 'add' to this).

#############################################################################
#   sub output_hash($hash, $pass, $encoded_pass)
# a 'common' output function. This right now is just a stub, but laster we
# can have some command line option(s) that allows control over this function
# to give us ability to change the output format.
#############################################################################
sub output_hash {
    my $p = $_[1];
    if ($out_uc_pass) {$p = uc $p; }
    if ($out_extras == 2)    { $p = "$u:0:".$p;}
    elsif ($out_extras == 1) { $p = "$u:".$p;}
    if (length($out_username)) { print "$out_username:"; } else { print "u$u:"; }
    print "$_[0]:$p:\n"
}

this currently is pretty simple. It has only this 'format':

u:hash:x:x:pass:

some formats changes things a bit (mscash, lm, pwdump, nt, etc). But so far, 100% of the hashes I have done (I am up to mssql12. so there are 50 or so left to go), have the password in field #5, so it is at a fixed location.

The going is not 'super' fast. I am testing every hash as I go. It will output 2 lines (the current line, and the new one). I make sure it is correct, prior to removing the current print"" version.

<!-- gh-comment-id:72243875 --> @jfoug commented on GitHub (Jan 30, 2015): Ok, shortly I will turn in a 'phase-1' of this. Phase-1 will have all hashes simply return the hash (and possibly set a couple of globals). Then there will be a single function that outputs ALL lines. Here is that function (NOTE, it is simple now, we can 'add' to this). ``` Perl ############################################################################# # sub output_hash($hash, $pass, $encoded_pass) # a 'common' output function. This right now is just a stub, but laster we # can have some command line option(s) that allows control over this function # to give us ability to change the output format. ############################################################################# sub output_hash { my $p = $_[1]; if ($out_uc_pass) {$p = uc $p; } if ($out_extras == 2) { $p = "$u:0:".$p;} elsif ($out_extras == 1) { $p = "$u:".$p;} if (length($out_username)) { print "$out_username:"; } else { print "u$u:"; } print "$_[0]:$p:\n" } ``` this currently is pretty simple. It has only this 'format': `u:hash:x:x:pass:` some formats changes things a bit (mscash, lm, pwdump, nt, etc). But so far, 100% of the hashes I have done (I am up to mssql12. so there are 50 or so left to go), have the password in field #5, so it is at a fixed location. The going is not 'super' fast. I am testing every hash as I go. It will output 2 lines (the current line, and the new one). I make sure it is correct, prior to removing the current print"" version.
Author
Owner

@jfoug commented on GitHub (Jan 30, 2015):

Problem formats:

  • netntlm-ess (L0phtcrack format).
  • netntlm (same as the -ess)
  • l0phtcrack
  • netlmv2
  • netntlmv2
  • mschapv2
<!-- gh-comment-id:72250210 --> @jfoug commented on GitHub (Jan 30, 2015): Problem formats: - [ ] netntlm-ess (L0phtcrack format). - [ ] netntlm (same as the -ess) - [ ] l0phtcrack - [ ] netlmv2 - [ ] netntlmv2 - [ ] mschapv2
Author
Owner

@magnumripper commented on GitHub (Aug 18, 2016):

I think this is essentially done, long ago.

<!-- gh-comment-id:240875808 --> @magnumripper commented on GitHub (Aug 18, 2016): I think this is essentially done, long ago.
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#639
No description provided.