[GH-ISSUE #2082] Use restore_tester_fmt.c to find and correct restore issues #1392

Open
opened 2026-10-14 03:47:12 +07:00 by bsakaguchi · 71 comments
Owner

Originally created by @jfoug on GitHub (Mar 8, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2082

Things I know about. Add more as they are seen/fixed, since some of these should get done in core also.

  • rules. When restarting, the words are restarted for whatever rules were being worked on. (Fixed 2 bugs github.com/magnumripper/JohnTheRipper@2110a37528 and github.com/magnumripper/JohnTheRipper@62310e8b5a)
  • rexgen does not resume #570 (fixed but can not use until v1.4.0 of rexgen is released).
  • rexgen-hybrid only resumes the base-word #570.
  • Multi-salt mode restarts all salt work over again (#2087)
  • single mode
  • markov mode
  • mask mode Restore is almost right. Just the very last word which was properly done is started with. (fix found, pending verify)
  • wordlist mask hybrid was also 'off by one', i.e. replaying last tested word. (fixed, pending verify)

Some of these could be handled as 'hybrid' type blocks added to the end of a .rec file (I think). Things like the rules and multi-salts redoing work, could be addressed in that manner. The 'normal' V4 processing of the rec file gets us back to the right words, and then the hybrid extra block appended provides additional information on how far to skip ahead inside the subwork done on the word or set of words, so that prior completed work is not replicated.

The restore_tester_fmt is great for determining exactly what was processed, written to .pot files, etc. So that we know 100% that we restart at proper location, not before, and CERTAINLY not later in the word stream.

Originally created by @jfoug on GitHub (Mar 8, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2082 Things I know about. Add more as they are seen/fixed, since some of these should get done in core also. - [x] rules. When restarting, the words are restarted for whatever rules were being worked on. (Fixed 2 bugs https://github.com/magnumripper/JohnTheRipper/commit/2110a37528fb936f52ff789a0f5d27f05f09b5d1 and https://github.com/magnumripper/JohnTheRipper/commit/62310e8b5a9aefc2b31da43e167eedcd280fb6a5) - [x] rexgen does not resume #570 (fixed but can not use until v1.4.0 of rexgen is released). - [x] rexgen-hybrid only resumes the base-word #570. - [x] Multi-salt mode restarts all salt work over again (#2087) - [ ] single mode - [ ] markov mode - [ ] mask mode Restore is almost right. Just the very last word which was properly done is started with. (fix found, pending verify) - [ ] wordlist mask hybrid was also 'off by one', i.e. replaying last tested word. (fixed, pending verify) Some of these could be handled as 'hybrid' type blocks added to the end of a .rec file (I think). Things like the rules and multi-salts redoing work, could be addressed in that manner. The 'normal' V4 processing of the rec file gets us back to the right words, and then the hybrid extra block appended provides additional information on how far to skip ahead inside the subwork done on the word or set of words, so that prior completed work is not replicated. The restore_tester_fmt is great for determining exactly what was processed, written to .pot files, etc. So that we know 100% that we restart at proper location, not before, and CERTAINLY not later in the word stream.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Here is what rules does (currently)

27e_01           (?)
27f_01           (?)
5904g 0:00:01:49 1.19% (ETA: 11:45:04) 54.16g/s 54.16p/s 54.16c/s 54.16C/s 280_01..2ff_01
Session aborted

$ ../run/john -res=tst-x
Loaded 1 password hash (restore_tester [None])
5904g 0:00:01:50 1.00% (ETA: 12:14:52) 53.67g/s 53.67p/s 53.67c/s 53.67C/s 000_01
000_01           (?)
001_01           (?)
002_01           (?)
003_01           (?)

here is the rec file:

Jim.Fougeron@1PQHGQ1 /c/projects/phpbb/johnripper/john-1.7.9/bleed64/test
$ cat *.rec
REC4
9
--rules=appendnumnum
--wordlist=tst-x.dic
tst-xx.in
--session=tst-x
--pot=tst-x.pot
--format=restore_tester
--input-encoding=ASCII
--target-encoding=ASCII
112
5936
1730
0
0
1730
0
1730
0
0
0
1
0
1
0
32

So it appears that under rules, only the rule# gets restored, and the run starts at the first input word on that rule.

So we need to save not only the rule# but also the word# for restore to work 'correctly'.

<!-- gh-comment-id:195409295 --> @jfoug commented on GitHub (Mar 11, 2016): Here is what rules does (currently) ``` 27e_01 (?) 27f_01 (?) 5904g 0:00:01:49 1.19% (ETA: 11:45:04) 54.16g/s 54.16p/s 54.16c/s 54.16C/s 280_01..2ff_01 Session aborted $ ../run/john -res=tst-x Loaded 1 password hash (restore_tester [None]) 5904g 0:00:01:50 1.00% (ETA: 12:14:52) 53.67g/s 53.67p/s 53.67c/s 53.67C/s 000_01 000_01 (?) 001_01 (?) 002_01 (?) 003_01 (?) ``` here is the rec file: ``` Jim.Fougeron@1PQHGQ1 /c/projects/phpbb/johnripper/john-1.7.9/bleed64/test $ cat *.rec REC4 9 --rules=appendnumnum --wordlist=tst-x.dic tst-xx.in --session=tst-x --pot=tst-x.pot --format=restore_tester --input-encoding=ASCII --target-encoding=ASCII 112 5936 1730 0 0 1730 0 1730 0 0 0 1 0 1 0 32 ``` So it appears that under rules, only the rule# gets restored, and the run starts at the first input word on that rule. So we need to save not only the rule# but also the word# for restore to work 'correctly'.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Rules bug (listed above), found and fixed. Still more testing to do, but that one WAS a bug, and is corrected.

NOTE, the restore_tester format kicks ass for finding these issues, and then knowing that it is correctly fixed!!!!

<!-- gh-comment-id:195421205 --> @jfoug commented on GitHub (Mar 11, 2016): Rules bug (listed above), found and fixed. Still more testing to do, but that one WAS a bug, and is corrected. NOTE, the restore_tester format kicks ass for finding these issues, and then knowing that it is correctly fixed!!!!
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Found another bug in wordlist resume. If the .rec file was made with a version that has mem_map enabled and restored on a build that does not have mem_map, then the offset was set to 0, so the new run does not restore properly. I think I can fix this, but not sure it is worth it. NOTE, if the .rec was made on a non-mem_map build, then it restores properly on a non-mem_map build (or on a mem_map build for that matter).

Fixed it here. github.com/magnumripper/JohnTheRipper@62310e8b5a

Now it does not matter if the build was mem_map or not. Either can resume the other's .rec files properly.

<!-- gh-comment-id:195428245 --> @jfoug commented on GitHub (Mar 11, 2016): Found another bug in wordlist resume. If the .rec file was made with a version that has mem_map enabled and restored on a build that does not have mem_map, then the offset was set to 0, so the new run does not restore properly. I think I can fix this, but not sure it is worth it. NOTE, if the .rec was made on a non-mem_map build, then it restores properly on a non-mem_map build (or on a mem_map build for that matter). Fixed it here. https://github.com/magnumripper/JohnTheRipper/commit/62310e8b5a9aefc2b31da43e167eedcd280fb6a5 Now it does not matter if the build was mem_map or not. Either can resume the other's .rec files properly.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

I believe wordlist is fixed. If others wanted to see if there are other restore things that could be 'fixed', then by all means try (-stdin, -pipe ??)

<!-- gh-comment-id:195439321 --> @jfoug commented on GitHub (Mar 11, 2016): I believe wordlist is fixed. If others wanted to see if there are other restore things that could be 'fixed', then by all means try (-stdin, -pipe ??)
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

I will have to enhance restore_tester format for testing salted hashes. I think I will make a 2nd format for this, so that any issues between pure-raw and salted running 1 salt does not get in the way

<!-- gh-comment-id:195440560 --> @jfoug commented on GitHub (Mar 11, 2016): I will have to enhance restore_tester format for testing salted hashes. I think I will make a 2nd format for this, so that any issues between pure-raw and salted running 1 salt does not get in the way
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Here is multi-salt restore issues (wordlist and rules, but I do not think it will matter on the mode).

Note, switched MAX/MIN candidates to 3

$ OMP_NUM_THREADS=1 ../run/john -rules=appendnumnum -mem=5 -w=tst-x.dic tst-x.in -ses=tst-x -pot=tst-x.pot
Loaded 9 password hashes with 9 different salts (restore_tester_salted [None])
000_00$SLT1      (?)
001_00$SLT1      (?)
002_00$SLT1      (?)
000_00$SLT8      (?)
001_00$SLT8      (?)
002_00$SLT8      (?)
000_00$SLT7      (?)
001_00$SLT7      (?)
002_00$SLT7      (?)
000_00$SLT6      (?)
001_00$SLT6      (?)
002_00$SLT6      (?)
000_00$SLT5      (?)
001_00$SLT5      (?)
002_00$SLT5      (?)
000_00$SLT4      (?)
001_00$SLT4      (?)
002_00$SLT4      (?)
000_00$SLT3      (?)
001_00$SLT3      (?)
002_00$SLT3      (?)
000_00$SLT2      (?)
001_00$SLT2      (?)
002_00$SLT2      (?)
000_00$SLT9      (?)
001_00$SLT9      (?)
002_00$SLT9      (?)
003_00$SLT1      (?)
004_00$SLT1      (?)
005_00$SLT1      (?)
003_00$SLT8      (?)
004_00$SLT8      (?)
005_00$SLT8      (?)
003_00$SLT7      (?)
004_00$SLT7      (?)
005_00$SLT7      (?)
003_00$SLT6      (?)
004_00$SLT6      (?)
005_00$SLT6      (?)
39g 0:00:00:02 0.00% (ETA: 2016-03-13 01:16) 16.09g/s 1.238p/s 16.09c/s 16.09C/s 003_00$SLT5..005_00$SLT5
Session aborted

$ OMP_NUM_THREADS=1 ../run/john -res=tst-x
Loaded 9 password hashes with 9 different salts (restore_tester_salted [None])
39g 0:00:00:03 0.00% (ETA: 2016-03-13 21:14) 13.00g/s 1.000p/s 13.00c/s 13.00C/s 003_00$SLT1
003_00$SLT1      (?)
004_00$SLT1      (?)
005_00$SLT1      (?)
003_00$SLT8      (?)
004_00$SLT8      (?)
005_00$SLT8      (?)
003_00$SLT7      (?)
004_00$SLT7      (?)
005_00$SLT7      (?)
003_00$SLT6      (?)
004_00$SLT6      (?)
005_00$SLT6      (?)
003_00$SLT5      (?)
004_00$SLT5      (?)
005_00$SLT5      (?)
003_00$SLT4      (?)
004_00$SLT4      (?)
005_00$SLT4      (?)

Note, the correct resume location is

000_00$SLT5      (?)
001_00$SLT5      (?)
002_00$SLT5      (?)
000_00$SLT4      (?)
001_00$SLT4      (?)
<!-- gh-comment-id:195464684 --> @jfoug commented on GitHub (Mar 11, 2016): Here is multi-salt restore issues (wordlist and rules, but I do not think it will matter on the mode). Note, switched MAX/MIN candidates to 3 ``` $ OMP_NUM_THREADS=1 ../run/john -rules=appendnumnum -mem=5 -w=tst-x.dic tst-x.in -ses=tst-x -pot=tst-x.pot Loaded 9 password hashes with 9 different salts (restore_tester_salted [None]) 000_00$SLT1 (?) 001_00$SLT1 (?) 002_00$SLT1 (?) 000_00$SLT8 (?) 001_00$SLT8 (?) 002_00$SLT8 (?) 000_00$SLT7 (?) 001_00$SLT7 (?) 002_00$SLT7 (?) 000_00$SLT6 (?) 001_00$SLT6 (?) 002_00$SLT6 (?) 000_00$SLT5 (?) 001_00$SLT5 (?) 002_00$SLT5 (?) 000_00$SLT4 (?) 001_00$SLT4 (?) 002_00$SLT4 (?) 000_00$SLT3 (?) 001_00$SLT3 (?) 002_00$SLT3 (?) 000_00$SLT2 (?) 001_00$SLT2 (?) 002_00$SLT2 (?) 000_00$SLT9 (?) 001_00$SLT9 (?) 002_00$SLT9 (?) 003_00$SLT1 (?) 004_00$SLT1 (?) 005_00$SLT1 (?) 003_00$SLT8 (?) 004_00$SLT8 (?) 005_00$SLT8 (?) 003_00$SLT7 (?) 004_00$SLT7 (?) 005_00$SLT7 (?) 003_00$SLT6 (?) 004_00$SLT6 (?) 005_00$SLT6 (?) 39g 0:00:00:02 0.00% (ETA: 2016-03-13 01:16) 16.09g/s 1.238p/s 16.09c/s 16.09C/s 003_00$SLT5..005_00$SLT5 Session aborted $ OMP_NUM_THREADS=1 ../run/john -res=tst-x Loaded 9 password hashes with 9 different salts (restore_tester_salted [None]) 39g 0:00:00:03 0.00% (ETA: 2016-03-13 21:14) 13.00g/s 1.000p/s 13.00c/s 13.00C/s 003_00$SLT1 003_00$SLT1 (?) 004_00$SLT1 (?) 005_00$SLT1 (?) 003_00$SLT8 (?) 004_00$SLT8 (?) 005_00$SLT8 (?) 003_00$SLT7 (?) 004_00$SLT7 (?) 005_00$SLT7 (?) 003_00$SLT6 (?) 004_00$SLT6 (?) 005_00$SLT6 (?) 003_00$SLT5 (?) 004_00$SLT5 (?) 005_00$SLT5 (?) 003_00$SLT4 (?) 004_00$SLT4 (?) 005_00$SLT4 (?) ``` Note, the correct resume location is ``` 000_00$SLT5 (?) 001_00$SLT5 (?) 002_00$SLT5 (?) 000_00$SLT4 (?) 001_00$SLT4 (?) ```
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

I have multi-salt restore working, but it will (may) require a new REC-VERSION (v5). This 'could' be handled in the same manner as I have done on the other 'extra' blocks. So I could keep this at REC_VERSION=4 and add a block like this to the end of the file

slt-v1
%x

%x is a salt idx.

Currently, I have added the salt idx to the bottom of the 'normal' block of restore stuff, and read it from there. But it would not have to be done in this manner. The way I did it for the other 'hybrid' modes would work just fine.

I am asking (@magnumripper and @frank-dittrich mostly), which way they would like to see this done? I could easily add this as a slt-v1 block, and then later if solar adds this data into a REC5 model, we could switch our logic to use that (but keep the slt-v1 processing, so any .rec files created could still be read).

But I really want this to be put into code. When working with a LARGE number of salts of some pretty slow formats, means that there is a lot of replicated work any time you have to shut down.

<!-- gh-comment-id:195485589 --> @jfoug commented on GitHub (Mar 11, 2016): I have multi-salt restore working, but it will (may) require a new REC-VERSION (v5). This 'could' be handled in the same manner as I have done on the other 'extra' blocks. So I could keep this at REC_VERSION=4 and add a block like this to the end of the file slt-v1 %x %x is a salt idx. Currently, I have added the salt idx to the bottom of the 'normal' block of restore stuff, and read it from there. But it would not have to be done in this manner. The way I did it for the other 'hybrid' modes would work just fine. I am asking (@magnumripper and @frank-dittrich mostly), which way they would like to see this done? I could easily add this as a slt-v1 block, and then later if solar adds this data into a REC5 model, we could switch our logic to use that (but keep the slt-v1 processing, so any .rec files created could still be read). But I really want this to be put into code. When working with a LARGE number of salts of some pretty slow formats, means that there is a lot of replicated work any time you have to shut down.
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

When testing wordlist mode, be sure to also try adding --mem=1 to the command line, disabling buffering. The logic is different for that.

EDIT it looks like you already did so.

<!-- gh-comment-id:195501671 --> @magnumripper commented on GitHub (Mar 11, 2016): When testing wordlist mode, be sure to also try adding `--mem=1` to the command line, disabling buffering. The logic is different for that. **EDIT** it looks like you already did so.
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

I am asking (@magnumripper and @frank-dittrich mostly), which way they would like to see this done?

This really should be discussed on john-dev before doing anything. I presume the problem exists in john proper? Solar may want to fix this and in that case we should do nothing (except possibly testing ideas for him).

<!-- gh-comment-id:195502250 --> @magnumripper commented on GitHub (Mar 11, 2016): > I am asking (@magnumripper and @frank-dittrich mostly), which way they would like to see this done? This really should be discussed on john-dev before doing anything. I presume the problem exists in john proper? Solar may want to fix this and in that case we should do nothing (except possibly testing ideas for him).
Author
Owner

@frank-dittrich commented on GitHub (Mar 11, 2016):

I don't think storing salt idx in .rec file is the way to go,
What if you have multiple sessions running, and when you restore, some salts got removed due to all passwords being cracked?
Or, if that still works, provided you don't change the input files: What if you drop all cracked hashes before restoring, to reduce load time.

Also, I don't think it i a good idea to create .rec files that are incompatible with master branch.

<!-- gh-comment-id:195502762 --> @frank-dittrich commented on GitHub (Mar 11, 2016): I don't think storing salt idx in .rec file is the way to go, What if you have multiple sessions running, and when you restore, some salts got removed due to all passwords being cracked? Or, if that still works, provided you don't change the input files: What if you drop all cracked hashes before restoring, to reduce load time. Also, I don't think it i a good idea to create .rec files that are incompatible with master branch.
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

What if you have multiple sessions running, and when you restore, some salts got removed due to all passwords being cracked?

This is an important caveat. The current behavior fully supports stopping a job and then resume it when there's much fewer salts left (from cracking in other sessions).

<!-- gh-comment-id:195504113 --> @magnumripper commented on GitHub (Mar 11, 2016): > What if you have multiple sessions running, and when you restore, some salts got removed due to all passwords being cracked? This is an important caveat. The current behavior fully supports stopping a job and then resume it when there's much fewer salts left (from cracking in other sessions).
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

I think I will make a 2nd format for this, so that any issues between pure-raw and salted running 1 salt does not get in the way

Not needed. As far as I know there is absolutely no difference between an unsalted format, and a salted one that has only one unique salt loaded.

<!-- gh-comment-id:195504775 --> @magnumripper commented on GitHub (Mar 11, 2016): > I think I will make a 2nd format for this, so that any issues between pure-raw and salted running 1 salt does not get in the way Not needed. As far as I know there is absolutely no difference between an unsalted format, and a salted one that has only one unique salt loaded.
Author
Owner

@frank-dittrich commented on GitHub (Mar 11, 2016):

But I really want this to be put into code. When working with a LARGE number of salts of some pretty slow formats, means that there is a lot of replicated work any time you have to shut down.

Don't we have an option to completely test one block of password candidates before stopping a session?

Appatently AbortGraceTime only works with --max-run-time, may be we need a config option to complete testing all salts before terminating the session.
(But woulodn't that make AbortGraceTime obsolete?

<!-- gh-comment-id:195504794 --> @frank-dittrich commented on GitHub (Mar 11, 2016): > But I really want this to be put into code. When working with a LARGE number of salts of some pretty slow formats, means that there is a lot of replicated work any time you have to shut down. Don't we have an option to completely test one block of password candidates before stopping a session? Appatently `AbortGraceTime` only works with --max-run-time, may be we need a config option to complete testing all salts before terminating the session. (But woulodn't that make `AbortGraceTime` obsolete?
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

Don't we have an option to completely test one block of password candidates before stopping a session?

It's not even an option, this is just how it works off the top of my head. Unless you brutally kill john with eg. kill -9, it will complete the block for all salts.

<!-- gh-comment-id:195505452 --> @magnumripper commented on GitHub (Mar 11, 2016): > Don't we have an option to completely test one block of password candidates before stopping a session? It's not even an option, this is just how it works off the top of my head. Unless you brutally kill john with eg. `kill -9`, it will complete the block for all salts.
Author
Owner

@frank-dittrich commented on GitHub (Mar 11, 2016):

@magnumripper

See issue #1638 and your commit:

commit 31834168ba59311387944ad1c33972f7f5984e82
Author: magnum <john.magnum@hushmail.com>
Date:   Wed Nov 4 23:12:11 2015 +0100

    Add a john.conf option AbortGraceTime for tweaking behavior
    of --max-run-time=N option. Closes #1638.

<!-- gh-comment-id:195506269 --> @frank-dittrich commented on GitHub (Mar 11, 2016): @magnumripper See issue #1638 and your commit: ``` commit 31834168ba59311387944ad1c33972f7f5984e82 Author: magnum <john.magnum@hushmail.com> Date: Wed Nov 4 23:12:11 2015 +0100 Add a john.conf option AbortGraceTime for tweaking behavior of --max-run-time=N option. Closes #1638. ```
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

Sure, the --max-run-time option is special. Is that what we're testing here? We shouldn't use it, or it should be used with AbortGraceTime = -1 here.

<!-- gh-comment-id:195507193 --> @magnumripper commented on GitHub (Mar 11, 2016): Sure, the --max-run-time option is special. Is that what we're testing here? We shouldn't use it, or it should be used with `AbortGraceTime = -1` here.
Author
Owner

@frank-dittrich commented on GitHub (Mar 11, 2016):

@magnumripper If you mean the behavior for sessions interrupted by pressing q or ctrl-c, then why is there a need to store the salt index in the .rec file at all?

<!-- gh-comment-id:195507396 --> @frank-dittrich commented on GitHub (Mar 11, 2016): @magnumripper If you mean the behavior for sessions interrupted by pressing q or ctrl-c, then why is there a need to store the salt index in the .rec file at all?
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

As far as I know there is no need but I'm not sure I understand how @jfoug tested it.

<!-- gh-comment-id:195508341 --> @magnumripper commented on GitHub (Mar 11, 2016): As far as I know there is no need but I'm not sure I understand how @jfoug tested it.
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

Likewise, if you press 'q' or 'ctrl-c' twice, all bets are off. We shouldn't fix "too early restore" caused by that. We should just ensure that the restore doesn't miss anything, EVER.

<!-- gh-comment-id:195509180 --> @magnumripper commented on GitHub (Mar 11, 2016): Likewise, if you press 'q' or 'ctrl-c' twice, all bets are off. We shouldn't fix "too early restore" caused by that. We should just ensure that the restore doesn't **miss** anything, EVER.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

This really should be discussed on john-dev before doing anything. I presume the problem exists in john proper? Solar may want to fix this and in that case we should do nothing (except possibly testing ideas for him).

Solar has mentioned this, and made a statement about 'IF I ever chose to fix it'.

I have done so keeping REC4 format. I simply append a slt-v1 block if there is a salt index (i.e. it is not at 0). It would be very trivial to switch this back to a REC5 structure if we later have that. All the other logic would need no adjustments. Only adjustment is where to grab the 'salt_idx' value.

<!-- gh-comment-id:195511516 --> @jfoug commented on GitHub (Mar 11, 2016): > This really should be discussed on john-dev before doing anything. I presume the problem exists in john proper? Solar may want to fix this and in that case we should do nothing (except possibly testing ideas for him). Solar has mentioned this, and made a statement about 'IF I ever chose to fix it'. I have done so keeping REC4 format. I simply append a slt-v1 block if there is a salt index (i.e. it is not at 0). It would be very trivial to switch this back to a REC5 structure if we later have that. All the other logic would need no adjustments. Only adjustment is where to grab the 'salt_idx' value.
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

You should revert this and use a topic branch instead. And you should not merge that topic branch ever. Leave that to me.

<!-- gh-comment-id:195512110 --> @magnumripper commented on GitHub (Mar 11, 2016): You should revert this and use a topic branch instead. And you should not merge that topic branch ever. Leave that to me.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Agreed:

What if you have multiple sessions running, and when you restore, some salts got removed due to all passwords being cracked?

This is an important caveat. The current behavior fully supports stopping a job and then resume it when there's much fewer salts left (from cracking in other sessions).

<!-- gh-comment-id:195512398 --> @jfoug commented on GitHub (Mar 11, 2016): Agreed: > > What if you have multiple sessions running, and when you restore, some salts got removed due to all passwords being cracked? > > This is an important caveat. The current behavior fully supports stopping a job and then resume it when there's much fewer salts left (from cracking in other sessions).
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

Don't get me wrong, you might be on to something. Or perhaps not. But you are too trigger happy for sure, with major core changes like this. Using topic branches, you are totally free to commit just anything for testing and reviewing. Even better you are free to git push --force to those topic branches, and/or rebase them, squash commits and so on until you end up with a nice clean fully tested PR for merging.

<!-- gh-comment-id:195515650 --> @magnumripper commented on GitHub (Mar 11, 2016): Don't get me wrong, you might be on to something. Or perhaps not. But you are too trigger happy for sure, with major core changes like this. Using topic branches, you are totally free to commit just anything for testing and reviewing. Even better you are free to `git push --force` to those topic branches, and/or rebase them, squash commits and so on until you end up with a nice clean fully tested PR for merging.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

trust me, if there are 100 salts, and you hit ^c, cracker loop will break out, say after the 54th salt. Upon restore, the first salt (with the same password), is what will be tested.

Even solar knows this, and does not seem to think it is critical enough to fix (until someone else does, probably).

<!-- gh-comment-id:195516250 --> @jfoug commented on GitHub (Mar 11, 2016): trust me, if there are 100 salts, and you hit ^c, cracker loop will break out, say after the 54th salt. Upon restore, the first salt (with the same password), is what will be tested. Even solar knows this, and does not seem to think it is critical enough to fix (until someone else does, probably).
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

trust me, if there are 100 salts, and you hit ^c, cracker loop will break out, say after the 54th salt

I'm pretty sure I've seen the opposite many times. Perhaps you are seeing an actual bug in Jumbo?

<!-- gh-comment-id:195517006 --> @magnumripper commented on GitHub (Mar 11, 2016): > trust me, if there are 100 salts, and you hit ^c, cracker loop will break out, say after the 54th salt I'm pretty sure I've seen the opposite many times. Perhaps you are seeing an actual bug in Jumbo?
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Just look at the code I changed in cracker.c (which was reverted) There is NOTHING that waits until all salts have been addressed for a block. And upon each entry into the crack_salt_loop, we always start at the first salt.

One other ISSUE is salt sorting. This may also be impacted by the input file (as Frank mentioned). I have never liked the salt sorting in cases where it makes little difference. This is another issue that could make multi-salt resuming something that is not resumable.

<!-- gh-comment-id:195517379 --> @jfoug commented on GitHub (Mar 11, 2016): Just look at the code I changed in cracker.c (which was reverted) There is NOTHING that waits until all salts have been addressed for a block. And upon each entry into the crack_salt_loop, we always start at the first salt. One other ISSUE is salt sorting. This may also be impacted by the input file (as Frank mentioned). I have never liked the salt sorting in cases where it makes little difference. This is another issue that could make multi-salt resuming something that is not resumable.
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

Then how come ctrl-c with thousands of slow salts take ages?

<!-- gh-comment-id:195517889 --> @magnumripper commented on GitHub (Mar 11, 2016): Then how come ctrl-c with thousands of slow salts take ages?
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

I'm pretty sure I've seen the opposite many times. Perhaps you are seeing an actual bug in Jumbo?

I doubt it. Even solar mentioned something about this not too long ago and he was talking about core.

One other thing I have seen, is that the LAST crack block is NOT processed for results. That is why I had to grab the external stuff before a block was run.

<!-- gh-comment-id:195518361 --> @jfoug commented on GitHub (Mar 11, 2016): > I'm pretty sure I've seen the opposite many times. Perhaps you are seeing an actual bug in Jumbo? I doubt it. Even solar mentioned something about this not too long ago and he was talking about core. One other thing I have seen, is that the LAST crack block is NOT processed for results. That is why I had to grab the external stuff before a block was run.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Then how come ctrl-c with thousands of slow salts take ages?

It doesn't, trust me. But ^c will NOT break out of a crypt_all call.

<!-- gh-comment-id:195518615 --> @jfoug commented on GitHub (Mar 11, 2016): > Then how come ctrl-c with thousands of slow salts take ages? It doesn't, trust me. But ^c will NOT break out of a crypt_all call.
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

Then how come ctrl-c with thousands of slow salts take ages?

It doesn't, trust me. But ^c will NOT break out of a crypt_all call.

Are you testing this under Cygwin?

There is NOTHING that waits until all salts have been addressed for a block

I see nothing that looks at event_abort until all salts HAVE been addressed.

<!-- gh-comment-id:195519251 --> @magnumripper commented on GitHub (Mar 11, 2016): > > Then how come ctrl-c with thousands of slow salts take ages? > > It doesn't, trust me. But ^c will NOT break out of a crypt_all call. Are you testing this under Cygwin? > There is NOTHING that waits until all salts have been addressed for a block I see nothing that looks at event_abort until all salts HAVE been addressed.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Look at my multi-salt test hash. The get_key appends the salt (well, if not in benchmark mode, so I can fool the damn logic). So I get the actual salt being used being appended. I have 9 salts in my input file SLT1 to SLT9. Look at the running results:

$ OMP_NUM_THREADS=1 ../run/john -rules=appendnumnum -mem=5 -w=tst-x.dic tst-x.in -ses=tst-x -pot=tst-x.pot
Loaded 9 password hashes with 9 different salts (restore_tester_salted [None])
000_00$SLT1      (?)
001_00$SLT1      (?)
002_00$SLT1      (?)
000_00$SLT8      (?)
001_00$SLT8      (?)
002_00$SLT8      (?)
000_00$SLT7      (?)
001_00$SLT7      (?)
002_00$SLT7      (?)
000_00$SLT6      (?)
001_00$SLT6      (?)
002_00$SLT6      (?)
000_00$SLT5      (?)
001_00$SLT5      (?)
002_00$SLT5      (?)
000_00$SLT4      (?)
001_00$SLT4      (?)
002_00$SLT4      (?)
000_00$SLT3      (?)
001_00$SLT3      (?)
002_00$SLT3      (?)
000_00$SLT2      (?)
001_00$SLT2      (?)
002_00$SLT2      (?)
000_00$SLT9      (?)
001_00$SLT9      (?)
002_00$SLT9      (?)
003_00$SLT1      (?)
004_00$SLT1      (?)
005_00$SLT1      (?)
003_00$SLT8      (?)
004_00$SLT8      (?)
005_00$SLT8      (?)
003_00$SLT7      (?)
004_00$SLT7      (?)
005_00$SLT7      (?)
003_00$SLT6      (?)
004_00$SLT6      (?)
005_00$SLT6      (?)
39g 0:00:00:02 0.00% (ETA: 2016-03-13 04:42) 16.02g/s 1.232p/s 16.02c/s 16.02C/s 003_00$SLT5..005_00$SLT5
Session aborted

This was with a 'q', but ^c works the same. NOTE, that it exited at salt==SLT6 The way the salts were sorted, SLT9 is the LAST salt.

<!-- gh-comment-id:195519653 --> @jfoug commented on GitHub (Mar 11, 2016): Look at my multi-salt test hash. The get_key appends the salt (well, if not in benchmark mode, so I can fool the damn logic). So I get the actual salt being used being appended. I have 9 salts in my input file SLT1 to SLT9. Look at the running results: ``` $ OMP_NUM_THREADS=1 ../run/john -rules=appendnumnum -mem=5 -w=tst-x.dic tst-x.in -ses=tst-x -pot=tst-x.pot Loaded 9 password hashes with 9 different salts (restore_tester_salted [None]) 000_00$SLT1 (?) 001_00$SLT1 (?) 002_00$SLT1 (?) 000_00$SLT8 (?) 001_00$SLT8 (?) 002_00$SLT8 (?) 000_00$SLT7 (?) 001_00$SLT7 (?) 002_00$SLT7 (?) 000_00$SLT6 (?) 001_00$SLT6 (?) 002_00$SLT6 (?) 000_00$SLT5 (?) 001_00$SLT5 (?) 002_00$SLT5 (?) 000_00$SLT4 (?) 001_00$SLT4 (?) 002_00$SLT4 (?) 000_00$SLT3 (?) 001_00$SLT3 (?) 002_00$SLT3 (?) 000_00$SLT2 (?) 001_00$SLT2 (?) 002_00$SLT2 (?) 000_00$SLT9 (?) 001_00$SLT9 (?) 002_00$SLT9 (?) 003_00$SLT1 (?) 004_00$SLT1 (?) 005_00$SLT1 (?) 003_00$SLT8 (?) 004_00$SLT8 (?) 005_00$SLT8 (?) 003_00$SLT7 (?) 004_00$SLT7 (?) 005_00$SLT7 (?) 003_00$SLT6 (?) 004_00$SLT6 (?) 005_00$SLT6 (?) 39g 0:00:00:02 0.00% (ETA: 2016-03-13 04:42) 16.02g/s 1.232p/s 16.02c/s 16.02C/s 003_00$SLT5..005_00$SLT5 Session aborted ``` This was with a 'q', but ^c works the same. NOTE, that it exited at salt==SLT6 The way the salts were sorted, SLT9 is the LAST salt.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Going to test with ubuntu-64, but I am almost 100% sure, this behavior will be identical there.

<!-- gh-comment-id:195520002 --> @jfoug commented on GitHub (Mar 11, 2016): Going to test with ubuntu-64, but I am almost 100% sure, this behavior will be identical there.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Changing logic to wait until salt is 100% processed is NOT a good thing either. Wow, so you can not exit for weeks ???

<!-- gh-comment-id:195520376 --> @jfoug commented on GitHub (Mar 11, 2016): Changing logic to wait until salt is 100% processed is NOT a good thing either. Wow, so you can not exit for weeks ???
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

Anyway you put it and even if you are 100% right, this should still be a topic branch. We've lived with this since 1992 or so, there's no need to rush it into the main branch.

<!-- gh-comment-id:195520809 --> @magnumripper commented on GitHub (Mar 11, 2016): Anyway you put it and even if you are 100% right, this should still be a topic branch. We've lived with this since 1992 or so, there's no need to rush it into the main branch.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

This was from ubuntu. Note, salts are sorted differently (ugg). Also, it exited after the 2nd salt on the 2nd set of words

000_00$SLT9      (?)
001_00$SLT9      (?)
002_00$SLT9      (?)
000_00$SLT8      (?)
001_00$SLT8      (?)
002_00$SLT8      (?)
000_00$SLT7      (?)
001_00$SLT7      (?)
002_00$SLT7      (?)
000_00$SLT6      (?)
001_00$SLT6      (?)
002_00$SLT6      (?)
000_00$SLT5      (?)
001_00$SLT5      (?)
002_00$SLT5      (?)
000_00$SLT4      (?)
001_00$SLT4      (?)
002_00$SLT4      (?)
000_00$SLT3      (?)
001_00$SLT3      (?)
002_00$SLT3      (?)
000_00$SLT2      (?)
001_00$SLT2      (?)
002_00$SLT2      (?)
000_00$SLT1      (?)
001_00$SLT1      (?)
002_00$SLT1      (?)
003_00$SLT9      (?)
004_00$SLT9      (?)
005_00$SLT9      (?)
003_00$SLT8      (?)
004_00$SLT8      (?)
005_00$SLT8      (?)
<!-- gh-comment-id:195522926 --> @jfoug commented on GitHub (Mar 11, 2016): This was from ubuntu. Note, salts are sorted differently (ugg). Also, it exited after the 2nd salt on the 2nd set of words ``` 000_00$SLT9 (?) 001_00$SLT9 (?) 002_00$SLT9 (?) 000_00$SLT8 (?) 001_00$SLT8 (?) 002_00$SLT8 (?) 000_00$SLT7 (?) 001_00$SLT7 (?) 002_00$SLT7 (?) 000_00$SLT6 (?) 001_00$SLT6 (?) 002_00$SLT6 (?) 000_00$SLT5 (?) 001_00$SLT5 (?) 002_00$SLT5 (?) 000_00$SLT4 (?) 001_00$SLT4 (?) 002_00$SLT4 (?) 000_00$SLT3 (?) 001_00$SLT3 (?) 002_00$SLT3 (?) 000_00$SLT2 (?) 001_00$SLT2 (?) 002_00$SLT2 (?) 000_00$SLT1 (?) 001_00$SLT1 (?) 002_00$SLT1 (?) 003_00$SLT9 (?) 004_00$SLT9 (?) 005_00$SLT9 (?) 003_00$SLT8 (?) 004_00$SLT8 (?) 005_00$SLT8 (?) ```
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

I just can't see any place in the code that would make it exit before completing the salt loop. Short of sending a second signal, for a brutal abort. Just HOW does it exit?!

<!-- gh-comment-id:195523813 --> @magnumripper commented on GitHub (Mar 11, 2016): I just can't see any place in the code that would make it exit before completing the salt loop. Short of sending a second signal, for a brutal abort. Just HOW does it exit?!
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

This is why the restore_tester format is so sweet. It shows just WTF is going on, and how you 'think' it works does not matter. This is actually how things ARE running.

<!-- gh-comment-id:195523957 --> @jfoug commented on GitHub (Mar 11, 2016): This is why the restore_tester format is so sweet. It shows just WTF is going on, and how you 'think' it works does not matter. This is actually how things ARE running.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

It happens right here:

static int crk_password_loop(struct db_salt *salt)
{
    void ext_hybrid_fix_state(void);
    int count;
    unsigned int match, index;
#if CRK_PREFETCH
    unsigned int target;
#endif

#if !OS_TIMER
    sig_timer_emu_tick();
#endif

    idle_yield();

++  if (event_pending && crk_process_event())
++      return -1;

Could idle_yield also cause the signal to get there?

<!-- gh-comment-id:195525304 --> @jfoug commented on GitHub (Mar 11, 2016): It happens right here: ``` C static int crk_password_loop(struct db_salt *salt) { void ext_hybrid_fix_state(void); int count; unsigned int match, index; #if CRK_PREFETCH unsigned int target; #endif #if !OS_TIMER sig_timer_emu_tick(); #endif idle_yield(); ++ if (event_pending && crk_process_event()) ++ return -1; ``` Could idle_yield also cause the signal to get there?
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

That is why I add my 'fix_state()' call(s) RIGHT after that return -1, and before the call to crypt_all that follows. The bad thing, is that all work done IN that call to crypt all (the very last one), is tossed away, and not used. That 'may' be what has to happen, to make sure that everything gets properly re-tested, but it makes storing off these 'extra' resume blocks harder. I was able to get it done, but it is not something that can simply be done at the time of the exit. If done there, then the 'extra' steps will be crypt_all count ahead of where the proper resume location actually is.

<!-- gh-comment-id:195526240 --> @jfoug commented on GitHub (Mar 11, 2016): That is why I add my 'fix_state()' call(s) RIGHT after that return -1, and before the call to crypt_all that follows. The bad thing, is that all work done IN that call to crypt all (the very last one), is tossed away, and not used. That 'may' be what has to happen, to make sure that everything gets properly re-tested, but it makes storing off these 'extra' resume blocks harder. I was able to get it done, but it is not something that can simply be done at the time of the exit. If done there, then the 'extra' steps will be crypt_all count ahead of where the proper resume location actually is.
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

OK, now I see how this can happen. And I'm definitely all for enhancing this, as long as it starts off in a topic branch.

<!-- gh-comment-id:195526769 --> @magnumripper commented on GitHub (Mar 11, 2016): OK, now I see how this can happen. And I'm definitely all for enhancing this, as long as it starts off in a topic branch.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

Ok, will do. What exactly do you mean by 'topic branch' A pull request or fork ? just it's own issue ?

Now that I see all the additional nuances in this, it does make it a tougher issue.

One thing that 'could' help here, is to store the total count of salts (in the .rec file), AND a sha1 of all salt data, taken in order. That way, upon restore, we would know that all salts were there, AND the order of them. If that data does NOT check out, then the salt_idx is simply set to 0, so that all salts are re-checked, since it is not possible to restore properly.

<!-- gh-comment-id:195531718 --> @jfoug commented on GitHub (Mar 11, 2016): Ok, will do. What exactly do you mean by 'topic branch' A pull request or fork ? just it's own issue ? Now that I see all the additional nuances in this, it does make it a tougher issue. One thing that 'could' help here, is to store the total count of salts (in the .rec file), AND a sha1 of all salt data, taken in order. That way, upon restore, we would know that all salts were there, AND the order of them. If that data does NOT check out, then the salt_idx is simply set to 0, so that all salts are re-checked, since it is not possible to restore properly.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

multisalt-resume branch made.

<!-- gh-comment-id:195534769 --> @jfoug commented on GitHub (Mar 11, 2016): multisalt-resume branch made.
Author
Owner

@jfoug commented on GitHub (Mar 11, 2016):

github.com/magnumripper/JohnTheRipper@e67bb3a798

This addresses ALL issues talked about on this thread. Yes, we still should see how Solar wants to proceed with this.

This version stores the salt-count and a sha1 of the salt data. If there is ANY changes to the order of salts (or what salts are there) then the salt-recover will simply start at the beginning of the salt list, since there is no assurance that we could ever recover.

I am sure dyna-salts will need to be looked at also (they are not 'yet'). This version also still keeps the REC4 structure (but 'could' easily be incorporated into a REC5 if we later need to).

<!-- gh-comment-id:195588942 --> @jfoug commented on GitHub (Mar 11, 2016): https://github.com/magnumripper/JohnTheRipper/commit/e67bb3a798ff4fee8479c2845993c92a19a674f1 This addresses ALL issues talked about on this thread. Yes, we still should see how Solar wants to proceed with this. This version stores the salt-count and a sha1 of the salt data. If there is ANY changes to the order of salts (or what salts are there) then the salt-recover will simply start at the beginning of the salt list, since there is no assurance that we could ever recover. I am sure dyna-salts will need to be looked at also (they are not 'yet'). This version also still keeps the REC4 structure (but 'could' easily be incorporated into a REC5 if we later need to).
Author
Owner

@magnumripper commented on GitHub (Mar 11, 2016):

Great, now we have something to test and tweak. Some thoughts after just a quick glance:

  • I believe salts do get removed during cracking, and the list changes. But it may be a bad idea recalculating the SHA-1 every time (I'm not sure). Just how slow is this?
  • For dynamic salts, we should ideally only SHA-1 the "salt compare part" of the salt. I guess we could add that functionality in some way, but as long as your code falls back correctly it's not a show stopper at all.

That AM leak (or what was the name) bcrypt with sooo many salts might be a good test case. I think I'll experiment with a john.conf setting that says we should NOT abort the salt loop at exit unless signalled twice. But I'm pretty sure the AM case will show this work of yours is needed anyway.

What exactly do you mean by 'topic branch' A pull request or fork ? just it's own issue ?

Your new branch "multisalt-resume" is a topic branch. You could also open up a PR for it already, just like you've done for rexgen. That PR will let us see the "sum of all commits" compared to the main branch, as well as each individual commit.

<!-- gh-comment-id:195601956 --> @magnumripper commented on GitHub (Mar 11, 2016): Great, now we have something to test and tweak. Some thoughts after just a quick glance: - I believe salts do get removed during cracking, and the list changes. But it may be a bad idea recalculating the SHA-1 every time (I'm not sure). Just how slow is this? - For dynamic salts, we should ideally only SHA-1 the "salt compare part" of the salt. I guess we could add that functionality in some way, but as long as your code falls back correctly it's not a show stopper at all. That AM leak (or what was the name) bcrypt with sooo many salts might be a good test case. I think I'll experiment with a john.conf setting that says we should NOT abort the salt loop at exit unless signalled twice. But I'm pretty sure the AM case will show this work of yours is needed anyway. > What exactly do you mean by 'topic branch' A pull request or fork ? just it's own issue ? Your new branch "multisalt-resume" is a topic branch. You could also open up a PR for it already, just like you've done for rexgen. That PR will let us see the "sum of all commits" compared to the main branch, as well as each individual commit.
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

It is likely going to be much harder than this.

Again, back to what Frank had mentioned (now that I have decompressed a bit and thought about it).

Take for instance you have several runs going, over the same data, but with different worksets. Each are working on the data, but doing it independently. None have work completed by any of the others. They may not even be running at the same time. For instance run #1 was a incremental number, 10 digits. It was working fine, but when it slowed to a specific rate, it was broken out of and 'documented' and the .rec file kept. Then other runs were done which produced better rates. But at some point, those searches started to produce slower than the saved off incremental 10digit run. So now that one is restarted. However, when the .pot file reduces the salts, there will be MANY salts not there, so with the blind logic I have here, the salt hashes will not match, so the salts will be started from the beginning for the first block of candidate words (same behavior as without salt restarting).

So, I am re-thinking the logic. What I think I need is:

  1. the salt sort has to be EXACTLY the same, every time, without regard to the input value order.
  2. hashing information must be stored about the EXACT salt that is currently being worked on (at time of .rec save).
  3. this logic likely should be made optional, default off, which would be current behavior.

With those rules, I am pretty sure I can get salt restore to work correctly every time.

There are 3 salt 'types', and each will have to be addressed.

  1. normal salt
  2. dyna salt
  3. salt of the dynamic format
<!-- gh-comment-id:195659984 --> @jfoug commented on GitHub (Mar 12, 2016): It is likely going to be much harder than this. Again, back to what Frank had mentioned (now that I have decompressed a bit and thought about it). Take for instance you have several runs going, over the same data, but with different worksets. Each are working on the data, but doing it independently. None have work completed by any of the others. They may not even be running at the same time. For instance run #1 was a incremental number, 10 digits. It was working fine, but when it slowed to a specific rate, it was broken out of and 'documented' and the .rec file kept. Then other runs were done which produced better rates. But at some point, those searches started to produce slower than the saved off incremental 10digit run. So now that one is restarted. However, when the .pot file reduces the salts, there will be MANY salts not there, so with the blind logic I have here, the salt hashes will not match, so the salts will be started from the beginning for the first block of candidate words (same behavior as without salt restarting). So, I am re-thinking the logic. What I think I need is: 1. the salt sort has to be EXACTLY the same, every time, without regard to the input value order. 2. hashing information must be stored about the EXACT salt that is currently being worked on (at time of .rec save). 3. this logic likely should be made optional, default off, which would be current behavior. With those rules, I am pretty sure I can get salt restore to work correctly every time. There are 3 salt 'types', and each will have to be addressed. 1. normal salt 2. dyna salt 3. salt of the dynamic format
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

I believe salts do get removed during cracking, and the list changes. But it may be a bad idea recalculating the SHA-1 every time (I'm not sure). Just how slow is this?

We may not have to compute SHA1 of entire set. In fact, I really think that idea is now DOA (see message above)

That AM leak (or what was the name) bcrypt with sooo many salts might be a good test case. I think I'll experiment with a john.conf setting that says we should NOT abort the salt loop at exit unless signalled twice. But I'm pretty sure the AM case will show this work of yours is needed anyway.

The Ashley Madison stuff is what I am cracking on, but only on a dynamic-4 type which is much faster.

The full AM (bcrypt) takes months to compute all salts against 3 passwords. SO if you add that logic, and hit 'q', expect to wait a bit, lol!

<!-- gh-comment-id:195660258 --> @jfoug commented on GitHub (Mar 12, 2016): > I believe salts do get removed during cracking, and the list changes. But it may be a bad idea recalculating the SHA-1 every time (I'm not sure). Just how slow is this? We may not have to compute SHA1 of entire set. In fact, I really think that idea is now DOA (see message above) > That AM leak (or what was the name) bcrypt with sooo many salts might be a good test case. I think I'll experiment with a john.conf setting that says we should NOT abort the salt loop at exit unless signalled twice. But I'm pretty sure the AM case will show this work of yours is needed anyway. The Ashley Madison stuff is what I am cracking on, but only on a dynamic-4 type which is much faster. The full AM (bcrypt) takes months to compute all salts against 3 passwords. SO if you add that logic, and hit 'q', expect to wait a bit, lol!
Author
Owner

@magnumripper commented on GitHub (Mar 12, 2016):

So, I am re-thinking the logic. What I think I need is:

  1. the salt sort has to be EXACTLY the same, every time, without regard to the input value order.
  2. hashing information must be stored about the EXACT salt that is currently being worked on (at time of .rec save).
  3. this logic likely should be made optional, default off, which would be current behavior.

We have a default AlwaysSortSalts = Y that sort salts most used first. This will screw things up. Given we drop that default, I guess you could just

  1. Always store a hash (or some other id) of current salt, ie. the salt a resumed session should start with.
  2. At resume, look for that salt. If it exists, we continue there - if not, we start the loop from scratch.

However, we don't want to perform a SHA-1 every time we switch salt. Yet we can't wait until "needed" because a hard kill should ideally resume perfectly too (the AM will nearly always be a hard kill).

I'm not sure we need any fix at all, except possibly add an option to actually process all salts before soft abort. Given that, you'd simply run a sane number of salts at a time and there'll be no problem.
We don't need a fix for the case "months to compute all salts against 3 passwords" because that case is hopeless regardless.

<!-- gh-comment-id:195699625 --> @magnumripper commented on GitHub (Mar 12, 2016): > So, I am re-thinking the logic. What I think I need is: > 1. the salt sort has to be EXACTLY the same, every time, without regard to the input value order. > 2. hashing information must be stored about the EXACT salt that is currently being worked on (at time of .rec save). > 3. this logic likely should be made optional, default off, which would be current behavior. We have a default `AlwaysSortSalts = Y` that sort salts _most used first_. This will screw things up. Given we drop that default, I guess you could just 1. Always store a hash (or some other id) of current salt, ie. the salt a resumed session should start with. 2. At resume, look for that salt. If it exists, we continue there - if not, we start the loop from scratch. However, we don't want to perform a SHA-1 every time we switch salt. Yet we can't wait until "needed" because a hard kill should ideally resume perfectly too (the AM will nearly always be a hard kill). I'm not sure we need any fix at all, except possibly add an option to actually process all salts before soft abort. Given that, you'd simply run a sane number of salts at a time and there'll be no problem. We don't need a fix for the case "months to compute all salts against 3 passwords" because that case is hopeless regardless.
Author
Owner

@magnumripper commented on GitHub (Mar 12, 2016):

Perhaps simply using the existing "salt hash" is good enough? It will home in to the right neighborhood even if that bucket contains several salts. And the salt hash is readily available.

<!-- gh-comment-id:195699694 --> @magnumripper commented on GitHub (Mar 12, 2016): Perhaps simply using the existing "salt hash" is good enough? It will home in to the right neighborhood even if that bucket contains several salts. And the salt hash is readily available.
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

This type salt_compare function is a no go (from 7z)

static int salt_compare(const void *x, const void *y)
{
    const struct custom_salt *s1 = x;
    const struct custom_salt *s2 = y;

    return (s1->NumCyclesPower - s2->NumCyclesPower);
}

This is due to undefined order if NumCyclesPower is same in a group.

So the above needs to be something like:

static int salt_compare(const void *x, const void *y)
{
    const struct custom_salt *s1 = x;
    const struct custom_salt *s2 = y;
    if (s1->NumCyclesPower != s2->NumCyclesPower)
       return (s1->NumCyclesPower - s2->NumCyclesPower);
     return (some comparison that is repeatable)
}

Dynamic format will also need adjustment. It sorts solely based upon salt length (that is a REQUIREMENT for dynamic due to implementation issues). But there will need to be a strcmp/memcmp added if the lengths are equal, so that the end result is 100% repeatable.

Again, we have to store some indication of the salt being worked on (that may be salt-hash AND some other exact hash of the salt). Then upon restart, we scan for the salt-hash, and if found not found, we start over. Then we scan the salts for the right value, and if not found, start at the first one of that salt hash. If an exact match is found, then we know that we need to start there.

That should be universal working, even if it has to fall back and redo salts (because the salt it no longer there, and was cracked somewhere else). It is likely that the 'matching id' could be done at salt load time, and stored, so no run-time recompute is needed.

<!-- gh-comment-id:195752970 --> @jfoug commented on GitHub (Mar 12, 2016): This type salt_compare function is a no go (from 7z) ``` C static int salt_compare(const void *x, const void *y) { const struct custom_salt *s1 = x; const struct custom_salt *s2 = y; return (s1->NumCyclesPower - s2->NumCyclesPower); } ``` This is due to undefined order if NumCyclesPower is same in a group. So the above needs to be something like: ``` C static int salt_compare(const void *x, const void *y) { const struct custom_salt *s1 = x; const struct custom_salt *s2 = y; if (s1->NumCyclesPower != s2->NumCyclesPower) return (s1->NumCyclesPower - s2->NumCyclesPower); return (some comparison that is repeatable) } ``` Dynamic format will also need adjustment. It sorts solely based upon salt length (that is a REQUIREMENT for dynamic due to implementation issues). But there will need to be a strcmp/memcmp added if the lengths are equal, so that the end result is 100% repeatable. Again, we have to store some indication of the salt being worked on (that may be salt-hash AND some other exact hash of the salt). Then upon restart, we scan for the salt-hash, and if found not found, we start over. Then we scan the salts for the right value, and if not found, start at the first one of that salt hash. If an exact match is found, then we know that we need to start there. That should be universal working, even if it has to fall back and redo salts (because the salt it no longer there, and was cracked somewhere else). It is likely that the 'matching id' could be done at salt load time, and stored, so no run-time recompute is needed.
Author
Owner

@frank-dittrich commented on GitHub (Mar 12, 2016):

This type salt_compare function is a no go (from 7z)

It wasn't a problem until you started to use the salt_compare() function for something new.
formats.h doesn't mention the need to never return 0.
So far, the "unreliable" sequence didn't hurt. The format only cared about sorting salts based on NumCyclesPower.
So may be if you have additional requirements, you should implement your own comparison function.
Wouldn't you need a stable sequence even if the format doesn't have a salt_compare() function?
(Not sure how ugly it gets if you want to make use of the format's salt_compare(), and only take care of never returning 0...)

<!-- gh-comment-id:195761348 --> @frank-dittrich commented on GitHub (Mar 12, 2016): > This type salt_compare function is a no go (from 7z) It wasn't a problem until you started to use the salt_compare() function for something new. formats.h doesn't mention the need to never return 0. So far, the "unreliable" sequence didn't hurt. The format only cared about sorting salts based on NumCyclesPower. So may be if you have additional requirements, you should implement your own comparison function. Wouldn't you need a stable sequence even if the format doesn't have a salt_compare() function? (Not sure how ugly it gets if you want to make use of the format's salt_compare(), and only take care of never returning 0...)
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

github.com/magnumripper/JohnTheRipper@f7659bd03d

This should have ALL salts in deterministic order (BUT does this not happen if that AlwaysSortSalts = N ???

Now, I should also comment the salt_sort. Basically, it needs to provide an fully useful comparison function ready for qsort. The ONLY way to have qsort be deterministic (if there are NO dupes), is to never return 0, UNLESS the values match. Thus if there are no matching salts, then a properly written qsort should never see a 0 return from the int(cmp_)(void_,void*) function NOTE, there are busted implementations of qsort (they still work, just not optimally), where the qsort function will compare a value against itself. So it is not 100% out of realm to return a 0, BUT it should only be done if the salts is actually 100% identical. Also, I think salt_cmp is called during loader, to see if salt is the same, or does loader simply do a memcmp() call ?

The salt_cmp() should really behave like memcmp. It can be 'smart' about it, but if the salt is not 100% equal to the other salt, then 0 should not be returned.

The salt_cmp_num was easy to fix. I just passed in the salts, pre-called dyna_salt_init, and then use the dyna_salt_cmp function.

<!-- gh-comment-id:195778033 --> @jfoug commented on GitHub (Mar 12, 2016): https://github.com/magnumripper/JohnTheRipper/commit/f7659bd03d89accb022aa2f5ab56e525bf308ef7 This should have ALL salts in deterministic order (BUT does this not happen if that `AlwaysSortSalts = N` ??? Now, I should also comment the salt_sort. Basically, it needs to provide an fully useful comparison function ready for qsort. The ONLY way to have qsort be deterministic (if there are NO dupes), is to never return 0, UNLESS the values match. Thus if there are no matching salts, then a properly written qsort should never see a 0 return from the int(cmp_)(void_,void*) function NOTE, there are busted implementations of qsort (they still work, just not optimally), where the qsort function will compare a value against itself. So it is not 100% out of realm to return a 0, BUT it should only be done if the salts is actually 100% identical. Also, I think salt_cmp is called during loader, to see if salt is the same, or does loader simply do a memcmp() call ? The salt_cmp() should really behave like memcmp. It can be 'smart' about it, but if the salt is not 100% equal to the other salt, then 0 should not be returned. The salt_cmp_num was easy to fix. I just passed in the salts, pre-called dyna_salt_init, and then use the dyna_salt_cmp function.
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

We may have to change this in loader, to simply always sort, OR if not sorted, then there will be no salt-resume logic added for the current session (unless it has a fmt.salt_compare function).

    int always;

    always = cfg_get_bool(SECTION_OPTIONS, NULL, "AlwaysSortSalts", 1);

    if (db->salt_count < 2 || (!fmt_salt_compare && !always))
        return;
// sorting happens later in the ldr function

@magnumripper what do you think?

NOTE, if the order of the input file is not changed, and there is no sorting, then I believe the salt order would still be deterministic. This may not be 100% correct, since I think the salt_hash buckets are created, and if there are some buckets removed, it would change the order of the buckets. NOTE, I still do not have my mind fully around all the intricacies of how salts are stored, with or without salt_hash functions.

<!-- gh-comment-id:195780692 --> @jfoug commented on GitHub (Mar 12, 2016): We may have to change this in loader, to simply always sort, OR if not sorted, then there will be no salt-resume logic added for the current session (unless it has a fmt.salt_compare function). ``` C int always; always = cfg_get_bool(SECTION_OPTIONS, NULL, "AlwaysSortSalts", 1); if (db->salt_count < 2 || (!fmt_salt_compare && !always)) return; // sorting happens later in the ldr function ``` @magnumripper what do you think? NOTE, if the order of the input file is not changed, and there is no sorting, then I believe the salt order would still be deterministic. This may not be 100% correct, since I think the salt_hash buckets are created, and if there are some buckets removed, it would change the order of the buckets. NOTE, I still do not have my mind fully around all the intricacies of how salts are stored, with or without salt_hash functions.
Author
Owner

@magnumripper commented on GitHub (Mar 12, 2016):

I think your focus is completely off. Only a handful formats have their own salt sort, and we can ignore this new resume enhancement for them.

You should focus on the 400+ other formats.

<!-- gh-comment-id:195790439 --> @magnumripper commented on GitHub (Mar 12, 2016): I think your focus is completely off. Only a handful formats have their own salt sort, and we can ignore this new resume enhancement for them. You should focus on the 400+ other formats.
Author
Owner

@magnumripper commented on GitHub (Mar 12, 2016):

No, wait... we NEED a default salt sort that is deterministic, that is what you say right? The ones that currently (optionally) is salted by "most used first" should instead default to some deterministic order.

<!-- gh-comment-id:195791177 --> @magnumripper commented on GitHub (Mar 12, 2016): No, wait... we NEED a _default_ salt sort that is deterministic, that is what you say right? The ones that currently (optionally) is salted by "most used first" should instead default to some deterministic order.
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

No, wait... we NEED a default salt sort that is deterministic, that is what you say right?

Absolutely. That is what I have right now, in the 2nd commit to this branch. I have also 'fixed' the other formats to properly sort (dynamic and the 2 7z's which should get unified code).

I have also looked at the salt_hash, and it appears to play no part at all, when we get to the cracker loop (which is where we have to 'skip' salts to resume. I made a 3rd test format, that also added a salt_hash, and the salt hash was simply the 4th byte (minus '0'). Note, that the salts are in deterministic salt order. They do not give a crap about the salt hash. I am pretty sure that was only used during the loader code reading salts, and striking them off from the .pot file.

000_ salt->SAT0 salthash->0 (?)
001_ salt->SAT0 salthash->0 (?)
002_ salt->SAT0 salthash->0 (?)
000_ salt->SAT1 salthash->1 (?)
001_ salt->SAT1 salthash->1 (?)
002_ salt->SAT1 salthash->1 (?)
000_ salt->SAT2 salthash->2 (?)
001_ salt->SAT2 salthash->2 (?)
002_ salt->SAT2 salthash->2 (?)
000_ salt->SAT3 salthash->3 (?)
001_ salt->SAT3 salthash->3 (?)
002_ salt->SAT3 salthash->3 (?)
000_ salt->SAT4 salthash->4 (?)
001_ salt->SAT4 salthash->4 (?)
002_ salt->SAT4 salthash->4 (?)
000_ salt->SAT5 salthash->5 (?)
001_ salt->SAT5 salthash->5 (?)
002_ salt->SAT5 salthash->5 (?)
000_ salt->SAT6 salthash->6 (?)
001_ salt->SAT6 salthash->6 (?)
002_ salt->SAT6 salthash->6 (?)
000_ salt->SAT7 salthash->7 (?)
001_ salt->SAT7 salthash->7 (?)
002_ salt->SAT7 salthash->7 (?)
000_ salt->SAT8 salthash->8 (?)
001_ salt->SAT8 salthash->8 (?)
002_ salt->SAT8 salthash->8 (?)
000_ salt->SAT9 salthash->9 (?)
001_ salt->SAT9 salthash->9 (?)
002_ salt->SAT9 salthash->9 (?)
000_ salt->SLT0 salthash->0 (?)
001_ salt->SLT0 salthash->0 (?)
002_ salt->SLT0 salthash->0 (?)
000_ salt->SLT1 salthash->1 (?)
001_ salt->SLT1 salthash->1 (?)
002_ salt->SLT1 salthash->1 (?)
000_ salt->SLT2 salthash->2 (?)
<!-- gh-comment-id:195792797 --> @jfoug commented on GitHub (Mar 12, 2016): > No, wait... we NEED a default salt sort that is deterministic, that is what you say right? Absolutely. That is what I have right now, in the 2nd commit to this branch. I have also 'fixed' the other formats to properly sort (dynamic and the 2 7z's which should get unified code). I have also looked at the salt_hash, and it appears to play no part at all, when we get to the cracker loop (which is where we have to 'skip' salts to resume. I made a 3rd test format, that also added a salt_hash, and the salt hash was simply the 4th byte (minus '0'). Note, that the salts are in deterministic salt order. They do not give a crap about the salt hash. I am pretty sure that was only used during the loader code reading salts, and striking them off from the .pot file. ``` 000_ salt->SAT0 salthash->0 (?) 001_ salt->SAT0 salthash->0 (?) 002_ salt->SAT0 salthash->0 (?) 000_ salt->SAT1 salthash->1 (?) 001_ salt->SAT1 salthash->1 (?) 002_ salt->SAT1 salthash->1 (?) 000_ salt->SAT2 salthash->2 (?) 001_ salt->SAT2 salthash->2 (?) 002_ salt->SAT2 salthash->2 (?) 000_ salt->SAT3 salthash->3 (?) 001_ salt->SAT3 salthash->3 (?) 002_ salt->SAT3 salthash->3 (?) 000_ salt->SAT4 salthash->4 (?) 001_ salt->SAT4 salthash->4 (?) 002_ salt->SAT4 salthash->4 (?) 000_ salt->SAT5 salthash->5 (?) 001_ salt->SAT5 salthash->5 (?) 002_ salt->SAT5 salthash->5 (?) 000_ salt->SAT6 salthash->6 (?) 001_ salt->SAT6 salthash->6 (?) 002_ salt->SAT6 salthash->6 (?) 000_ salt->SAT7 salthash->7 (?) 001_ salt->SAT7 salthash->7 (?) 002_ salt->SAT7 salthash->7 (?) 000_ salt->SAT8 salthash->8 (?) 001_ salt->SAT8 salthash->8 (?) 002_ salt->SAT8 salthash->8 (?) 000_ salt->SAT9 salthash->9 (?) 001_ salt->SAT9 salthash->9 (?) 002_ salt->SAT9 salthash->9 (?) 000_ salt->SLT0 salthash->0 (?) 001_ salt->SLT0 salthash->0 (?) 002_ salt->SLT0 salthash->0 (?) 000_ salt->SLT1 salthash->1 (?) 001_ salt->SLT1 salthash->1 (?) 002_ salt->SLT1 salthash->1 (?) 000_ salt->SLT2 salthash->2 (?) ```
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

This really should be a very easy solution, now that I am fully seeing the nuances of the salt running and am able to get salts into deterministic order all the time (note, I am 'assuming' that AlwaysSortSalts = Y behavior will simply have to be done always, or if it is NOT done, then salt resume simply starts over.

I now only need to build a universal salt hash, and then on restore search for it. I will likely make this something computed at load time, and then simply used to store the .rec file, and later used to search for the thing. Very easy and should have no overhead during runtime (other than writing a few extra bytes into the .rec file).

If I was not going out on a date for who knows how long (doing a cycle ride with no destination, lol), I would probably get this done today. But I will almost certainly have this branch working correctly by the start of next week.

<!-- gh-comment-id:195794060 --> @jfoug commented on GitHub (Mar 12, 2016): This really should be a very easy solution, now that I am fully seeing the nuances of the salt running and am able to get salts into deterministic order all the time (note, I am 'assuming' that `AlwaysSortSalts = Y` behavior will simply have to be done always, or if it is NOT done, then salt resume simply starts over. I now only need to build a universal salt hash, and then on restore search for it. I will likely make this something computed at load time, and then simply used to store the .rec file, and later used to search for the thing. Very easy and should have no overhead during runtime (other than writing a few extra bytes into the .rec file). If I was not going out on a date for who knows how long (doing a cycle ride with no destination, lol), I would probably get this done today. But I will almost certainly have this branch working correctly by the start of next week.
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

I believe this covers everything.

github.com/magnumripper/JohnTheRipper@5015bc66ae

There is a MD5 hash done at final salt load time (after stripped/sorted salts are loaded back into final usable array).

Before starting a salt, there is a pointer in the status record that is pointed to this md5. NOTE during runtime, setting this pointer is the only CPU hit.

At .rec file writing, the pointer from status is read, a 32 byte buffer ascii buffer built and written to file. No hashing needed.

At recover time, a static buffer is built based upon the prior .rec file saved hash. Also a flag is set in the status object listing that we should resume the salt, if we can find it.

in cracker loop, if that flag is set, we enter a loop that clears the flag, and then searches for the salt (based upon the MD5). If we find it, we skip our salt ahead to that salt record. If not, we simply revert to normal start at first salt logic.

Boom, I think this is it! I see no holes in this logic. It all is based upon getting those salts into the same deterministic sorted order, so that when we find our MD5, we are 'golden'. Unfortunately a linear search is needed, but it is not 'too' bad. I put the MD5 buffers into code as uint32_t [4] array, so most of the walk is simply assigning our salt ptr to s->next and then checking if s->md5[0] == recover->md5[0] so it is all just pointer walking and 32 bit int dereference.

<!-- gh-comment-id:195818163 --> @jfoug commented on GitHub (Mar 12, 2016): I believe this covers everything. https://github.com/magnumripper/JohnTheRipper/commit/5015bc66ae400094d3ef563088ea077c4a395151 There is a MD5 hash done at final salt load time (after stripped/sorted salts are loaded back into final usable array). Before starting a salt, there is a pointer in the status record that is pointed to this md5. NOTE during runtime, setting this pointer is the only CPU hit. At .rec file writing, the pointer from status is read, a 32 byte buffer ascii buffer built and written to file. No hashing needed. At recover time, a static buffer is built based upon the prior .rec file saved hash. Also a flag is set in the status object listing that we should resume the salt, if we can find it. in cracker loop, if that flag is set, we enter a loop that clears the flag, and then searches for the salt (based upon the MD5). If we find it, we skip our salt ahead to that salt record. If not, we simply revert to normal start at first salt logic. Boom, I think this is it! I see no holes in this logic. It all is based upon getting those salts into the same deterministic sorted order, so that when we find our MD5, we are 'golden'. Unfortunately a linear search is needed, but it is not 'too' bad. I put the MD5 buffers into code as uint32_t [4] array, so most of the walk is simply assigning our salt ptr to s->next and then checking if s->md5[0] == recover->md5[0] so it is all just pointer walking and 32 bit int dereference.
Author
Owner

@jfoug commented on GitHub (Mar 12, 2016):

Fuk! CI failed :( I gotta see why, grr! Well, that's not good. But should be easy to fix, lol

<!-- gh-comment-id:195818479 --> @jfoug commented on GitHub (Mar 12, 2016): Fuk! CI failed :( I gotta see why, grr! Well, that's not good. But should be easy to fix, lol
Author
Owner

@jfoug commented on GitHub (Mar 14, 2016):

Crap, I can't use this format for core. Core does not know about FMT_NOT_EXACT. Somewhat easy (partial) fix, so it is in there.

Well, it is obvious that core does not restore prior salt work. I was pretty sure Solar had stated this fact prior.

<!-- gh-comment-id:196141684 --> @jfoug commented on GitHub (Mar 14, 2016): Crap, I can't use this format for core. Core does not know about FMT_NOT_EXACT. Somewhat easy (partial) fix, so it is in there. Well, it is obvious that core does not restore prior salt work. I was pretty sure Solar had stated this fact prior.
Author
Owner

@jfoug commented on GitHub (Mar 14, 2016):

How do we test single mode ? Any ideas? I would think we may have to build a version which does a printf of every candidate (or use restore_tester format), and then have a list of words, in order. Then re-run the single mode, breaking out and restarting several times, and make sure that the exact same words were tested, and only tested one time.

Can someone think of an easier way to do this?

<!-- gh-comment-id:196141957 --> @jfoug commented on GitHub (Mar 14, 2016): How do we test single mode ? Any ideas? I would think we may have to build a version which does a printf of every candidate (or use restore_tester format), and then have a list of words, in order. Then re-run the single mode, breaking out and restarting several times, and make sure that the exact same words were tested, and only tested one time. Can someone think of an easier way to do this?
Author
Owner

@frank-dittrich commented on GitHub (Mar 14, 2016):

For single mode, you can have multiple "users" with the same hash. John will try candidates based on all the "user names".
The list of candidates will differ for restarted sessions, because with default single mode settings john will retry successful guesses on all the other hashes. In restored sessions, that will only be done for successful guesses of the restarted session...

<!-- gh-comment-id:196169239 --> @frank-dittrich commented on GitHub (Mar 14, 2016): For single mode, you can have multiple "users" with the same hash. John will try candidates based on all the "user names". The list of candidates will differ for restarted sessions, because with default single mode settings john will retry successful guesses on all the other hashes. In restored sessions, that will only be done for successful guesses of the restarted session...
Author
Owner

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

I've had the idea to allow -single -stdout hashfile for debug purposes (perhaps with -DDEBUG) and make it print candidates instead of (or along with) actually using them. But I'm not sure how to do it with a KISS non-intrusive patch.

<!-- gh-comment-id:196176762 --> @magnumripper commented on GitHub (Mar 14, 2016): I've had the idea to allow `-single -stdout hashfile` for debug purposes (perhaps with -DDEBUG) and make it print candidates instead of (or along with) actually using them. But I'm not sure how to do it with a KISS non-intrusive patch.
Author
Owner

@frank-dittrich commented on GitHub (Mar 14, 2016):

But just printing the candidates will not work, because single mode generates individual candidates per hash, based on user name etc., so you would have to print the hashes as well.
I don't think --stdout should be misused for that.

<!-- gh-comment-id:196183615 --> @frank-dittrich commented on GitHub (Mar 14, 2016): But just printing the candidates will not work, because single mode generates individual candidates per hash, based on user name etc., so you would have to print the hashes as well. I don't think --stdout should be misused for that.
Author
Owner

@jfoug commented on GitHub (Mar 14, 2016):

I have not started on this one yet, but I think the restore_tester will be ideal. It will list candidates and the hash they are being tested on at same time. Ideal I just have to use the salted variety, and make sure each hash has a unique salt.

One thing single will not resume properly, is the try found words against other candidates. But we have ability to replay the .pot file to handle that.

<!-- gh-comment-id:196289820 --> @jfoug commented on GitHub (Mar 14, 2016): I have not started on this one yet, but I think the restore_tester will be ideal. It will list candidates and the hash they are being tested on at same time. Ideal I just have to use the salted variety, and make sure each hash has a unique salt. One thing single will not resume properly, is the try found words against other candidates. But we have ability to replay the .pot file to handle that.
Author
Owner

@jfoug commented on GitHub (Mar 23, 2016):

Then how come ctrl-c with thousands of slow salts take ages?

I think this slow shutdown has to do with rules. What takes long, is if there are a LOT of rules. john will NOT exit, until the current loaded salt/words block has been run against ALL rules.

It must have been seen early on, that rules needed to be either forced to finish, or some form is sub-block restore code added. It looks like solar (or possibly even early with cracker jack) chose to take the easy route, and let the rules complete. However, this is probably not as bad as the resume of salts. For really slow (especially salted formats), you can not use rules much anyway. When it takes days (or weeks), to burn through all the salts on a load of data for a hash, I assure you, that rules are the last thing anyone worries about, lol.

So it may be ok, to have rules 'complete', and not have to worry about sub-resume logic at all. Yes, there will be times where you hit 'q' and it takes a while to exit. How long, depends upon how slow the format is, and how willing you are to have an excruciatingly slow search.

<!-- gh-comment-id:200526059 --> @jfoug commented on GitHub (Mar 23, 2016): > Then how come ctrl-c with thousands of slow salts take ages? I think this slow shutdown has to do with rules. What takes long, is if there are a LOT of rules. john will NOT exit, until the current loaded salt/words block has been run against ALL rules. It must have been seen early on, that rules needed to be either forced to finish, or some form is sub-block restore code added. It looks like solar (or possibly even early with cracker jack) chose to take the easy route, and let the rules complete. However, this is probably not as bad as the resume of salts. For really slow (especially salted formats), you can not use rules much anyway. When it takes days (or weeks), to burn through all the salts on a load of data for a hash, I assure you, that rules are the last thing anyone worries about, lol. So it may be ok, to have rules 'complete', and not have to worry about sub-resume logic at all. Yes, there will be times where you hit 'q' and it takes a while to exit. How long, depends upon how slow the format is, and how willing you are to have an excruciatingly slow search.
Author
Owner

@frank-dittrich commented on GitHub (Mar 23, 2016):

Does that (ctrl-c taking ages) really happen with CPU formats, or is it just with GPU formats with huge max_keys_per_crypt?

<!-- gh-comment-id:200543188 --> @frank-dittrich commented on GitHub (Mar 23, 2016): Does that (ctrl-c taking ages) really happen with CPU formats, or is it just with GPU formats with huge max_keys_per_crypt?
Author
Owner

@magnumripper commented on GitHub (Mar 23, 2016):

I'm pretty sure it happens with CPU formats. @jfoug is probably right.

<!-- gh-comment-id:200549923 --> @magnumripper commented on GitHub (Mar 23, 2016): I'm pretty sure it happens with CPU formats. @jfoug is probably right.
Author
Owner

@jfoug commented on GitHub (Mar 23, 2016):

Its within the cracker loop. Cracker is not going to exit until the rules are exhausted.

However, that logic (which I am GLAD about), was not done for the multi-salts.

So, what this implies, is that there is NO additional logic needed to get -rules[=anything] from restoring properly. It always should be good. But multi-salts, yes, there is need for resume there.

NOTE, I have not tested this (in the multi-salt pull request) so I need to test. Multi-salted hash using -rules. That may have failures, because john may toss us to the next block of words. That will not be a logic error in the multi-salt logic, but will simply be something that may have to change. The restore_tester_fmt will help to easily shine the light on exactly what the functionality is. It may be that the current logic is working fine, and that the save/resume does not go to the next words until the salt is done, and 'only' pauses until all rules have spun through. But that is still to be seen, in the actual running of the executable.

<!-- gh-comment-id:200556651 --> @jfoug commented on GitHub (Mar 23, 2016): Its within the cracker loop. Cracker is not going to exit until the rules are exhausted. However, that logic (which I am GLAD about), was not done for the multi-salts. So, what this implies, is that there is NO additional logic needed to get -rules[=anything] from restoring properly. It always should be good. But multi-salts, yes, there is need for resume there. NOTE, I have not tested this (in the multi-salt pull request) so I need to test. Multi-salted hash using -rules. That may have failures, because john may toss us to the next block of words. That will not be a logic error in the multi-salt logic, but will simply be something that may have to change. The restore_tester_fmt will help to easily shine the light on exactly what the functionality is. It may be that the current logic is working fine, and that the save/resume does not go to the next words until the salt is done, and 'only' pauses until all rules have spun through. But that is still to be seen, in the actual running of the executable.
Author
Owner

@jfoug commented on GitHub (Apr 4, 2016):

This fixes the bug in non-hybrid mask mode (was restarting with the candidate completed just before the save)

$ git diff mask.c
diff --git a/src/mask.c b/src/mask.c
index b78a04c..f9e86f5 100644
--- a/src/mask.c
+++ b/src/mask.c
@@ -1769,7 +1769,8 @@ void mask_save_state(FILE *file)
 int mask_restore_state(FILE *file)
 {
        int i, d;
-       unsigned char uc;
+       unsigned cu;
+       int fixed = 0;
        unsigned long long ull;
        int fail = !(options.flags & FLG_MASK_STACKED);

@@ -1799,9 +1800,24 @@ int mask_restore_state(FILE *file)
                        return fail;
        }

+       /* vc and mingw can not handle %hhu and blow the stack
+          and fail to restart properly */
        for (i = 0; i < cpu_mask_ctx.count; i++)
-       if (fscanf(file, "%hhu\n", &uc) == 1)
-               cpu_mask_ctx.ranges[i].iter = uc;
+       if (fscanf(file, "%u\n", &cu) == 1) {
+               cpu_mask_ctx.ranges[i].iter = cu;
+               /*
+                * Code was starting off with the last value. So increment
+                * things by 1 so we start at the next mask value.
+                */
+               if (!fixed) {
+                       if (++cpu_mask_ctx.ranges[i].iter <
+                           cpu_mask_ctx.ranges[i].count) {
+                               fixed = 1;
+                       } else {
+                               cpu_mask_ctx.ranges[i].iter = 0;
+                       }
+               }
+       }
        else
                return fail;
        restored = 1;

This increments to the next value. I have tested with many 'q' and ^c vs single runs, and the end result with the above change is correct. I am not 100% sure this is the best way to fix this, BUT it does fix it. I am waiting to check this in, to let @magnumripper or @solardiz have a look and see if there is a better way.

<!-- gh-comment-id:205121409 --> @jfoug commented on GitHub (Apr 4, 2016): This fixes the bug in non-hybrid mask mode (was restarting with the candidate completed just before the save) ``` diff $ git diff mask.c diff --git a/src/mask.c b/src/mask.c index b78a04c..f9e86f5 100644 --- a/src/mask.c +++ b/src/mask.c @@ -1769,7 +1769,8 @@ void mask_save_state(FILE *file) int mask_restore_state(FILE *file) { int i, d; - unsigned char uc; + unsigned cu; + int fixed = 0; unsigned long long ull; int fail = !(options.flags & FLG_MASK_STACKED); @@ -1799,9 +1800,24 @@ int mask_restore_state(FILE *file) return fail; } + /* vc and mingw can not handle %hhu and blow the stack + and fail to restart properly */ for (i = 0; i < cpu_mask_ctx.count; i++) - if (fscanf(file, "%hhu\n", &uc) == 1) - cpu_mask_ctx.ranges[i].iter = uc; + if (fscanf(file, "%u\n", &cu) == 1) { + cpu_mask_ctx.ranges[i].iter = cu; + /* + * Code was starting off with the last value. So increment + * things by 1 so we start at the next mask value. + */ + if (!fixed) { + if (++cpu_mask_ctx.ranges[i].iter < + cpu_mask_ctx.ranges[i].count) { + fixed = 1; + } else { + cpu_mask_ctx.ranges[i].iter = 0; + } + } + } else return fail; restored = 1; ``` This increments to the next value. I have tested with many 'q' and ^c vs single runs, and the end result with the above change is correct. I am not 100% sure this is the best way to fix this, BUT it does fix it. I am waiting to check this in, to let @magnumripper or @solardiz have a look and see if there is a better way.
Author
Owner

@jfoug commented on GitHub (Aug 8, 2016):

Rexgen 1.4.0 with proper resume is now checked into bleeding

<!-- gh-comment-id:238280757 --> @jfoug commented on GitHub (Aug 8, 2016): Rexgen 1.4.0 with proper resume is now checked into bleeding
Author
Owner

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

Just throwing this up here: Hashcat now has an alternate quit option 'c' (checkpoint) that is same as 'q' (quit) except the former waits until eg. all keys and salts are processed. It might take ages but it can also be very rewarding when resuming. I had a look at implementing it but it will be very tricky with OMP signaling and stuff.

<!-- gh-comment-id:240839127 --> @magnumripper commented on GitHub (Aug 18, 2016): Just throwing this up here: Hashcat now has an alternate quit option 'c' (checkpoint) that is same as 'q' (quit) except the former waits until eg. all keys and salts are processed. It might take ages but it can also be very rewarding when resuming. I had a look at implementing it but it will be very tricky with OMP signaling and stuff.
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#1392
No description provided.