[GH-ISSUE #985] Should dynamic formats store trailing salts that end in ' ' or '\t' converted to hex? #585

Closed
opened 2026-10-14 03:14:19 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @frank-dittrich on GitHub (Jan 1, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/985

We do have hex conversion of certain salts with problematic characters already, e.g. for salts that would otherwise contain ':' or '$'.
May be salts that end in a trailing space or horizontal tab character (or salts containing ' ' or '\t') should be converted into hex before storing in john.pot.
Otherwise, those hashes will cause trouble if you try to verify the contents of a pot file.

Consider this line:

$dynamic_4$05de5c963ee6234dc7d52f7589a1922b$  :welcome

This is the result of cracking the first osc format self test hash.

When you run

cut -d: -f 1 john.pot > hashes
cut -d: -f 2- john.pot > passwords

and then either

./john --wordlist=passwords hashes --pot=new.pot --format=dynamic_4

or

./john --wordlist=passwords hashes --pot=new.pot --format=osc

you will not be able to verify that this particular hash has been cracked correctly.

The reason is that the loader will strip trailing spaces when loading the hashes:

(bleeding-jumbo)src $ grep -A 5 -n "Skip leading and trailing whitespace" loader.c
347:/* Skip leading and trailing whitespace */
348-        while (*p == ' ' || *p == '\t') p++;
349-        *ciphertext = p;
350-        p += strlen(p) - 1;
351-        while (p > *ciphertext && (*p == ' ' || *p == '\t')) p--;
352-        p++;
Originally created by @frank-dittrich on GitHub (Jan 1, 2015). Original GitHub issue: https://github.com/openwall/john/issues/985 We do have hex conversion of certain salts with problematic characters already, e.g. for salts that would otherwise contain ':' or '$'. May be salts that end in a trailing space or horizontal tab character (or salts containing `' '` or `'\t'`) should be converted into hex before storing in john.pot. Otherwise, those hashes will cause trouble if you try to verify the contents of a pot file. Consider this line: ``` $dynamic_4$05de5c963ee6234dc7d52f7589a1922b$ :welcome ``` This is the result of cracking the first osc format self test hash. When you run ``` cut -d: -f 1 john.pot > hashes cut -d: -f 2- john.pot > passwords ``` and then either ``` ./john --wordlist=passwords hashes --pot=new.pot --format=dynamic_4 ``` or ``` ./john --wordlist=passwords hashes --pot=new.pot --format=osc ``` you will not be able to verify that this particular hash has been cracked correctly. The reason is that the loader will strip trailing spaces when loading the hashes: ``` (bleeding-jumbo)src $ grep -A 5 -n "Skip leading and trailing whitespace" loader.c 347:/* Skip leading and trailing whitespace */ 348- while (*p == ' ' || *p == '\t') p++; 349- *ciphertext = p; 350- p += strlen(p) - 1; 351- while (p > *ciphertext && (*p == ' ' || *p == '\t')) p--; 352- p++; ```
Author
Owner

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

You are probably very right here @frank-dittrich, and this has likely been a problem for a while.

-show lists it. rerun reads it and properly strips out the input for any follow up runs. But yes, you are right, cutting from pot should fail. However, I thought I was doing that already?? I guess I do not cut the hashes from the .pot file, just the passwords, and rerun to make sure that what was written into the .pot can actualiy crack hashes, BUT I think i still use original input hashes as test,, so the TS would not have seen this 'issue'.

The 'issue' is a bit contrived, but I think you are right, and it should be fixed, and this logic added to the set of 'dangerous' salts and turned into HEX before putting into .pot.

<!-- gh-comment-id:68502314 --> @jfoug commented on GitHub (Jan 1, 2015): You are probably very right here @frank-dittrich, and this has likely been a problem for a while. -show lists it. rerun reads it and properly strips out the input for any follow up runs. But yes, you are right, cutting from pot should fail. However, I thought I was doing that already?? I guess I do not cut the hashes from the .pot file, just the passwords, and rerun to make sure that what was written into the .pot can actualiy crack hashes, BUT I think i still use original input hashes as test,, so the TS would not have seen this 'issue'. The 'issue' is a bit contrived, but I think you are right, and it should be fixed, and this logic added to the set of 'dangerous' salts and turned into $HEX$ before putting into .pot.
Author
Owner

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

@frank-dittrich would you mind giving it a go at coding this? It really should not be 'too' hard to find. I think the function is named something like dynamic_remove_hex (or add hex, or something like that). Just look for HEX[$] and it should pop right up. It is in dynamic_utils.c and is function dynamic_FIX_SALT_TO_HEX()

<!-- gh-comment-id:68502424 --> @jfoug commented on GitHub (Jan 1, 2015): @frank-dittrich would you mind giving it a go at coding this? It really should not be 'too' hard to find. I think the function is named something like dynamic_remove_hex (or add hex, or something like that). Just look for HEX[\$] and it should pop right up. It is in dynamic_utils.c and is function dynamic_FIX_SALT_TO_HEX()
Author
Owner

@frank-dittrich commented on GitHub (Jan 2, 2015):

@jfoug done, see commit github.com/magnumripper/JohnTheRipper@ec14e1fe2d.

I guess I'll create a new issue for the --show=LEFT problem I just noticed (see the comment I added to my commit ec14e1f.

<!-- gh-comment-id:68503816 --> @frank-dittrich commented on GitHub (Jan 2, 2015): @jfoug done, see commit https://github.com/magnumripper/JohnTheRipper/commit/ec14e1fe2d19ec51462e6dfe4e0c196c41379c9b. I guess I'll create a new issue for the --show=LEFT problem I just noticed (see the comment I added to my commit ec14e1f.
Author
Owner

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

I think you are right, the show-left has probably been there forever. We have just not spotted it yet.

<!-- gh-comment-id:68505822 --> @jfoug commented on GitHub (Jan 2, 2015): I think you are right, the show-left has probably been there forever. We have just not spotted it yet.
Author
Owner

@frank-dittrich commented on GitHub (Jan 2, 2015):

The original issue has been fixed by github.com/magnumripper/JohnTheRipper@ec14e1fe2d.
There's a separate issue for the --show=LEFT problem: https://github.com/magnumripper/JohnTheRipper/issues/986
I'm closing this one.

<!-- gh-comment-id:68566872 --> @frank-dittrich commented on GitHub (Jan 2, 2015): The original issue has been fixed by https://github.com/magnumripper/JohnTheRipper/commit/ec14e1fe2d19ec51462e6dfe4e0c196c41379c9b. There's a separate issue for the --show=LEFT problem: https://github.com/magnumripper/JohnTheRipper/issues/986 I'm closing this one.
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#585
No description provided.