[GH-ISSUE #710] Dynamic: Spaces in salt lost unless login field present (?) #357

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

Originally created by @magnumripper on GitHub (Aug 10, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/710

Originally assigned to: @jfoug on GitHub.

From CMIYC 2014 mailing list

On 2014-08-09 11:08, Alexander Cherepanov wrote:
Consider a salted md5 hash "05de5c963ee6234dc7d52f7589a1922b" with the salt " " (two spaces) and password "welcome" (taken from osc_fmt_plug.c).

When there is a login in input file non-encoded spaces at the end of the line are processed Ok:

$ echo ':$dynamic_4$05de5c963ee6234dc7d52f7589a1922b$  ' > test.john
$ john-contest --pot=test.pot --format=dynamic_4 test.john
Loaded 1 password hash (dynamic_4 [md5($s.$p) (OSC) 128/128 SSSE3 10x4x3])
Press 'q' or Ctrl-C to abort, almost any other key for status
welcome          ()
1g 0:00:00:00 DONE 2/3 (2014-08-09 12:59) 4.545g/s 1090p/s 1090c/s 1090C/s brian..blazer
Use the "--show" option to display all of the cracked passwords reliably
Session completed

When login is absent the spaces are trimmed?

$ echo '$dynamic_4$05de5c963ee6234dc7d52f7589a1922b$  ' > test.john
$ john-contest --pot=test.pot --format=dynamic_4 test.john
Loaded 1 password hash (dynamic_4 [md5($s.$p) (OSC) 128/128 SSSE3 10x4x3])
Press 'q' or Ctrl-C to abort, almost any other key for status
...

Indeed:

$ printf welcome | md5sum
40be4e59b9a2a2b5dffb918c0e86b3d7  -
$ echo '$dynamic_4$40be4e59b9a2a2b5dffb918c0e86b3d7$  ' > test.john
$ john-contest --pot=test.pot --format=dynamic_4 test.john
Loaded 1 password hash (dynamic_4 [md5($s.$p) (OSC) 128/128 SSSE3 10x4x3])
Press 'q' or Ctrl-C to abort, almost any other key for status
welcome          (?)
1g 0:00:00:00 DONE 2/3 (2014-08-09 13:06) 5.263g/s 1263p/s 1263c/s 1263C/s brian..blazer
Use the "--show" option to display all of the cracked passwords reliably
Session completed 
Originally created by @magnumripper on GitHub (Aug 10, 2014). Original GitHub issue: https://github.com/openwall/john/issues/710 Originally assigned to: @jfoug on GitHub. From CMIYC 2014 mailing list On 2014-08-09 11:08, Alexander Cherepanov wrote: Consider a salted md5 hash "05de5c963ee6234dc7d52f7589a1922b" with the salt " " (two spaces) and password "welcome" (taken from osc_fmt_plug.c). When there is a login in input file non-encoded spaces at the end of the line are processed Ok: ``` $ echo ':$dynamic_4$05de5c963ee6234dc7d52f7589a1922b$ ' > test.john $ john-contest --pot=test.pot --format=dynamic_4 test.john Loaded 1 password hash (dynamic_4 [md5($s.$p) (OSC) 128/128 SSSE3 10x4x3]) Press 'q' or Ctrl-C to abort, almost any other key for status welcome () 1g 0:00:00:00 DONE 2/3 (2014-08-09 12:59) 4.545g/s 1090p/s 1090c/s 1090C/s brian..blazer Use the "--show" option to display all of the cracked passwords reliably Session completed ``` When login is absent the spaces are trimmed? ``` $ echo '$dynamic_4$05de5c963ee6234dc7d52f7589a1922b$ ' > test.john $ john-contest --pot=test.pot --format=dynamic_4 test.john Loaded 1 password hash (dynamic_4 [md5($s.$p) (OSC) 128/128 SSSE3 10x4x3]) Press 'q' or Ctrl-C to abort, almost any other key for status ... ``` Indeed: ``` $ printf welcome | md5sum 40be4e59b9a2a2b5dffb918c0e86b3d7 - $ echo '$dynamic_4$40be4e59b9a2a2b5dffb918c0e86b3d7$ ' > test.john $ john-contest --pot=test.pot --format=dynamic_4 test.john Loaded 1 password hash (dynamic_4 [md5($s.$p) (OSC) 128/128 SSSE3 10x4x3]) Press 'q' or Ctrl-C to abort, almost any other key for status welcome (?) 1g 0:00:00:00 DONE 2/3 (2014-08-09 13:06) 5.263g/s 1263p/s 1263c/s 1263C/s brian..blazer Use the "--show" option to display all of the cracked passwords reliably Session completed ```
bsakaguchi 2026-10-14 03:02:39 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@jfoug commented on GitHub (Aug 13, 2014):

Check loader.c

static int ldr_split_line(char **login, char **ciphertext,
    char **gecos, char **home,
    char *source, struct fmt_main **format,
    struct db_options *db_opts, char *line)
{
..... 
/* Skip leading and trailing whitespace */
        while (*p == ' ' || *p == '\t') p++;
        *ciphertext = p;
        p += strlen(p) - 1;
        while (p > *ciphertext && (*p == ' ' || *p == '\t')) p--;
        p++;

This is only done for the no ciphertext case where login is copied into ciphertext, i.e. no colons, just a raw hash. Keep in mind, that fixing this, COULD cause other things which require the trim, to now fail.

<!-- gh-comment-id:52085096 --> @jfoug commented on GitHub (Aug 13, 2014): Check loader.c ``` static int ldr_split_line(char **login, char **ciphertext, char **gecos, char **home, char *source, struct fmt_main **format, struct db_options *db_opts, char *line) { ..... /* Skip leading and trailing whitespace */ while (*p == ' ' || *p == '\t') p++; *ciphertext = p; p += strlen(p) - 1; while (p > *ciphertext && (*p == ' ' || *p == '\t')) p--; p++; ``` This is only done for the no ciphertext case where login is copied into ciphertext, i.e. no colons, just a raw hash. Keep in mind, that fixing this, COULD cause other things which require the trim, to now fail.
Author
Owner

@magnumripper commented on GitHub (Aug 13, 2014):

OK, here's the commit: 989316c. So this is the very intended behavior, from core. I guess the solution is to encode spaces as HEX. Maybe we should just document that somewhere (where?) and then we could close this.

<!-- gh-comment-id:52088978 --> @magnumripper commented on GitHub (Aug 13, 2014): OK, here's the commit: 989316c. So this is the very intended behavior, from core. I guess the solution is to encode spaces as $HEX$. Maybe we should just document that somewhere (where?) and then we could close this.
Author
Owner

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

I am going to at least change this in raw2dyna.c At least it will be documented there, that if the salt ends in spaces, that it can be 'trimmed' away by jtr core.

I will also document the issue in some dyna text file.

<!-- gh-comment-id:52461137 --> @jfoug commented on GitHub (Aug 18, 2014): I am going to at least change this in raw2dyna.c At least it will be documented there, that if the salt ends in spaces, that it can be 'trimmed' away by jtr core. I will also document the issue in some dyna text file.
Author
Owner

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

We also must make sure of this issue for things like reload of .pot file, etc.

<!-- gh-comment-id:52461328 --> @jfoug commented on GitHub (Aug 18, 2014): We also must make sure of this issue for things like reload of .pot file, etc.
Author
Owner

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

committed ff86e93 and it appears to work in the .pot file. The non-HEX salt is put into the .pot file, but it removes things. The only time this bug 'may' have happened was in that special code that was added to trim raw hashes when read from an input file. So spaces at end of salt 'should' be OK, in other situations.

<!-- gh-comment-id:52463337 --> @jfoug commented on GitHub (Aug 18, 2014): committed ff86e93 and it appears to work in the .pot file. The non-$HEX$ salt is put into the .pot file, but it removes things. The only time this bug 'may' have happened was in that special code that was added to trim raw hashes when read from an input file. So spaces at end of salt 'should' be OK, in other situations.
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#357
No description provided.