Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with dynamic format #2800

Closed
jeroen-80 opened this issue Sep 29, 2017 · 22 comments
Closed

Problem with dynamic format #2800

jeroen-80 opened this issue Sep 29, 2017 · 22 comments

Comments

@jeroen-80
Copy link

jeroen-80 commented Sep 29, 2017

magnum wrote:

It can do many crazy combinations that is (probably) not used anywhere:

$ ../run/john -test -form:dynamic='sha1(md5(md4($pass).$salt))'
Benchmarking: dynamic=sha1(md5(md4($p).$s)) [128/128 AVX 4x1]... DONE
Many salts: 5816K c/s real, 5816K c/s virtual
Only one salt: 5340K c/s real, 5340K c/s virtual

Nice timing. I'm playing with a non-standard format. Magnumripper (from GIT) reports an error:

bofh@cruncher:/opt/JohnTheRipper/run$ ./john /tmp/test -form:dynamic='md5(sha1($salt.md5($pass)))'
Using default input encoding: UTF-8
Loaded 1236356 password hashes with 1223955 different salts
(dynamic=md5(sha1($s.md5($p))) [128/128 SSE4.1 4x1])
Warning: no OpenMP support for this hash type, consider --fork=80 Self
test failed (cmp_all(1))

How can I help to fix this issue?

Reply from magnum,

Unfortunately JimF (author/maintainer of dynamic and lots of other stuff) has been mostly gone for quite some time now. He used to do that now and then, so let's hope he'll come back and dig into it! Meanwhile, your best bet is opening an issue for this problem on GitHub.

@frank-dittrich
Copy link
Collaborator

frank-dittrich commented Sep 29, 2017

Not a solution yet, but:

If I add a constant into that expression, the self test passes:

$ ./john --format=dynamic='md5($c1.sha1($salt.md5($pass))),c1=x' --test 
Benchmarking: dynamic=md5($c1.sha1($s.md5($p))) [128/128 AVX 4x1]... DONE
Many salts:	4381K c/s real, 4381K c/s virtual
Only one salt:	4080K c/s real, 4080K c/s virtual

And now with debug output:

$ ./john --format=dynamic='md5($c1.sha1($salt.md5($pass))),c1=x,debug' --test 
push
app_1
.
push
app_sh
.
push
app_p
f5h
f1h
f5h

crc32 = D3430DB4
pExpr=md5($c1.sha1($s.md5($p)))
extraParams=,c1=x,debug
signature=@dynamic=md5($c1.sha1($salt.md5($pass))),c1=x,debug@
line0=@dynamic=md5($c1.sha1($s.md5($p)))@dc8d58cdddac7ad25137c70950c74e85$76931fac
line1=@dynamic=md5($c1.sha1($s.md5($p)))@811d75760d0ff9b9c572c0969e9556e0$9dab2b36
line2=@dynamic=md5($c1.sha1($s.md5($p)))@d79c263fd644593cdbb40e0691da039c$c248b87d
line3=@dynamic=md5($c1.sha1($s.md5($p)))@d37258601633ac38f9dab311ba48c1ac$6ae33f9a
line4=@dynamic=md5($c1.sha1($s.md5($p)))@d0d859640cbfae3e52faec0f58b2ca1f$62d7183a
##############################################################
#  Dynamic script for expression md5($c1.sha1($s.md5($p))),c1=x,debug
##############################################################
Expression=dynamic=md5($c1.sha1($s.md5($p)))
#  Flags for this format
Flag=MGF_FLAT_BUFFERS
Flag=MGF_SALTED
#  Lengths used in this format
SaltLen=-32
MaxInputLenX86=110
MaxInputLen=110
#  The functions in the script
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_keys
Func=DynamicFunc__MD5_crypt_input1_overwrite_input2
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_salt
Func=DynamicFunc__append_input_from_input2
Func=DynamicFunc__SHA1_crypt_input1_overwrite_input2
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_input1_from_CONST1
Func=DynamicFunc__append_input_from_input2
Func=DynamicFunc__MD5_crypt_input1_to_output1_FINAL
#  Constants used by this format
Const1=x
#  The test hashes that validate this script
Test=@dynamic=md5($c1.sha1($s.md5($p)))@dc8d58cdddac7ad25137c70950c74e85$76931fac:abc
Test=@dynamic=md5($c1.sha1($s.md5($p)))@811d75760d0ff9b9c572c0969e9556e0$9dab2b36:john
Test=@dynamic=md5($c1.sha1($s.md5($p)))@d79c263fd644593cdbb40e0691da039c$c248b87d:passweird
Test=@dynamic=md5($c1.sha1($s.md5($p)))@d37258601633ac38f9dab311ba48c1ac$6ae33f9a:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEF
Test=@dynamic=md5($c1.sha1($s.md5($p)))@d0d859640cbfae3e52faec0f58b2ca1f$62d7183a:

Same for the format which fails:

$ ./john --format=dynamic='md5(sha1($salt.md5($pass))),debug' --test 
push
push
app_sh
.
push
app_p
f5h
f1h
f5h

crc32 = CAEDC732
pExpr=md5(sha1($s.md5($p)))
extraParams=,debug
signature=@dynamic=md5(sha1($salt.md5($pass))),debug@
line0=@dynamic=md5(sha1($s.md5($p)))@cde2d0f968a83ad5c770ec34b99ec377$76931fac
line1=@dynamic=md5(sha1($s.md5($p)))@1ea967473f72b1f32d6abee0210705f4$9dab2b36
line2=@dynamic=md5(sha1($s.md5($p)))@f8d383c5017500552a014d7eddbb1347$c248b87d
line3=@dynamic=md5(sha1($s.md5($p)))@1d5eb0d39615205a2d2003f08bbfaa3d$6ae33f9a
line4=@dynamic=md5(sha1($s.md5($p)))@d304c96c32da64891bfe6fb05fe94aff$62d7183a
##############################################################
#  Dynamic script for expression md5(sha1($s.md5($p))),debug
##############################################################
Expression=dynamic=md5(sha1($s.md5($p)))
#  Flags for this format
Flag=MGF_FLAT_BUFFERS
Flag=MGF_SALTED
#  Lengths used in this format
SaltLen=-32
MaxInputLenX86=110
MaxInputLen=110
#  The functions in the script
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_keys
Func=DynamicFunc__MD5_crypt_input1_overwrite_input2
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_salt
Func=DynamicFunc__append_input_from_input2
Func=DynamicFunc__SHA1_crypt_input1_append_input2
Func=DynamicFunc__MD5_crypt_input2_to_output1_FINAL
#  The test hashes that validate this script
Test=@dynamic=md5(sha1($s.md5($p)))@cde2d0f968a83ad5c770ec34b99ec377$76931fac:abc
Test=@dynamic=md5(sha1($s.md5($p)))@1ea967473f72b1f32d6abee0210705f4$9dab2b36:john
Test=@dynamic=md5(sha1($s.md5($p)))@f8d383c5017500552a014d7eddbb1347$c248b87d:passweird
Test=@dynamic=md5(sha1($s.md5($p)))@1d5eb0d39615205a2d2003f08bbfaa3d$6ae33f9a:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEF
Test=@dynamic=md5(sha1($s.md5($p)))@d304c96c32da64891bfe6fb05fe94aff$62d7183a:

May be someone more familiar with writing dynamic formats dynamic_nnnn can see where the problem is, and work around it by defining a new format dynamic_9001 or similar.
(9nnn is for personal use. If that format really is used, a new dynamic_1nnn can be used.)

BTW: dynamic='md5(md5($salt.md5($pass)))' fails as well .dynamic='sha1(sha1($salt.sha1($pass)))'

@frank-dittrich
Copy link
Collaborator

frank-dittrich commented Sep 29, 2017

Tried to convert this into a regular dynamic format and turn most test lines into comments, but format still fails.

[List.Generic:dynamic_1519]
Expression=md5(sha1($s.md5($p)))
#  Flags for this format
Flag=MGF_FLAT_BUFFERS
Flag=MGF_SALTED
#  Lengths used in this format
SaltLen=-32
MaxInputLenX86=110
MaxInputLen=110
#  The functions in the script
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_keys
Func=DynamicFunc__MD5_crypt_input1_overwrite_input2
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_salt
Func=DynamicFunc__append_input_from_input2
Func=DynamicFunc__SHA1_crypt_input1_append_input2
Func=DynamicFunc__MD5_crypt_input2_to_output1_FINAL
#  The test hashes that validate this script
Test=$dynamic_1519$cde2d0f968a83ad5c770ec34b99ec377$76931fac:abc
#Test=$dynamic_1519$1ea967473f72b1f32d6abee0210705f4$9dab2b36:john
#Test=$dynamic_1519$f8d383c5017500552a014d7eddbb1347$c248b87d:passweird
#Test=$dynamic_1519$1d5eb0d39615205a2d2003f08bbfaa3d$6ae33f9a:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEF
#Test=$dynamic_1519$d304c96c32da64891bfe6fb05fe94aff$62d7183a:

$ ./john --format=dynamic_1519 --test
Benchmarking: dynamic_1519 [md5(sha1($s.md5($p))) 128/128 AVX 4x1]... FAILED (cmp_all(1))

@kholia
Copy link
Member

kholia commented Sep 30, 2017

@frank-dittrich There is a small typo in your dynamic script.

The DynamicFunc__SHA1_crypt_input1_append_input2 part should be DynamicFunc__SHA1_crypt_input1_overwrite_input2 instead.

Here is the full working version,

[List.Generic:dynamic_1519]
Expression=md5(sha1($s.md5($p)))
Flag=MGF_FLAT_BUFFERS
Flag=MGF_SALTED
SaltLen=-32
MaxInputLenX86=110
MaxInputLen=110
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_keys
Func=DynamicFunc__MD5_crypt_input1_overwrite_input2
Func=DynamicFunc__clean_input_kwik
Func=DynamicFunc__append_salt
Func=DynamicFunc__append_input_from_input2
Func=DynamicFunc__SHA1_crypt_input1_overwrite_input2
Func=DynamicFunc__MD5_crypt_input2_to_output1_FINAL
Test=$dynamic_1519$cde2d0f968a83ad5c770ec34b99ec377$76931fac:abc
Test=$dynamic_1519$1ea967473f72b1f32d6abee0210705f4$9dab2b36:john
Test=$dynamic_1519$f8d383c5017500552a014d7eddbb1347$c248b87d:passweird
Test=$dynamic_1519$1d5eb0d39615205a2d2003f08bbfaa3d$6ae33f9a:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEF
Test=$dynamic_1519$d304c96c32da64891bfe6fb05fe94aff$62d7183a:

Results,

$ ../run/john --device=0 --test --format=dynamic_1519
Benchmarking: dynamic_1519 [md5(sha1($s.md5($p))) 256/256 AVX2 8x1]... DONE
Many salts:	7691K c/s real, 7691K c/s virtual
Only one salt:	6985K c/s real, 6985K c/s virtual

@kholia kholia added the bug label Sep 30, 2017
@kholia
Copy link
Member

kholia commented Sep 30, 2017

This issue is probably related to #1746. Issue #1746 has more details.

@frank-dittrich
Copy link
Collaborator

frank-dittrich commented Sep 30, 2017

@kholia actually, it is not my dynamic script, it is more or less Jim's debugging output, converted into a format, see the Func=DynamicFunc__SHA1_crypt_input1_append_input2 in the debug output.

May be you can even figure out and fix the bug in the dynamic compiler?

@jeroen-80 thanks to @kholia you now have a workaround.

Is this format used somewhere? What product uses this format? Should we include it in jumbo?
If not, I suggest you rename the format, to avoid naming collisions with future jumbo formats.

(But I was wrong about the name space. You can't use dynamic_9001 etc. Jumbo doesn't allow format names > dynamic_5000.
So I suggest you use dynamic_4999, dynamic_4998 etc. for your private formats.)

Unfortunately, due to another bug, #2776, you'll get a warning for every dynamic format defined in run/john-local.conf.

 $ ./john --test --format=dynamic_4999
Warning! Section [list.generic:dynamic_4999] overridden by john-local.conf
Benchmarking: dynamic_5000 [md5(sha1($s.md5($p))) 128/128 AVX 4x1]... DONE
Many salts:	4920K c/s real, 4920K c/s virtual
Only one salt:	4483K c/s real, 4483K c/s virtual

For now, just ignore that warning or adjust verbosity with --verbosity=2 (but that will also change what gets logged in the .log file).

@kholia
Copy link
Member

kholia commented Sep 30, 2017

@frank-dittrich I will take a look at the dynamic compiler soon but I doubt I will be able to understand this complex piece of code without Jim's help. Thanks for the nudge though! :-)

@kholia
Copy link
Member

kholia commented Oct 14, 2017

@@ -1962,7 +1963,7 @@ static int parse_expression(DC_struct *p) {
 #define ELSEIF(C,T,L) else if (!strncasecmp(pCode[i], #T, L)) \
        { \
                char type = pCode[i][strlen(pCode[i])-1]; \
-               comp_add_script_line("Func=DynamicFunc__" #C "_crypt_input%s_%s_input2\n", use_inp1?"1":"2", use_inp1?"append":"overwrite"); \
+               comp_add_script_line("Func=DynamicFunc__" #C "_crypt_input%s_%s_input2\n", use_inp1?"1":"2", "overwrite"); \
                if (type=='r') { len_comp2 += nLenCode[i]; } \
                else if (type=='c'||type=='6') { len_comp2 += b64_len(nLenCode[i]); } \
                else { len_comp2 += nLenCode[i]*2; } \

This incorrect patch makes the dynamic compiler emit the right code for this particular situation.

It appears that a single use_inp1 variable is insufficient to determine both the "buffer" (input1, input2) and the "mode" (append / overwrite).

@jfoug
Copy link
Collaborator

jfoug commented Nov 6, 2017

This really is a limitation of dynamic. Yes, the format above CAN be handled with smarter code. BUT that does not mean the dyna compiler (or dynamic in general), can handle all expressions. As soon as someone can write this expression for me in working 'flat' dynamic (by hand), then I will look at extending the dyna compiler. BUT this is simply a limitation of dynamic in general. It was written as a simple proof of concept, that ended up working amazingly well. BUT it is limited. The new flat model has only 2 buffers, and all operations will either append or overwrite one of the buffers with the results of the current operations. So, I post this as a challenge. Write a valid flat dynamic format for this hash:

md5($p.md5($p.md5($p.$s).md5($p)).$p.$s.md5($s.$p.$p).md5($s.md5($s.$p).md5($s)))

here is perl script to do it, and sample

#!/usr/bin/perl

# md5($p.md5($p.md5($p.$s).md5($p)).$p.$s.md5($s.$p.$p).md5($s.md5($s.$p).md5($s)))

use Digest::MD5 qw(md5_hex);

foreach my $inp (<STDIN>) {
	chomp $inp;
	my @ar = split(",", $inp);
	my $s = $ar[0];
	my $p = $ar[1];
	my $h1 = md5_hex($p.md5_hex($p.md5_hex($p.$s).md5_hex($p)).$p.$s.md5_hex($s.$p.$p).md5_hex($s.md5_hex($s.$p).md5_hex($s)));
	print "pw=$p  salt=$s   hash=$h1\n";
}

So my point is that even if we do fix the above issue, this does not (and CAN NOT) fix this format for all arbitrarily expressions. Simply put, the current compiler will handle all expressions which are dependent on a single var. It can handle a few which should be able to be done in 2 vars, but it fails for many instances which could be done in 2. It can not handle anything which would require 3 or more variables to complete. The above expression I have listed would require 3 independent variables, to house the sub expressions. There currently are not 3 variables within dynamic.

@magnumripper
Copy link
Member

If possible/feasible, it would obviously be nice if the compiler could detect "impossible tasks" like this one and bail out with some descriptive error, instead of producing something that fails self-test.

@jfoug
Copy link
Collaborator

jfoug commented Dec 6, 2017

I have sort of left it. I still am not 100% sure that I want to abandon it. I 'could' write a format that does use oSSL CTX, and recursive decent parsing. It would be slow (sort of like the crypt(3) code), BUT be a fallback to allow any valid simple function expression to 'work', even if it does not fit into dynamic with its variable limitations.

Yes, I can easily run a simple ST and it will fail. I can run the existing RD parser code, and it generates valid data. I could write something that is much thinner than dynamic (hell, I already have most of it, in the logic in dyna compiler to create the ST strings). Then simply build a format around that.

This is not a trivial undertaking, but I think it is something that really needs done, since about every 6 months, someone resurrects this zombie bug over and over again ;)

@kholia
Copy link
Member

kholia commented Dec 6, 2017

I 'could' write a format that does use oSSL CTX, and recursive decent parsing. It would be slow (sort of like the crypt(3) code), BUT be a fallback to allow any valid simple function expression to 'work', even if it does not fit into dynamic with its variable limitations.

This sounds like a great idea. I would love to have this functionality.

@jfoug
Copy link
Collaborator

jfoug commented Dec 11, 2017

Some good comments were made under this issue #2990 I will copy the text here

@kholia

I am super interested in seeing support for arbitrary (but reasonable) expressions in the
dynamic format with OpenSSL backend.

I vaguely remember reading an article which mentioned an "enhanced hash scheme
description" language. Something like our dynamic expression language but with
support for sub-strings, and iterations. I can't find the article now ;(

Update: Found the article!
https://s3inlc.wordpress.com/2017/11/10/algorithms-on-hashes-org/

@jfoug

Yes, the dyna compiler certainly 'could' really become dynamic. using the existing code in
dynamic when it can (the flat code), and using other logic, when it can not (such as
iterations, hmacs, pbkd2 algorithm, etc). I do like how the compiler does allow
'optimizations' into using appropriate dynamic_flat code, when it can, and I think that
is a great way to optimize. But also having it actually fall back into a new format, that
does recursive decent parsing on hashes which fall outside of capabilities of the existing
dynamic, and then this new format simply does that, would be a great gain. The format
would not be the fastest thing possible, BUT it would allow usage of john anyway, and
allow you to prototype a 'new' hash easily, get it working, and then if it is something
important, write a 'fat' format that optimizes it.

Lemme dig into that article a bit.

@jfoug

I really like the additions, such as iteration counts, substrings, and rotations. my plan
was to do use the '^' character for iterations, such as md5($p)^1000 or
sha256((sha256($s.$p).sha256($p))^1500), etc. As for sub and rot[lr] The can be added.
Currently, the name of the function specifies things like casing, base64, etc (for internal,
while still hashing, re-hash work).

Some other things to think about are talk of algos, such as:

h1=md5($p) count=1000+substr(h1,0,3) hash=sha256($s.$p)^count

within the existing expression syntax, we have no way of INTERPRETING the prior hash
results for anything other than feed into the next hashing. but here, we could add
something like:

hash=sha256($s.$p)^(binary_value(substr(md5($p),0,3))+1000) (we could also build a
hex_value function)

so this type usage 'can' be converted into our single expression model, albeit the
expression parser just grew a LOT more complex, but CERTAINLY doable. The SunMD5
fits this model (sort of), where it does some computations on the data returned from
a subhash test (heck, all of the algo-crypt functions do that). But those hashes are
probably beyond trying to handle generically. They simply have too much 1-off
uniqueness to them.

@magnumripper

This should probably be discussed elsewhere or we'll never find it again... I think an
extremely interesting idea is OpenCL dynamic (#1564). It could re-use many ideas
from current dynamic and/or dynamic compiler but in the end it'd be combining
the needed pre-made functions or blocks of code at run-time to a temporary kernel
just for the occasion. Unlike on CPU, we'll actually be compiling the result at run
time, which means the optimizers can do a lot of difference (normally, most functions
will end up inlined).

@magnumripper
Copy link
Member

Adding to my statement above, the dynamic-opencl would obviously include mask-mode acceleration from day 1.

But we should not even start this until after next Jumbo release because it'd take 105% of our time (at least yours truly and @jfoug) for quite some time before we'd have a nice start, ready for merging.

@jfoug
Copy link
Collaborator

jfoug commented Dec 12, 2017

The openCL version of dynamic has scared the shit outta me, and I have even deemed it undoable.

However, while going over what I was going to reply in this message, something just hit me. How about getting really out of the box, much like when I did FLAT dynamic. Simply have an offline tool, that you enter the expressions wanted, and it builds a 'nearly' workable file. The valid, salt, binary may be the only things needing work, and possibly not even those. Thus, someone could list out something like

./generic_opencl_gen 'sha256($s.sha256($p.$s)^2048.$p)' > opencl_specialsha256_fmt_plug.c which there is no format for, and this generator would print to this file, the data needed.

NOTE, i do not know opencl well, especially the really good 'tricks'. For this to work, we may need some additional flags, such as which tricks to use.

I know this is vastly different than I was picturing, BUT I can see getting this to work. I am not sure I can see getting a true generic opencl format working at all. My original goal, was to get md5_gen (the original shit), and simply add CPU engines (including opencl) to it. But the more I dug into that code, and from experience doing SIMD, I see opencl as nothing more than a pipe dream. There is simply WAY too much nuance you have to do to get things working well, depending upon fast format, flat format, simply salted format, salted multi iteration format, or something else. each have to be somewhat hand done.

@magnumripper
Copy link
Member

./generic_opencl_gen 'sha256($s.sha256($p.$s)^2048.$p)' > opencl_specialsha256_fmt_plug.c

Hmm but that's the host code - it would be the same every time 😆 and who would write the kernel?

The openCL version of dynamic has scared the shit outta me, and I have even deemed it undoable.

How is it different or harder than the existing CPU format? Let's picture a rudimentary PoC. I think what you have in CPU dynamic is a bunch of functions that all have the same prototype. In CPU dynamic it's void f(void) and they all use a bunch of globals. In OpenCL it'd be better to have all them (needed or not) as parameters - but the key is all have the same prototype. Eg:

func(uchar *input_buf1, uchar *input_buf2, uint total_len1, uint total_len2, uchar *out_1, uchar *out_2 (...and so on...))

The OpenCL dynamic would never invent a single line of code. What it would do is put prefab blocks together. Since all of them have the exact same prototype, it's as easy as on CPU.

So one of these prefab blocks (functions) would be

DynamicFunc__crypt_md5(uchar *input_buf1, uchar *input_buf2, uint total_len1, uint total_len2, uchar *out_1, uchar *out_2 (...and so on...))

That function is trivial. Putting it all together is not hard.

@jfoug
Copy link
Collaborator

jfoug commented Dec 27, 2018

Please test using the PR: #3568

@jfoug
Copy link
Collaborator

jfoug commented Dec 28, 2018

Here is a couple quick tests:

In this one, I did not have the input file @jeroen-80 had, but the format is passing self test, and I HAVE run against real test vectors in other areas, and it has been finding them all.

$ ../run/john -test -form:dynamic='md5(sha1($salt.md5($pass)))'
cmp_one() failed. This format will FAIL and needs the Slower dyna-compiler format
This expression will use the RDP dynamic compiler format.
Benchmarking: dynamic=md5(sha1($s.md5($p))) [Dynamic RDP]... DONE
Warning: "Many salts" test limited: 255/256
Many salts:     454777 c/s real, 503112 c/s virtual
Only one salt:  411098 c/s real, 478922 c/s virtual

And just to show the format will work for expressions which can not be handled by dynamic in any manner whatsoever (from a post I did earlier in this thread)

$ ../run/john in -form='dynamic=md5($p.md5($p.md5($p.$s).md5($p)).$p.$s.md5($s.$p.$p).md5($s.md5($s.$p).md5($s)))' -w=../run/password.lst
cmp_one() failed. This format will FAIL and needs the Slower dyna-compiler format
This expression will use the RDP dynamic compiler format.
Using default input encoding: UTF-8
Loaded 50 password hashes with 50 different salts (dynamic=md5($p.md5($p.md5($p.$s).md5($p)).$p.$s.md5($s.$p.$p).md5($s.md5($s.$p).md5($s))) [Dynamic RDP])
Warning: no OpenMP support for this hash type, consider --fork=2
Press 'q' or Ctrl-C to abort, almost any other key for status
snoopy           ()
password1        ()
carmen           ()
123456           ()
ranger           ()
123              ()
123456789        ()
mike             ()
hello            ()
shadow           ()
12345678         ()
1234567890       ()
a1b2c3           ()
mustang          ()
service          ()
letmein          ()
qwerty           ()
1234             ()
mickey           ()
computer         ()
summer           ()
donald           ()
canada           ()
internet         ()
money            ()
tigger           ()
hockey           ()
abc123           ()
secret           ()
harley           ()
buster           ()
maggie           ()
baseball         ()
                 ()
password         ()
dragon           ()
12345            ()
37g 0:00:00:03 DONE (2018-12-27 18:42) 12.19g/s 1168p/s 56150c/s 56150C/s Hammer..sss
Use the "--show --format=dynamic=md5($p.md5($p.md5($p.$s).md5($p)).$p.$s.md5($s.$p.$p).md5($s.md5($s.$p).md5($s)))" options to display all of the cracked passwords reliably

$ can in
:774349fcb01ce88df2d029e30588cb31$EJWLMXFI:#!comment: This list has been compiled by Solar Designer of Openwall Project
:459dc6cc512a823527ae5d92d5c50a3f$NVLBUJSN:#!comment: in 1996 through 2011.  It is assumed to be in the public domain.
:a6bc54bcc8c5041cc8f2ee09eda626a6$CIZTVERW:#!comment:
:84fa52b9997fdb59bcc9ced0e7b8f836$BFCUCTIM:#!comment: This list is based on passwords most commonly seen on a set of Unix
:f45062a9cf0849a01bc91a5a751489cc$AOXTPUTA:#!comment: systems in mid-1990's, sorted for decreasing number of occurrences
:c57a9bab480efb1e6990577eb1404106$BLJPRAEX:#!comment: (that is, more common passwords are listed first).  It has been
:ec1995bf8566836f365dbaf47582dacf$RMTSFCHK:#!comment: revised to also include common website passwords from public lists
:ee84eda9a475a76f17c0480e08beaf33$NXUMOBXQ:#!comment: of "top N passwords" from major community website compromises that
:c7d0e1352c62d6d7c438fb529c998987$DGBVJGFR:#!comment: occurred in 2006 through 2010.
:82e187f72a32c42169143c2280a3e19a$OKCWTWYH:#!comment:
:d89682c6b7185deb56c024ff798d3f21$KRMOXIED:#!comment: Last update: 2011/11/20 (3546 entries)
:16b47784314693f6e9415e5e5f0418fb$ZXLZRTGW:#!comment:
:edec77faedf532fa5124bd99ad6b6535$ZWLSZZNC:#!comment: For more wordlists, see http://www.openwall.com/wordlists/
:1915b61aba5928b44a5c26b203c951df$DNMYTUIN:123456
:08b503b69c3c12b3d3b5b0ef9b343bef$ZEAKZIPE:12345
:6cf82cf76ea901f22df581a3abdcd8d1$YLDAPQDE:password
:f8a725b7a43a8bbfa5c821e5a62289a2$BIASMQAH:password1
:0cf3f6b1508adc116c6c04e26cc10faf$EYROLVKT:123456789
:85163cdae553787146204b1ff0471319$HUZMDVZE:12345678
:1afd2c52e3dfaab569a8fc1e16c7d57f$JODIKUMV:1234567890
:8b3529377f9758189748e3aa1ec0f451$VGJPBBVJ:abc123
:ae22a9d08dc3c368a42bca5dd252233f$OGPGKEKB:computer
:69f3d464eea34967a9dc4a9e0b21d999$VCLZBYJM:tigger
:f57226c86b09f477c54f7a18da98f04c$MCEAWSEE:1234
:7e524ecb3f0df4ca01233e8e870c8051$LVTVDOAZ:qwerty
:6e2cc373f2eead50f179ce088b0ec04c$UQNPOXJR:money
:23f6087589feb99e1511f1a5f6107ae8$CGNBCPXM:carmen
:1055c774f40b1a70d0b203328c87a367$NGHFEAIU:mickey
:0294e591598a49a1c31621af0aef0411$VKBREQXO:secret
:05225580d20370aa3e5665223d27f1bd$PTTATQSX:summer
:6c2bb6281a1d6c34ab82158a01c201b5$UGUZTVOE:internet
:ce8994eb58c2f8129b92dccb5f66b727$JPZFHAMH:a1b2c3
:f3d84a7a855394da76d286d3f005087d$ERENLPYW:123
:291262bfa109a7a0efb389a5d01aa89b$KESYFBUB:service
:4dbbe0acb9047fd9579f2e38ee000ae2$YILZOVRK:
:953da97026f7e53b50ad1034b159f53e$TPRBXLJF:canada
:f0f11f0065ef901e50ff859029fd8e57$FIUDPRSI:hello
:a018233b3a05bbb4bee934e8369caeb7$DXYCFGKT:ranger
:01c79d4dec4fb64dcee14b9574c36ef4$FYIVREFD:shadow
:710b54285cf09a1161c447322c29ec6a$XRXLIESZ:baseball
:9a0d1c3f89f5914008c5e2bd0f757848$SQWADCMX:donald
:e707cfb3a1ea0bea0c5de7c46b6f568c$WHMADOJD:harley
:912c29391199abd3e33767a5d4ef198e$VCTEYXFH:hockey
:10e7faf12f86505c8f1d44f06acc4942$LQRAWAGU:letmein
:95b38c46d0363d67c85a0b05296a9f6e$XJVRLLBQ:maggie
:d3dd63c9f8c57c5d71c1247d4ca15106$FBHSIVYV:mike
:f6977b43b93ad9bdd61a08d895ed757b$JZBWSIJU:mustang
:22b7afbc9474259a82afdae3203b532f$ATMIBQCG:snoopy
:9d1e31258c4c0a6098fdf934f653901b$WPUCDFYS:buster
:a3caa6664bb3db9966236361101736d6$YSZHBULN:dragon

I used this script to generate the input file for that last sample data:

$ cat x.pl
#!/usr/bin/perl

# md5($p.md5($p.md5($p.$s).md5($p)).$p.$s.md5($s.$p.$p).md5($s.md5($s.$p).md5($s)))

use Digest::MD5 qw(md5_hex);

foreach my $p (<STDIN>) {
        chomp $p;
        my $s = rand_str(8);
        my $h1 = md5_hex($p.md5_hex($p.md5_hex($p.$s).md5_hex($p)).$p.$s.md5_hex($s.$p.$p).md5_hex($s.md5_hex($s.$p).md5_hex($s)));
        print ":$h1\$$s:$p\n";
}

sub rand_str {
        my $s = "";
        my $n = $_[0];
        for ($i = 0; $i < $n; $i++) {
                $s .= chr(rand(26)+ord('A'));
        }
        return $s;
}

@kholia
Copy link
Member

kholia commented Dec 28, 2018

The cmp_one() failed. This format will FAIL and needs the Slower dyna-compiler format text is confusing, especially the will FAIL part.

This needs to be reworded I think.

Should we say would have failed with the fast code path...?

@kholia
Copy link
Member

kholia commented Dec 28, 2018

It's crazy that RDP stuff can handle such complex expressions ❤️

@kholia
Copy link
Member

kholia commented Dec 28, 2018

Proposed text,

diff --git a/src/dynamic_compiler.c b/src/dynamic_compiler.c
index 4fa96b1f6..094a66eda 100644
--- a/src/dynamic_compiler.c
+++ b/src/dynamic_compiler.c
@@ -2517,13 +2517,13 @@ int dynamic_assign_script_to_format(DC_HANDLE H, struct fmt_main *pFmt) {
                                ret = pFmt->methods.cmp_exact(pFmt->params.tests[j].ciphertext, 0);
                                if (!ret && !failed) {
                                        if (options.verbosity > VERB_DEFAULT)
-                                               fprintf(stderr, "cmp_exact() failed. This format will FAIL and needs the Slower dyna-compiler format\n");
+                                               fprintf(stderr, "This format would have failed with the fast code path, hence falling back to slower dyna-compiler format.\n");
                                        failed = 1;
                                }
                        }
                        else if (!failed) {
                                if (options.verbosity >= VERB_DEFAULT)
-                                       fprintf(stderr, "cmp_one() failed. This format will FAIL and needs the Slower dyna-compiler format\n");
+                                       fprintf(stderr, "This format would have failed with the fast code path, hence falling back to slower dyna-compiler format.\n");
                                failed = 1;
                        }
                }

@frank-dittrich Do you have a better sounding message?

@jfoug
Copy link
Collaborator

jfoug commented Dec 28, 2018 via email

@jfoug
Copy link
Collaborator

jfoug commented Dec 28, 2018 via email

magnumripper pushed a commit that referenced this issue Dec 30, 2018
* added dynamic-compiler RDP format when script builds incorrectly

* fixed compiler errors about signed/unsigned chars

* better algo label. Fixed bug when MD5_X2 set

* the failed message (i.e. using RDP) needed moved inside an if clause

* dyna-compiler.  added ,rdp switch to force RDP format. common_init needed for dyna-lib. expanded buffers in the compiler.

* fixed john.pot output of things like -form=dynamic=md5($p)

* Handle extra params for compiler lib formats. Fixed WS and speeling errors, per reviews

* exe bit set

* VC at 2015 is C99 compliant for vsnprintf. Handle RDP where base format stored keys in input buffers

Closes #1746 and #2800, see also #3389, #3125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants