[GH-ISSUE #1748] Dynamic ad-hoc format: AM "complex" does not work #1158

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

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

Originally assigned to: @jfoug on GitHub.

$ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.lc($s).$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73@^bhhs&#@&^@8@*$'
Unknown ciphertext format name requested

I think I write it correctly. Why is it not recognized at all?

Originally created by @magnumripper on GitHub (Sep 11, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1748 Originally assigned to: @jfoug on GitHub. ``` $ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.lc($s).$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73@^bhhs&#@&^@8@*$' Unknown ciphertext format name requested ``` I think I write it correctly. Why is it not recognized at all?
bsakaguchi 2026-10-14 03:37:10 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Tried hexifying @ and $, no difference

$ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.lc($s).$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs&#\x40&^\x408\x40*\x24'
Unknown ciphertext format name requested
<!-- gh-comment-id:139564324 --> @magnumripper commented on GitHub (Sep 11, 2015): Tried hexifying @ and $, no difference ``` $ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.lc($s).$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs&#\x40&^\x408\x40*\x24' Unknown ciphertext format name requested ```
Author
Owner

@frank-dittrich commented on GitHub (Sep 11, 2015):

Trying to reduce that:

$ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.lc($s).$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73'
ERROR in dyna-parser. Have salt_as_hex_type set, but do not KNOW this type of hash
<!-- gh-comment-id:139565632 --> @frank-dittrich commented on GitHub (Sep 11, 2015): Trying to reduce that: ``` $ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.lc($s).$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73' ERROR in dyna-parser. Have salt_as_hex_type set, but do not KNOW this type of hash ```
Author
Owner

@frank-dittrich commented on GitHub (Sep 11, 2015):

$ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.lc($s).$c3),c1=\x3a\x3a,c2=\x3a,c3=a,debug'
push
app_u_lc
.
app_1
.
app_p_lc
.
app_2
.
app_sh
.
app_3
f5h
ERROR in dyna-parser. Have salt_as_hex_type set, but do not KNOW this type of hash
<!-- gh-comment-id:139566104 --> @frank-dittrich commented on GitHub (Sep 11, 2015): ``` $ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.lc($s).$c3),c1=\x3a\x3a,c2=\x3a,c3=a,debug' push app_u_lc . app_1 . app_p_lc . app_2 . app_sh . app_3 f5h ERROR in dyna-parser. Have salt_as_hex_type set, but do not KNOW this type of hash ```
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

This should not have salt_as_hex set. lc($s) is not a hashing function.

I think the parser is failing. It must be using 'any' function as a salt_as hex, when parsing. It should ONLY do that for a hashing type. The uc/lc are not really functions. They just use function-like syntax

<!-- gh-comment-id:139583246 --> @jfoug commented on GitHub (Sep 11, 2015): This should not have salt_as_hex set. lc($s) is not a hashing function. I think the parser is failing. It must be using 'any' function as a salt_as hex, when parsing. It should ONLY do that for a hashing type. The uc/lc are not really functions. They just use function-like syntax
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

& has to be encoded (even in '...' the shell wants to start background processes)
* 'may' have to be.

<!-- gh-comment-id:139652388 --> @jfoug commented on GitHub (Sep 11, 2015): & has to be encoded (even in '...' the shell wants to start background processes) `*` 'may' have to be.
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

$ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16,debug'
push
app_u_lc
.
app_1
.
app_p_lc
.
app_2
.
app_sh
.
app_3
f5h

crc32 = 396C64FD
pExpr=md5(lc($u).$c1.lc($p).$c2.$s.$c3)
extraParams=,c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16,debug
signature=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16,debug@
line1=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@811c5755f866441acdb35728c21ae2af$df694488$$U87ffb1c9
line2=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@4a4f7cc851d6914842312e3efb0fc85f$a69c5744$$U4f58497b
line3=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@611e2cb6f91efec854ee95c2b2eed3bd$e0b88e64$$U35644f9d

##############################################################
#  Dynamic script for expression md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16,debug
##############################################################
Expression=dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)
#  Flags for this format
Flag=MGF_FLAT_BUFFERS
Flag=MGF_SALTED
Flag=MGF_PASSWORD_LOCASE
Flag=MGF_USERNAME_LOCASE
#  Lengths used in this format
SaltLen=-16
MaxInputLenX86=110
MaxInputLen=110
#  The functions in the script
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_userid
Func=DynamicFunc__append_input1_from_CONST1
Func=DynamicFunc__append_keys
Func=DynamicFunc__append_input1_from_CONST2
Func=DynamicFunc__append_salt
Func=DynamicFunc__append_input1_from_CONST3
Func=DynamicFunc__MD5_crypt_input1_to_output1_FINAL
#  Constants used by this format
Const1=\x3a\x3a
Const2=\x3a
Const3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24
#  The test hashes that validate this script
Test=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@811c5755f866441acdb35728c21ae2af$df694488$$U87ffb1c9:abc
Test=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@4a4f7cc851d6914842312e3efb0fc85f$a69c5744$$U4f58497b:john
Test=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@611e2cb6f91efec854ee95c2b2eed3bd$e0b88e64$$U35644f9d:passweird
$ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16'
Benchmarking: dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3) [128/128 AVX 4x3]... DONE
Many salts:     7107K c/s real, 7111K c/s virtual
Only one salt:  4960K c/s real, 4956K c/s virtual

I have to 'fix' the compiler to not treat lc($s) as a salt_as_hex type. For the above test, I removed the lc($s) and just use $s. Other than missing a dyna startup flag, the above format 'would' work. And if all the salts were already lower case in the input data, then this 'would' work.

<!-- gh-comment-id:139652892 --> @jfoug commented on GitHub (Sep 11, 2015): ``` $ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16,debug' push app_u_lc . app_1 . app_p_lc . app_2 . app_sh . app_3 f5h crc32 = 396C64FD pExpr=md5(lc($u).$c1.lc($p).$c2.$s.$c3) extraParams=,c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16,debug signature=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16,debug@ line1=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@811c5755f866441acdb35728c21ae2af$df694488$$U87ffb1c9 line2=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@4a4f7cc851d6914842312e3efb0fc85f$a69c5744$$U4f58497b line3=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@611e2cb6f91efec854ee95c2b2eed3bd$e0b88e64$$U35644f9d ############################################################## # Dynamic script for expression md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16,debug ############################################################## Expression=dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3) # Flags for this format Flag=MGF_FLAT_BUFFERS Flag=MGF_SALTED Flag=MGF_PASSWORD_LOCASE Flag=MGF_USERNAME_LOCASE # Lengths used in this format SaltLen=-16 MaxInputLenX86=110 MaxInputLen=110 # The functions in the script Func=DynamicFunc__clean_input_kwik Func=DynamicFunc__append_userid Func=DynamicFunc__append_input1_from_CONST1 Func=DynamicFunc__append_keys Func=DynamicFunc__append_input1_from_CONST2 Func=DynamicFunc__append_salt Func=DynamicFunc__append_input1_from_CONST3 Func=DynamicFunc__MD5_crypt_input1_to_output1_FINAL # Constants used by this format Const1=\x3a\x3a Const2=\x3a Const3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24 # The test hashes that validate this script Test=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@811c5755f866441acdb35728c21ae2af$df694488$$U87ffb1c9:abc Test=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@4a4f7cc851d6914842312e3efb0fc85f$a69c5744$$U4f58497b:john Test=@dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3)@611e2cb6f91efec854ee95c2b2eed3bd$e0b88e64$$U35644f9d:passweird ``` ``` $ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs\x26#\x40\x26^\x408\x40\x2a\x24,saltlen=-16' Benchmarking: dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3) [128/128 AVX 4x3]... DONE Many salts: 7107K c/s real, 7111K c/s virtual Only one salt: 4960K c/s real, 4956K c/s virtual ``` I have to 'fix' the compiler to not treat lc($s) as a salt_as_hex type. For the above test, I removed the lc($s) and just use $s. Other than missing a dyna startup flag, the above format 'would' work. And if all the salts were already lower case in the input data, then this 'would' work.
Author
Owner

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

& has to be encoded (even in '...' the shell wants to start background processes)
* 'may' have to be.

I can't see why any of them would have to be escaped. We are inside single quotes already so the shell is not involved at all - all problems here are the format's problems.

I can buy that @ and : need escaping since both have meanings to JtR.

<!-- gh-comment-id:139678296 --> @magnumripper commented on GitHub (Sep 11, 2015): > & has to be encoded (even in '...' the shell wants to start background processes) > `*` 'may' have to be. I can't see why any of them would have to be escaped. We are inside single quotes already so the shell is not involved at all - **all** problems here are the format's problems. I can buy that `@` and `:` need escaping since both have meanings to JtR.
Author
Owner

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

It was the *, not the &. I would like to know why * needs escaping. It's not used in dynamic, is it?

<!-- gh-comment-id:139679051 --> @magnumripper commented on GitHub (Sep 11, 2015): It was the `*`, not the `&`. I would like to know why `*` needs escaping. It's not used in dynamic, is it?
Author
Owner

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

OK, here's why. Might even be my fault 😝

$ git grep -C1 '"\*"'
(...)
john.c- if (options.format) {
john.c:         char *pos = strchr(options.format, '*');
john.c-
(...)
dynamic_fmt.c-
dynamic_fmt.c:  if (options.format && strstr(options.format, "*"))
dynamic_fmt.c-          wildcard = 1;
<!-- gh-comment-id:139679553 --> @magnumripper commented on GitHub (Sep 11, 2015): OK, here's why. Might even be my fault :stuck_out_tongue_closed_eyes: ``` $ git grep -C1 '"\*"' (...) john.c- if (options.format) { john.c: char *pos = strchr(options.format, '*'); john.c- (...) dynamic_fmt.c- dynamic_fmt.c: if (options.format && strstr(options.format, "*")) dynamic_fmt.c- wildcard = 1; ```
Author
Owner

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

This addresses the problem

diff --git a/src/dynamic_compiler.c b/src/dynamic_compiler.c
index 47b6fa8..cfe5f23 100644
--- a/src/dynamic_compiler.c
+++ b/src/dynamic_compiler.c
@@ -1040,9 +1040,11 @@ static char *comp_optimize_expression(const char *pExpr) {
                }
                if (n1 == n2) {
                        // ok, all were same hash type.  Now make sure all $s are in crypt($s)
+                       // Ignore lc() and uc() */
                        n2 = 0;
                        p = strstr(pBuf, "$s");
-                       while (p) {
+                       while (p && (p[-1] != '(' || p[-2] != 'c' ||
+                                    (p[-3] != 'l' && p[-3] != 'u'))) {
                                ++n2;
                                p = strstr(&p[1], cpType);
                        }

But it ends up with an other problem

Dyna expression syntax error around this part of expression
md5(lc($u).$c1.lc($p).$c2.lc($s).$c3)
                          ^
Invalid token following the . character
<!-- gh-comment-id:139686857 --> @magnumripper commented on GitHub (Sep 11, 2015): This addresses the problem ``` diff diff --git a/src/dynamic_compiler.c b/src/dynamic_compiler.c index 47b6fa8..cfe5f23 100644 --- a/src/dynamic_compiler.c +++ b/src/dynamic_compiler.c @@ -1040,9 +1040,11 @@ static char *comp_optimize_expression(const char *pExpr) { } if (n1 == n2) { // ok, all were same hash type. Now make sure all $s are in crypt($s) + // Ignore lc() and uc() */ n2 = 0; p = strstr(pBuf, "$s"); - while (p) { + while (p && (p[-1] != '(' || p[-2] != 'c' || + (p[-3] != 'l' && p[-3] != 'u'))) { ++n2; p = strstr(&p[1], cpType); } ``` But it ends up with an other problem ``` Dyna expression syntax error around this part of expression md5(lc($u).$c1.lc($p).$c2.lc($s).$c3) ^ Invalid token following the . character ```
Author
Owner

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

OK... lc($s) is simply not supported yet while lc($u) and lc($p) are. So I think my patch above is correct, but we'd also need to actually support lc($s).

<!-- gh-comment-id:139687169 --> @magnumripper commented on GitHub (Sep 11, 2015): OK... `lc($s)` is simply not supported yet while `lc($u)` and `lc($p)` are. So I think my patch above is correct, but we'd also need to actually support `lc($s)`.
Author
Owner

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

We don't even have MGF_SALT_LOCASE or MGF_SALT_UPCASE.

<!-- gh-comment-id:139687983 --> @magnumripper commented on GitHub (Sep 11, 2015): We don't even have MGF_SALT_LOCASE or MGF_SALT_UPCASE.
Author
Owner

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

I'll admit it's not very relevant to support lc($s) or uc($s) even though it'd be nice in this case. The easy solution is to prepare the input file correctly.

<!-- gh-comment-id:139688975 --> @magnumripper commented on GitHub (Sep 11, 2015): I'll admit it's not very relevant to support `lc($s)` or `uc($s)` even though it'd be nice in this case. The easy solution is to prepare the input file correctly.
Author
Owner

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

I will actually commit the patch above. It's relevant for getting the proper error, and if we'll support case-correcting $s in the future, it still stands.

Other than that, this issue is more or less PEBCAK.

<!-- gh-comment-id:139689487 --> @magnumripper commented on GitHub (Sep 11, 2015): I will actually commit the patch above. It's relevant for getting the proper error, and if we'll support case-correcting `$s` in the future, it still stands. Other than that, this issue is more or less PEBCAK.
Author
Owner

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

So @jfoug I'll let you decide: Either close this now, or implement lc/uc for salt.

Oh, and we should document which characters need escaping.

<!-- gh-comment-id:139689763 --> @magnumripper commented on GitHub (Sep 11, 2015): So @jfoug I'll let you decide: Either close this now, or implement lc/uc for salt. Oh, and we should document which characters need escaping.
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

this 'fixes' the lc($s) not parsing, but there are only 2 valid uc/lc situations. That is user name and pass.

Remind me why casing of the salt is needed? Can't it just be properly built in the first place??

<!-- gh-comment-id:139689901 --> @jfoug commented on GitHub (Sep 11, 2015): this 'fixes' the lc($s) not parsing, but there are only 2 valid uc/lc situations. That is user name and pass. Remind me why casing of the salt is needed? Can't it just be properly built in the first place??
Author
Owner

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

Yeah, sure. I just wrote it as lc($s) from a writeup about AM hashes. The solution is preparing the input.

I'm fine with this issue being closed now that we get the proper error.

<!-- gh-comment-id:139690011 --> @magnumripper commented on GitHub (Sep 12, 2015): Yeah, sure. I just wrote it as `lc($s)` from a writeup about AM hashes. The solution is preparing the input. I'm fine with this issue being closed now that we get the proper error.
Author
Owner

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

it's not an error if you are not 'trying' to support lc($s), but since lc() will parse (as will any expression.

wow. I just thought of something, do not submit that yet

<!-- gh-comment-id:139690080 --> @jfoug commented on GitHub (Sep 12, 2015): it's not an error if you are not 'trying' to support lc($s), but since lc() will parse (as will any expression. wow. I just thought of something, do not submit that yet
Author
Owner

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

I already committed that SALT_AS_HEX parsing fix.

<!-- gh-comment-id:139690163 --> @magnumripper commented on GitHub (Sep 12, 2015): I already committed that SALT_AS_HEX parsing fix.
Author
Owner

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

We have to whitelist what is allowed, not black list. Take this point

md5($p.fuckoff($s))

I think that will parse properly, because the optimizer will turn it into md5($p.$s), and set the 'this hash uses salt-as-hex' flag

<!-- gh-comment-id:139690177 --> @jfoug commented on GitHub (Sep 12, 2015): We have to whitelist what is allowed, not black list. Take this point md5($p.fuckoff($s)) I think that will parse properly, because the optimizer will turn it into md5($p.$s), and set the 'this hash uses salt-as-hex' flag
Author
Owner

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

LOL so fuckoff() is a no-op

<!-- gh-comment-id:139690243 --> @magnumripper commented on GitHub (Sep 12, 2015): LOL so fuckoff() is a no-op
Author
Owner

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

:) But then it will fail to find FUCKOFF_SALT_AS_HEX flag when later trying to emit the flag

<!-- gh-comment-id:139690282 --> @jfoug commented on GitHub (Sep 12, 2015): :) But then it will fail to find FUCKOFF_SALT_AS_HEX flag when later trying to emit the flag
Author
Owner

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

I'm laughing so much my wife will wake up. We definitely should have a FUCKOFF_SALT_AS_HEX flag just for the hell of it.

<!-- gh-comment-id:139690429 --> @magnumripper commented on GitHub (Sep 12, 2015): I'm laughing so much my wife will wake up. We definitely should have a FUCKOFF_SALT_AS_HEX flag just for the hell of it.
Author
Owner

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

what I am saying is that the optimizer will have to white list (that sucks, because now I have to edit that WL every time I add a crypt type. So it will ONLY work for md5($s), or sha1($s) and anything else, it leaves alone, so that the original text is in there, and the parser will have context on what 'bad' part of the expressino was seen

<!-- gh-comment-id:139690438 --> @jfoug commented on GitHub (Sep 12, 2015): what I am saying is that the optimizer will have to white list (that sucks, because now I have to edit that WL every time I add a crypt type. So it will ONLY work for md5($s), or sha1($s) and anything else, it leaves alone, so that the original text is in there, and the parser will have context on what 'bad' part of the expressino was seen
Author
Owner

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

Yes I see what you mean. Unless you can find a nice way with that CPP magic stuff.

<!-- gh-comment-id:139690519 --> @magnumripper commented on GitHub (Sep 12, 2015): Yes I see what you mean. Unless you can find a nice way with that CPP magic stuff.
Author
Owner

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

it will be with cpp magic, but it is just another edit point, no different than the rest. I just put a magic signature, then search for that, and wherever it is found, I figure out what needs to be there, and add it. At least I am not writing code into each of the 30 or so edit points.

<!-- gh-comment-id:139690679 --> @jfoug commented on GitHub (Sep 12, 2015): it will be with cpp magic, but it is just another edit point, no different than the rest. I just put a magic signature, then search for that, and wherever it is found, I figure out what needs to be there, and add it. At least I am not writing code into each of the 30 or so edit points.
Author
Owner

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

But this all can wait now. We should fix #1746 but I'm lost there.

<!-- gh-comment-id:139690712 --> @magnumripper commented on GitHub (Sep 12, 2015): But this all can wait now. We should fix #1746 but I'm lost there.
Author
Owner

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

it will be a macro that does something like:

CHK(A,B) if (offset > B && !strncmp(&p[- B], A)) valid=1

Then have a set of macros like:

valid=0;
CHK("md5(",4); CHK("md4(",4); CHK("sha1(",5); ....
if(valid) { /* do the logic */ }

<!-- gh-comment-id:139690961 --> @jfoug commented on GitHub (Sep 12, 2015): it will be a macro that does something like: CHK(A,B) if (offset > B && !strncmp(&p[- B], A)) valid=1 Then have a set of macros like: valid=0; CHK("md5(",4); CHK("md4(",4); CHK("sha1(",5); .... if(valid) { /\* do the logic */ }
Author
Owner

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

No wait, not #1746, I meant the build bot problems. We should open an issue for that.

<!-- gh-comment-id:139690962 --> @magnumripper commented on GitHub (Sep 12, 2015): No wait, not #1746, I meant the build bot problems. We should open an issue for that.
Author
Owner

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

I am leaving things alone right now, letting you dig in a bit. You might hopefully find stupid things I am doing, and help fix some design problems, in your digging in to understand just wtf is going on.

<!-- gh-comment-id:139691080 --> @jfoug commented on GitHub (Sep 12, 2015): I am leaving things alone right now, letting you dig in a bit. You might hopefully find stupid things I am doing, and help fix some design problems, in your digging in to understand just wtf is going on.
Author
Owner

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

One thing I may end up doing, is to not use the parsed reverse polish type data, other than to syntax check, and then later to run to get the test vars. I may re-do the code emission module to work directly from the original expression. I toyed with that a bit, but stopped the implementation about the time the AM leak sprung. Going from that recursive stack machine, to a 2 variable large instruction set system where all you can do is overwrite/append/clear/hash, does not map well at all. Although I 'may' do this by building a 2nd emulator, and actually RUNNING the code again, keeping track of the state of the machine, so that I know var 1 is free, var 2 is used for this part of the sub expression, etc, etc. IF I can get the code working like that, then it would be about as perfect as you can get.If you can actually do the expression by hand, that type of a parser could build a script to do it. It is no where NEAR that powerful today. It works for many common cases, but falls apart when there are more than 2 parts of the sub expression that need to be tracked and worked on at the same time.

<!-- gh-comment-id:139691701 --> @jfoug commented on GitHub (Sep 12, 2015): One thing I may end up doing, is to not use the parsed reverse polish type data, other than to syntax check, and then later to run to get the test vars. I may re-do the code emission module to work directly from the original expression. I toyed with that a bit, but stopped the implementation about the time the AM leak sprung. Going from that recursive stack machine, to a 2 variable large instruction set system where all you can do is overwrite/append/clear/hash, does not map well at all. Although I 'may' do this by building a 2nd emulator, and actually RUNNING the code again, keeping track of the state of the machine, so that I know var 1 is free, var 2 is used for this part of the sub expression, etc, etc. IF I can get the code working like that, then it would be about as perfect as you can get.If you can actually do the expression by hand, that type of a parser could build a script to do it. It is no where NEAR that powerful today. It works for many common cases, but falls apart when there are more than 2 parts of the sub expression that need to be tracked and worked on at the same time.
Author
Owner

@magnumripper commented on GitHub (Sep 14, 2015):

Anyway this issue can be closed. The following works:

$ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs&#\x40&^\x408\x40\x2a$'
Benchmarking: dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3) [256/256 AVX2 8x3]... DONE
Many salts: 9189K c/s real, 9189K c/s virtual
Only one salt:  7103K c/s real, 7103K c/s virtual

Verify the escapes:

$ echo -e 'c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs&#\x40&^\x408\x40\x2a$'
c1=::,c2=:,c3=:73@^bhhs&#@&^@8@*$

Email address has to be lower-cased in input file, as in

username:<md5 hash>$email@address.com
<!-- gh-comment-id:140225781 --> @magnumripper commented on GitHub (Sep 14, 2015): Anyway this issue can be closed. The following works: ``` $ ../run/john -test -form:dynamic='md5(lc($u).$c1.lc($p).$c2.$s.$c3),c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs&#\x40&^\x408\x40\x2a$' Benchmarking: dynamic=md5(lc($u).$c1.lc($p).$c2.$s.$c3) [256/256 AVX2 8x3]... DONE Many salts: 9189K c/s real, 9189K c/s virtual Only one salt: 7103K c/s real, 7103K c/s virtual ``` Verify the escapes: ``` $ echo -e 'c1=\x3a\x3a,c2=\x3a,c3=\x3a73\x40^bhhs&#\x40&^\x408\x40\x2a$' c1=::,c2=:,c3=:73@^bhhs&#@&^@8@*$ ``` Email address has to be lower-cased in input file, as in ``` username:<md5 hash>$email@address.com ```
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#1158
No description provided.