[GH-ISSUE #1541] Dynamic $u problems loading raw hashes in @dynamic= type. #1006

Closed
opened 2026-10-14 03:31:38 +07:00 by bsakaguchi · 28 comments
Owner

Originally created by @magnumripper on GitHub (Jul 11, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1541

Originally assigned to: @jfoug on GitHub.

I don't understand dynamic's use of $u at all.

To me, $u is merely a way of saying $s except it's read from the login field (eg. using prepare()) of the line instead of a salt field in the hash (we're not talking about pot entries yet). But this doesn't seem to be the case at all?

doc/DYNAMIC doesn't reveal anything about this.

Looking at test vectors, the hashes seem to get a "salt" of $U<username> (after another $ that separates it from the hash). This does not make any sense to me at all - what does that tag buy you? It's just a salt and could be written as any other salt. The only special with $u should be where it's read from when loading a hash file. Or maybe I'm missing something?

Originally created by @magnumripper on GitHub (Jul 11, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1541 Originally assigned to: @jfoug on GitHub. I don't understand dynamic's use of $u at all. To me, $u is merely a way of saying $s except it's _read from the login field_ (eg. using `prepare()`) of the line instead of a salt field in the hash (we're not talking about pot entries yet). But this doesn't seem to be the case at all? doc/DYNAMIC doesn't reveal anything about this. Looking at test vectors, the hashes seem to get a "salt" of `$U<username>` (after another `$` that separates it from the hash). This does not make any sense to me at all - what does that tag buy you? It's just a salt and could be written as any other salt. The only special with $u should be where it's read from when loading a hash file. Or maybe I'm missing something?
bsakaguchi 2026-10-14 03:31:38 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Jul 11, 2015):

IMO this should work (username "root" password "secret")

$ echo -n rootsecret | md5sum
5450a2c1af3c92f331d093aa12b5e01c

$ echo root:5450a2c1af3c92f331d093aa12b5e01c > test.in

$ ../run/john -form='dynamic=md5($u.$p)' test.in
No password hashes loaded (see FAQ)

$ echo 'root:@dynamic=md5($u.$p)@5450a2c1af3c92f331d093aa12b5e01c' > test.in 

$ ../run/john -form='dynamic=md5($u.$p)' test.in
No password hashes loaded (see FAQ)

But it refuses to load it, tag or not.

<!-- gh-comment-id:120669298 --> @magnumripper commented on GitHub (Jul 11, 2015): IMO this should work (username "root" password "secret") ``` $ echo -n rootsecret | md5sum 5450a2c1af3c92f331d093aa12b5e01c $ echo root:5450a2c1af3c92f331d093aa12b5e01c > test.in $ ../run/john -form='dynamic=md5($u.$p)' test.in No password hashes loaded (see FAQ) $ echo 'root:@dynamic=md5($u.$p)@5450a2c1af3c92f331d093aa12b5e01c' > test.in $ ../run/john -form='dynamic=md5($u.$p)' test.in No password hashes loaded (see FAQ) ``` But it refuses to load it, tag or not.
Author
Owner

@magnumripper commented on GitHub (Jul 11, 2015):

Also, IMO the .pot entry for such hash should be

@dynamic=md5($p.$u)@5450a2c1af3c92f331d093aa12b5e01c$root:secret

or possibly (for unification)

@dynamic=md5($p.$s)@5450a2c1af3c92f331d093aa12b5e01c$root:secret

(that is, write it as $s to pot file)

<!-- gh-comment-id:120669367 --> @magnumripper commented on GitHub (Jul 11, 2015): Also, IMO the .pot entry for such hash should be ``` @dynamic=md5($p.$u)@5450a2c1af3c92f331d093aa12b5e01c$root:secret ``` or possibly (for unification) ``` @dynamic=md5($p.$s)@5450a2c1af3c92f331d093aa12b5e01c$root:secret ``` (that is, write it as $s to pot file)
Author
Owner

@magnumripper commented on GitHub (Jul 11, 2015):

what does that tag buy you?

OK, I see it may be needed for things like md5($u.md5($p).$s). But the rest of my questions remain.

<!-- gh-comment-id:120673068 --> @magnumripper commented on GitHub (Jul 11, 2015): > what does that tag buy you? OK, I see it may be needed for things like `md5($u.md5($p).$s)`. But the rest of my questions remain.
Author
Owner

@magnumripper commented on GitHub (Jul 11, 2015):

Hmmm looking at some more test vectors it looks like it DOES work they way I always presumed

dynamic_15  11  admin:$dynamic_15$6a2dc4a6637bc5c2488f27faeead8720$123456   thatsworking

So maybe this (refusing load) is just a bug in self-contained dynamic?

<!-- gh-comment-id:120673223 --> @magnumripper commented on GitHub (Jul 11, 2015): Hmmm looking at some more test vectors it looks like it DOES work they way I always presumed ``` dynamic_15 11 admin:$dynamic_15$6a2dc4a6637bc5c2488f27faeead8720$123456 thatsworking ``` So maybe this (refusing load) is just a bug in self-contained dynamic?
Author
Owner

@magnumripper commented on GitHub (Jul 12, 2015):

So maybe this (refusing load) is just a bug in self-contained dynamic?

No, it refuses load in old dynamic too

$ echo -n rootsecret | shasum
18cecd05b9ebfdfd3613fbccc3073a6efd54eb56  -
$ echo root:18cecd05b9ebfdfd3613fbccc3073a6efd54eb56 > test.in

$ ../run/john -form=dynamic_37 test.in
No password hashes loaded (see FAQ)

$ ../run/john --bare-always-valid=Y -form=dynamic_37 test.in
No password hashes loaded (see FAQ)

So trying with tag...

$ echo 'root:$dynamic_37$18cecd05b9ebfdfd3613fbccc3073a6efd54eb56' > test.in
$ ../run/john -form=dynamic_37 test.in
Loaded 1 password hash (dynamic_37 [sha1(lc($u).$p) (SMF) 128/128 AVX 4x1])
Warning: no OpenMP support for this hash type, consider --fork=8
Press 'q' or Ctrl-C to abort, almost any other key for status
secret           (root)
1g 0:00:00:00 DONE 2/3 (2015-07-12 02:02) 100.0g/s 250300p/s 250300c/s 250300C/s 123456..phillips
Use the "--show" option to display all of the cracked passwords reliably
Session completed

Ah, so the bug for "normal" dynamic is we have to use a tag for $u to work?

<!-- gh-comment-id:120673535 --> @magnumripper commented on GitHub (Jul 12, 2015): > So maybe this (refusing load) is just a bug in self-contained dynamic? No, it refuses load in old dynamic too ``` $ echo -n rootsecret | shasum 18cecd05b9ebfdfd3613fbccc3073a6efd54eb56 - $ echo root:18cecd05b9ebfdfd3613fbccc3073a6efd54eb56 > test.in $ ../run/john -form=dynamic_37 test.in No password hashes loaded (see FAQ) $ ../run/john --bare-always-valid=Y -form=dynamic_37 test.in No password hashes loaded (see FAQ) ``` So trying with tag... ``` $ echo 'root:$dynamic_37$18cecd05b9ebfdfd3613fbccc3073a6efd54eb56' > test.in $ ../run/john -form=dynamic_37 test.in Loaded 1 password hash (dynamic_37 [sha1(lc($u).$p) (SMF) 128/128 AVX 4x1]) Warning: no OpenMP support for this hash type, consider --fork=8 Press 'q' or Ctrl-C to abort, almost any other key for status secret (root) 1g 0:00:00:00 DONE 2/3 (2015-07-12 02:02) 100.0g/s 250300p/s 250300c/s 250300C/s 123456..phillips Use the "--show" option to display all of the cracked passwords reliably Session completed ``` Ah, so the bug for "normal" dynamic is we have to use a tag for $u to work?
Author
Owner

@magnumripper commented on GitHub (Jul 12, 2015):

I deleted some of my false hypotheses above. There seem to be two bugs here:

  1. Something forces use of tags for dynamic_37 (possibly this applies to all $u formats?)
  2. Even with a tag, self-contained dynamics can't load $u from login field
<!-- gh-comment-id:120673829 --> @magnumripper commented on GitHub (Jul 12, 2015): I deleted some of my false hypotheses above. There seem to be two bugs here: 1. Something forces use of tags for dynamic_37 (possibly this applies to all $u formats?) 2. Even with a tag, self-contained dynamics can't load $u from login field
Author
Owner

@jfoug commented on GitHub (Jul 12, 2015):

OK, I see it may be needed for things like md5($u.md5($p).$s). But the rest of my questions remain.

That was exactly why $u was done the way it is. It is not the salt, and md5($u.$p) is not the same as md5($s.$p) even though conceptually they seem to be.

Ah, so the bug for "normal" dynamic is we have to use a tag for $u to work?

Probably a bug, not allowing valid to work. I think it should be handled by prepare, but i have NOT looked at $u code for a very long time, and it only semi worked, IIRC. It is one part of dyna that I really wish had NOT been introduced. I thought it good, to allow auto loading from the first field, also to allow up/down casing. But in all, it has not been a good addition.

<!-- gh-comment-id:120677473 --> @jfoug commented on GitHub (Jul 12, 2015): > OK, I see it may be needed for things like md5($u.md5($p).$s). But the rest of my questions remain. That was exactly why $u was done the way it is. It is not the salt, and md5($u.$p) is not the same as md5($s.$p) even though conceptually they seem to be. > Ah, so the bug for "normal" dynamic is we have to use a tag for $u to work? Probably a bug, not allowing valid to work. I think it should be handled by prepare, but i have NOT looked at $u code for a very long time, and it only semi worked, IIRC. It is one part of dyna that I really wish had NOT been introduced. I thought it good, to allow auto loading from the first field, also to allow up/down casing. But in all, it has not been a good addition.
Author
Owner

@jfoug commented on GitHub (Jul 12, 2015):

This fails because this is an unsalted raw hash. I think I can easily 'fix' this, so that if a hash has no salt but does have a $u and there is something provided in field1, then I can prepare it properly

<!-- gh-comment-id:120677988 --> @jfoug commented on GitHub (Jul 12, 2015): This fails because this is an unsalted raw hash. I think I can easily 'fix' this, so that if a hash has no salt but does have a $u and there is something provided in field1, then I can prepare it properly
Author
Owner

@jfoug commented on GitHub (Jul 12, 2015):

the problem is that some validation happens deeper down in dyna, in some shared code. There is no way to pass information to that function about the data in the fields. that function converts the raw hash into a possible dynamic by appending the right dynamic. However, since this format has a $u specified, but the function can not find any $$U signature, then it says there is no way this one can be a dynamic. The fix is a hack, but I am not sure of much better way to do this. It is sort of a one off issue. All other salted 'raw' hashes have to have the salt appendeded properly, so they really are not raw. This one is able to handle it, even though this is sort of contrived.

<!-- gh-comment-id:120683221 --> @jfoug commented on GitHub (Jul 12, 2015): the problem is that some validation happens deeper down in dyna, in some shared code. There is no way to pass information to that function about the data in the fields. that function converts the raw hash into a possible dynamic by appending the right dynamic. However, since this format has a $u specified, but the function can not find any $$U signature, then it says there is no way this one can be a dynamic. The fix is a hack, but I am not sure of much better way to do this. It is sort of a one off issue. All other salted 'raw' hashes have to have the salt appendeded properly, so they really are not raw. This one is able to handle it, even though this is sort of contrived.
Author
Owner

@jfoug commented on GitHub (Jul 12, 2015):

issue left open, ,because I am not 100% sure what you wanted here....

<!-- gh-comment-id:120751749 --> @jfoug commented on GitHub (Jul 12, 2015): issue left open, ,because I am not 100% sure what you wanted here....
Author
Owner

@magnumripper commented on GitHub (Jul 12, 2015):

You did something in e798942 right? I'll test.

<!-- gh-comment-id:120771364 --> @magnumripper commented on GitHub (Jul 12, 2015): You did something in e798942 right? I'll test.
Author
Owner

@magnumripper commented on GitHub (Jul 12, 2015):

Yeah, dynamic_37 works fine now. But self-contained dynamics doesn't. Is that trickier?

<!-- gh-comment-id:120771517 --> @magnumripper commented on GitHub (Jul 12, 2015): Yeah, dynamic_37 works fine now. But self-contained dynamics doesn't. Is that trickier?
Author
Owner

@jfoug commented on GitHub (Jul 12, 2015):

I may need to address that separately. It has it's own prepare, that is much more complex, and behaves differently depending upon if loading .pot file, loading normal file, etc. In .pot mode, it should attempt to use ALL dynamic_x hashes that 'possibly' could be of this type, so that we strip out any cracked values. Same goes for usable 'raw' hashes. The other loading (test strings, input file) also does certain conversions. It should try to convert all raw values (if in raw hash mode), it should 'know' which legacy dyna types that are matches (from a list of what each dyna type 'is', and of course it should load the proper @dyna type.

I simply have not gotten this one fully worked out. The reason why when loading .pot file I want to use ALL dyna types, is that if there are raw hashes on the input (salted or otherwise), then I want to strip out ALL found items I possibly can. So i want to use any 'possible' matching hash that appears like it could be a match, even if for a format that is totally different. We do not use the .pot stuff, we just remove items from our input file based upon what we see in the .pot. That has been one of the thorns in the side of allowing 'raw' hash input. you get 100k input lines, crack 35k of them with a hash, try a different one, and it tests all 100k unless the user is smart enough to remove found candidates himself. I want to make @dyna work as close to searching only 65k input on that next run as possible

However, there is still much more work to do. The hash is only about 75% done.

<!-- gh-comment-id:120772688 --> @jfoug commented on GitHub (Jul 12, 2015): I may need to address that separately. It has it's own prepare, that is much more complex, and behaves differently depending upon if loading .pot file, loading normal file, etc. In .pot mode, it should attempt to use ALL $dynamic_x$ hashes that 'possibly' could be of this type, so that we strip out any cracked values. Same goes for usable 'raw' hashes. The other loading (test strings, input file) also does certain conversions. It should try to convert all raw values (if in raw hash mode), it should 'know' which legacy dyna types that are matches (from a list of what each dyna type 'is', and of course it should load the proper @dyna type. I simply have not gotten this one fully worked out. The reason why when loading .pot file I want to use ALL dyna types, is that if there are raw hashes on the input (salted or otherwise), then I want to strip out ALL found items I possibly can. So i want to use any 'possible' matching hash that appears like it could be a match, even if for a format that is totally different. We do not use the .pot stuff, we just remove items from our input file based upon what we see in the .pot. That has been one of the thorns in the side of allowing 'raw' hash input. you get 100k input lines, crack 35k of them with a hash, try a different one, and it tests all 100k unless the user is smart enough to remove found candidates himself. I want to make @dyna work as close to searching only 65k input on that next run as possible However, there is still much more work to do. The hash is only about 75% done.
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

Here's a fix. Works as a champ but not much tested.

diff --git a/src/dynamic_compiler.c b/src/dynamic_compiler.c
index aa9cc75..ceaf215 100644
--- a/src/dynamic_compiler.c
+++ b/src/dynamic_compiler.c
@@ -143,6 +143,7 @@ DONE #define MGF_BASE_16_OUTPUT_UPCASE    0x00002000
 #include "common.h"
 #include "stdint.h"
 #include "formats.h"
+#include "options.h"
 #include "list.h"
 #include "crc32.h"
 #include "johnswap.h"
@@ -1607,6 +1608,12 @@ char *dynamic_compile_prepare(char *fld0, char *fld1) {
    }
    else if (!strncmp(fld1, "@dynamic=", 9))
        fld1 = dynamic_expr_normalize(fld1);
+   else if (options.format && !strncmp(options.format, "dynamic=", 8) &&
+            strstr(options.format, "$u") &&
+            fld0 && *fld0 && !strstr(fld1, "$$U")) {
+       snprintf(Buf, sizeof(Buf), "%s$$U%s", fld1, fld0);
+       fld1 = Buf;
+   }
    return fld1;
 }
 char *dynamic_compile_split(char *ct) {

So if we gave a format option, and it does contain "dynamic=" (so not auto-format mode, which should never apply to self-contained dynamics anyway) and we have a format containing $u but the hash does not have a $$U field, and we do have a login field to use, we apply it.

<!-- gh-comment-id:121660990 --> @magnumripper commented on GitHub (Jul 15, 2015): Here's a fix. Works as a champ but not much tested. ``` diff diff --git a/src/dynamic_compiler.c b/src/dynamic_compiler.c index aa9cc75..ceaf215 100644 --- a/src/dynamic_compiler.c +++ b/src/dynamic_compiler.c @@ -143,6 +143,7 @@ DONE #define MGF_BASE_16_OUTPUT_UPCASE 0x00002000 #include "common.h" #include "stdint.h" #include "formats.h" +#include "options.h" #include "list.h" #include "crc32.h" #include "johnswap.h" @@ -1607,6 +1608,12 @@ char *dynamic_compile_prepare(char *fld0, char *fld1) { } else if (!strncmp(fld1, "@dynamic=", 9)) fld1 = dynamic_expr_normalize(fld1); + else if (options.format && !strncmp(options.format, "dynamic=", 8) && + strstr(options.format, "$u") && + fld0 && *fld0 && !strstr(fld1, "$$U")) { + snprintf(Buf, sizeof(Buf), "%s$$U%s", fld1, fld0); + fld1 = Buf; + } return fld1; } char *dynamic_compile_split(char *ct) { ``` So if we gave a format option, and it does contain "dynamic=" (so not auto-format mode, which should never apply to self-contained dynamics anyway) and we have a format containing $u but the hash does not have a $$U field, and we do have a login field to use, we apply it.
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

Oh, and that patch breaks dynacomptest. I think dynacomptest shouldn't be built by default anyway, isn't that a debug tool of yours? Just drop it from JOHN_PROJ and you can still build it with make dynacomptest (after fixing the options.o linkage)

<!-- gh-comment-id:121661448 --> @magnumripper commented on GitHub (Jul 15, 2015): Oh, and that patch breaks dynacomptest. I think dynacomptest shouldn't be built by default anyway, isn't that a debug tool of yours? Just drop it from JOHN_PROJ and you can still build it with `make dynacomptest` (after fixing the options.o linkage)
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

So if we gave a format option, and it does contain "dynamic=" (so not auto-format mode, which should never apply to self-contained dynamics anyway)

BTW shouldn't we have this further up instead?

diff --git a/src/dynamic_compiler_fmt_plug.c b/src/dynamic_compiler_fmt_plug.c
index bb682e4..f359071 100644
--- a/src/dynamic_compiler_fmt_plug.c
+++ b/src/dynamic_compiler_fmt_plug.c
@@ -31,6 +31,7 @@ john_register_one(&fmt_CompiledDynamic);

 #include "common.h"
 #include "formats.h"
+#include "options.h"
 #include "dynamic.h"
 #include "dynamic_compiler.h"
 #include "dynamic_types.h"
@@ -97,10 +98,14 @@ static char *our_split(char *ciphertext, int index, struct fmt_main *self)
    ciphertext = dynamic_compile_split(ciphertext);
    return ciphertext;
 }
+
 static char *our_prepare(char **fields, struct fmt_main *self)
 {
-   char *ciphertext = dynamic_compile_prepare(fields[0], fields[1]);
-   return ciphertext;
+   if (options.format && !strncmp(options.format, "dynamic=", 8)) {
+       char *ciphertext = dynamic_compile_prepare(fields[0], fields[1]);
+       return ciphertext;
+   } else
+       return fields[1];
 }

 static int our_valid(char *ciphertext, struct fmt_main *self)

That would make the patch to dynamic_compiler.c not needing options.h so linkage problems for dynacomptest would go away:

diff --git a/src/dynamic_compiler.c b/src/dynamic_compiler.c
index aa9cc75..1921746 100644
--- a/src/dynamic_compiler.c
+++ b/src/dynamic_compiler.c
@@ -1607,6 +1607,11 @@ char *dynamic_compile_prepare(char *fld0, char *fld1) {
    }
    else if (!strncmp(fld1, "@dynamic=", 9))
        fld1 = dynamic_expr_normalize(fld1);
+   else if (strstr(options.format, "$u") &&
+            fld0 && *fld0 && !strstr(fld1, "$$U")) {
+       snprintf(Buf, sizeof(Buf), "%s$$U%s", fld1, fld0);
+       fld1 = Buf;
+   }
    return fld1;
 }
 char *dynamic_compile_split(char *ct) {
<!-- gh-comment-id:121667755 --> @magnumripper commented on GitHub (Jul 15, 2015): > So if we gave a format option, and it does contain "dynamic=" (so not auto-format mode, which should never apply to self-contained dynamics anyway) BTW shouldn't we have this further up instead? ``` diff diff --git a/src/dynamic_compiler_fmt_plug.c b/src/dynamic_compiler_fmt_plug.c index bb682e4..f359071 100644 --- a/src/dynamic_compiler_fmt_plug.c +++ b/src/dynamic_compiler_fmt_plug.c @@ -31,6 +31,7 @@ john_register_one(&fmt_CompiledDynamic); #include "common.h" #include "formats.h" +#include "options.h" #include "dynamic.h" #include "dynamic_compiler.h" #include "dynamic_types.h" @@ -97,10 +98,14 @@ static char *our_split(char *ciphertext, int index, struct fmt_main *self) ciphertext = dynamic_compile_split(ciphertext); return ciphertext; } + static char *our_prepare(char **fields, struct fmt_main *self) { - char *ciphertext = dynamic_compile_prepare(fields[0], fields[1]); - return ciphertext; + if (options.format && !strncmp(options.format, "dynamic=", 8)) { + char *ciphertext = dynamic_compile_prepare(fields[0], fields[1]); + return ciphertext; + } else + return fields[1]; } static int our_valid(char *ciphertext, struct fmt_main *self) ``` That would make the patch to dynamic_compiler.c not needing options.h so linkage problems for dynacomptest would go away: ``` diff diff --git a/src/dynamic_compiler.c b/src/dynamic_compiler.c index aa9cc75..1921746 100644 --- a/src/dynamic_compiler.c +++ b/src/dynamic_compiler.c @@ -1607,6 +1607,11 @@ char *dynamic_compile_prepare(char *fld0, char *fld1) { } else if (!strncmp(fld1, "@dynamic=", 9)) fld1 = dynamic_expr_normalize(fld1); + else if (strstr(options.format, "$u") && + fld0 && *fld0 && !strstr(fld1, "$$U")) { + snprintf(Buf, sizeof(Buf), "%s$$U%s", fld1, fld0); + fld1 = Buf; + } return fld1; } char *dynamic_compile_split(char *ct) { ```
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

No, strstr(options.format, "$u") still needs options.h

<!-- gh-comment-id:121667974 --> @magnumripper commented on GitHub (Jul 15, 2015): No, `strstr(options.format, "$u")` still needs options.h
Author
Owner

@jfoug commented on GitHub (Jul 15, 2015):

I think dynacomptest shouldn't be built by default anyway,

The nice thing about dynacomptest is 'ability' to dump out the script easily, which helps someone see how to script in dyna. HOWEVER, the same can be done with john, using the ,debug appended to the expression. so ../run/john -test=0 -format='md5($s.$u),debug' does the same function. So yes, that tool 'could' be removed from default build.

<!-- gh-comment-id:121670368 --> @jfoug commented on GitHub (Jul 15, 2015): > I think dynacomptest shouldn't be built by default anyway, The nice thing about dynacomptest is 'ability' to dump out the script easily, which helps someone see how to script in dyna. HOWEVER, the same can be done with john, using the ,debug appended to the expression. so `../run/john -test=0 -format='md5($s.$u),debug'` does the same function. So yes, that tool 'could' be removed from default build.
Author
Owner

@jfoug commented on GitHub (Jul 15, 2015):

No, strstr(options.format, "$u") still needs options.h

Still easy to get around, by putting a global in dynamic_compiler.c, and setting that global from dynanmic_compiler_fmt_plug.c.

<!-- gh-comment-id:121671751 --> @jfoug commented on GitHub (Jul 15, 2015): > No, strstr(options.format, "$u") still needs options.h Still easy to get around, by putting a global in dynamic_compiler.c, and setting that global from dynanmic_compiler_fmt_plug.c.
Author
Owner

@jfoug commented on GitHub (Jul 15, 2015):

NOTE, I am still looking for a better way to do this, than always 'forcing' the -format method.

I would like to have JtR be smart enough to handle a file with fully qualified dyna_compiler hashes without providing any forced --format= string.

The problem is these formats are LATE created. They do not exist until 'something' provides the expression to JtR. That makes installing them into the format chain as something HARD to do. Also, we are back to using a 'thick' format, where 1 format handles all of them (like we initially had with dynamic, before I split them out into independent format structures. The thick (1 format structure) method was NOT easy, it held all sorts of caveats that I would like to NOT have to address again.

<!-- gh-comment-id:121673030 --> @jfoug commented on GitHub (Jul 15, 2015): NOTE, I am still looking for a better way to do this, than always 'forcing' the -format method. I would like to have JtR be smart enough to handle a file with fully qualified dyna_compiler hashes without providing any forced --format= string. The problem is these formats are LATE created. They do not exist until 'something' provides the expression to JtR. That makes installing them into the format chain as something HARD to do. Also, we are back to using a 'thick' format, where 1 format handles all of them (like we initially had with dynamic, before I split them out into independent format structures. The thick (1 format structure) method was NOT easy, it held all sorts of caveats that I would like to NOT have to address again.
Author
Owner

@jfoug commented on GitHub (Jul 15, 2015):

Im gonna check in the code. I really like it done this way. This is somewhat of an 'obscure' bug, BUT this certainly gets it working in dyna-compiler code.

<!-- gh-comment-id:121680006 --> @jfoug commented on GitHub (Jul 15, 2015): Im gonna check in the code. I really like it done this way. This is somewhat of an 'obscure' bug, BUT this certainly gets it working in dyna-compiler code.
Author
Owner

@jfoug commented on GitHub (Jul 15, 2015):

Works slick. After the change (I have another change coming, but the last checkin is 100% valid)

$ cat in
JxoDbE6K:e2931cfe951b54b7d375c3ff3525e895
$ ../run/john in -form='dynamic=md5($u.$p)'
Using default input encoding: UTF-8
Loaded 1 password hash (dynamic=md5($u.$p) [128/128 AVX 4x3])
Warning: no OpenMP support for this hash type, consider --fork=8
Press 'q' or Ctrl-C to abort, almost any other key for status
test             (JxoDbE6K)
1g 0:00:00:00 DONE 2/3 (2015-07-15 12:17) 76.92g/s 184642p/s 198846c/s 184642C/s 123456..phillips
Use the "--show" option to display all of the cracked passwords reliably
Session completed

$ cat ../run/john.pot
e2931cfe951b54b7d375c3ff3525e895$$UJxoDbE6K:test

$ ../run/john in -form='dynamic=md5($u.$p)'
Using default input encoding: UTF-8
Loaded 1 password hash (dynamic=md5($u.$p) [128/128 AVX 4x3])
No password hashes left to crack (see FAQ)
<!-- gh-comment-id:121684368 --> @jfoug commented on GitHub (Jul 15, 2015): Works slick. After the change (I have another change coming, but the last checkin is 100% valid) ``` $ cat in JxoDbE6K:e2931cfe951b54b7d375c3ff3525e895 $ ../run/john in -form='dynamic=md5($u.$p)' Using default input encoding: UTF-8 Loaded 1 password hash (dynamic=md5($u.$p) [128/128 AVX 4x3]) Warning: no OpenMP support for this hash type, consider --fork=8 Press 'q' or Ctrl-C to abort, almost any other key for status test (JxoDbE6K) 1g 0:00:00:00 DONE 2/3 (2015-07-15 12:17) 76.92g/s 184642p/s 198846c/s 184642C/s 123456..phillips Use the "--show" option to display all of the cracked passwords reliably Session completed $ cat ../run/john.pot e2931cfe951b54b7d375c3ff3525e895$$UJxoDbE6K:test $ ../run/john in -form='dynamic=md5($u.$p)' Using default input encoding: UTF-8 Loaded 1 password hash (dynamic=md5($u.$p) [128/128 AVX 4x3]) No password hashes left to crack (see FAQ) ```
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

CRLF issues fixed in 157547e and more importantly, a tag is added.

$ echo root:5450a2c1af3c92f331d093aa12b5e01c > test.in

$ ../run/john test.in -form='dynamic=md5($u.$p)' 
Loaded 1 password hash (dynamic=md5($u.$p) [128/128 AVX 4x3])
Press 'q' or Ctrl-C to abort, almost any other key for status
secret           (root)
1g 0:00:00:00 DONE 2/3 (2015-07-15 20:26) 100.0g/s 250300p/s 250300c/s 250300C/s 123456..phillips
Use the "--show" option to display all of the cracked passwords reliably
Session completed

$ cat ../run/john.pot 
@dynamic=md5($u.$p)@5450a2c1af3c92f331d093aa12b5e01c$$Uroot:secret

$ ../run/john test.in -form='dynamic=md5($u.$p)' -show
root:secret

1 password hash cracked, 0 left
<!-- gh-comment-id:121704841 --> @magnumripper commented on GitHub (Jul 15, 2015): CRLF issues fixed in 157547e and more importantly, a tag is added. ``` $ echo root:5450a2c1af3c92f331d093aa12b5e01c > test.in $ ../run/john test.in -form='dynamic=md5($u.$p)' Loaded 1 password hash (dynamic=md5($u.$p) [128/128 AVX 4x3]) Press 'q' or Ctrl-C to abort, almost any other key for status secret (root) 1g 0:00:00:00 DONE 2/3 (2015-07-15 20:26) 100.0g/s 250300p/s 250300c/s 250300C/s 123456..phillips Use the "--show" option to display all of the cracked passwords reliably Session completed $ cat ../run/john.pot @dynamic=md5($u.$p)@5450a2c1af3c92f331d093aa12b5e01c$$Uroot:secret $ ../run/john test.in -form='dynamic=md5($u.$p)' -show root:secret 1 password hash cracked, 0 left ```
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

I would like to have JtR be smart enough to handle a file with fully qualified dyna_compiler hashes without providing any forced --format= string.

You mean this?

$ echo '@dynamic=md5($u.$p)@5450a2c1af3c92f331d093aa12b5e01c$$Uroot' > test.in

$ ../run/john test.in 
No password hashes loaded (see FAQ)

$ ../run/john test.in --bare-always-valid=y
No password hashes loaded (see FAQ)

I guess that would be nice but I personally don't consider it important at all. Tags are primarily for pot files, not input files. Ultimately the pot file should be considered an opaque database.

<!-- gh-comment-id:121706705 --> @magnumripper commented on GitHub (Jul 15, 2015): > I would like to have JtR be smart enough to handle a file with fully qualified dyna_compiler hashes without providing any forced --format= string. You mean this? ``` $ echo '@dynamic=md5($u.$p)@5450a2c1af3c92f331d093aa12b5e01c$$Uroot' > test.in $ ../run/john test.in No password hashes loaded (see FAQ) $ ../run/john test.in --bare-always-valid=y No password hashes loaded (see FAQ) ``` I guess that would be nice but I personally don't consider it important at all. Tags are primarily for pot files, not input files. Ultimately the pot file should be considered an opaque database.
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

I would like to have JtR be smart enough to handle a file with fully qualified dyna_compiler hashes without providing any forced --format= string.

Apparently this is also important when using -show while not specifying format (it's not the exact same thing but very close). So yes, we should fix it.

$ echo root:5450a2c1af3c92f331d093aa12b5e01c > test.in

$ ../run/john test.in -form='dynamic=md5($u.$p)' 
Loaded 1 password hash (dynamic=md5($u.$p) [128/128 AVX 4x3])
Press 'q' or Ctrl-C to abort, almost any other key for status
secret           (root)
1g 0:00:00:00 DONE 2/3 (2015-07-15 20:39) 100.0g/s 250300p/s 250300c/s 250300C/s 123456..phillips
Use the "--show" option to display all of the cracked passwords reliably
Session completed

$ ../run/john test.in -show
0 password hashes cracked, 2 left

(It says 2 left because it considers them LM halves)

In the case above, we have unqualified raw hashes that matches fully qualified .pot entries. We'd need to detect that, read the format from the tag, and handle it.

<!-- gh-comment-id:121709910 --> @magnumripper commented on GitHub (Jul 15, 2015): > I would like to have JtR be smart enough to handle a file with fully qualified dyna_compiler hashes without providing any forced --format= string. Apparently this is also important when using -show while not specifying format (it's not the exact same thing but very close). So yes, we should fix it. ``` $ echo root:5450a2c1af3c92f331d093aa12b5e01c > test.in $ ../run/john test.in -form='dynamic=md5($u.$p)' Loaded 1 password hash (dynamic=md5($u.$p) [128/128 AVX 4x3]) Press 'q' or Ctrl-C to abort, almost any other key for status secret (root) 1g 0:00:00:00 DONE 2/3 (2015-07-15 20:39) 100.0g/s 250300p/s 250300c/s 250300C/s 123456..phillips Use the "--show" option to display all of the cracked passwords reliably Session completed $ ../run/john test.in -show 0 password hashes cracked, 2 left ``` (It says 2 left because it considers them LM halves) In the case above, we have unqualified raw hashes that matches fully qualified .pot entries. We'd need to detect that, read the format from the tag, and handle it.
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

Hmm after 157547e we add a tag to bare hashes when using $u but not otherwise. We should always do that - it should happen in dynamic_expr_normalize() instead, don't you think?

<!-- gh-comment-id:121718677 --> @magnumripper commented on GitHub (Jul 15, 2015): Hmm after 157547e we add a tag to bare hashes when using $u but not otherwise. We should always do that - it should happen in dynamic_expr_normalize() instead, don't you think?
Author
Owner

@magnumripper commented on GitHub (Jul 15, 2015):

Note that when reading pot lines, prepare is never called. This makes it even trickier to get -show working with an untagged input file.

<!-- gh-comment-id:121768414 --> @magnumripper commented on GitHub (Jul 15, 2015): Note that when reading pot lines, prepare is never called. This makes it even trickier to get -show working with an untagged input file.
Author
Owner

@jfoug commented on GitHub (Jul 16, 2015):

No, still pretty easy stuff. Both split and prepare have a 'common' function in the compiler (and stubs in the format). I had origially NOT wanted to make changes, and I still think it should ONLY make changes for raw hashes. If the hash is dynamic_25, then it should be left as dynamic_25 even though the compiler was used to handle it. Same if it is PHPS format. Leave it alone, but handle it with md5($s.$p) if that is the right expression. But a raw hash, yes it should get a tag when found and when put into the DB.

But yes, I would 'like' to be able to handle an input file with this in it, without having to do a -format= statement.

echo '@dynamic=md5($u.$p)@5450a2c1af3c92f331d093aa12b5e01c$$Uroot' > test.in
<!-- gh-comment-id:121790143 --> @jfoug commented on GitHub (Jul 16, 2015): No, still pretty easy stuff. Both split and prepare have a 'common' function in the compiler (and stubs in the format). I had origially NOT wanted to make changes, and I still think it should ONLY make changes for raw hashes. If the hash is dynamic_25, then it should be left as dynamic_25 even though the compiler was used to handle it. Same if it is PHPS format. Leave it alone, but handle it with md5($s.$p) if that is the right expression. But a raw hash, yes it should get a tag when found and when put into the DB. But yes, I would 'like' to be able to handle an input file with this in it, without having to do a -format= statement. ``` echo '@dynamic=md5($u.$p)@5450a2c1af3c92f331d093aa12b5e01c$$Uroot' > test.in ```
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#1006
No description provided.