mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #2800] Problem with dynamic format #1797
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#1797
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jeroen-80 on GitHub (Sep 29, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2800
Originally assigned to: @jfoug on GitHub.
Reply from magnum,
@frank-dittrich commented on GitHub (Sep 29, 2017):
Not a solution yet, but:
If I add a constant into that expression, the self test passes:
And now with debug output:
Same for the format which fails:
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 commented on GitHub (Sep 29, 2017):
Tried to convert this into a regular dynamic format and turn most test lines into comments, but format still fails.
@kholia commented on GitHub (Sep 30, 2017):
@frank-dittrich There is a small typo in your dynamic script.
The
DynamicFunc__SHA1_crypt_input1_append_input2part should beDynamicFunc__SHA1_crypt_input1_overwrite_input2instead.Here is the full working version,
Results,
@kholia commented on GitHub (Sep 30, 2017):
This issue is probably related to https://github.com/magnumripper/JohnTheRipper/issues/1746. Issue #1746 has more details.
@frank-dittrich commented on GitHub (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_input2in 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, https://github.com/magnumripper/JohnTheRipper/issues/2776, you'll get a warning for every dynamic format defined in run/john-local.conf.
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 commented on GitHub (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 commented on GitHub (Oct 14, 2017):
This incorrect patch makes the dynamic compiler emit the right code for this particular situation.
It appears that a single
use_inp1variable is insufficient to determine both the "buffer" (input1, input2) and the "mode" (append / overwrite).@jfoug commented on GitHub (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
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 commented on GitHub (Dec 5, 2017):
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 commented on GitHub (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 commented on GitHub (Dec 6, 2017):
This sounds like a great idea. I would love to have this functionality.
@jfoug commented on GitHub (Dec 11, 2017):
Some good comments were made under this issue #2990 I will copy the text here
@kholia
@jfoug
@jfoug
@magnumripper
@magnumripper commented on GitHub (Dec 11, 2017):
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 commented on GitHub (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 commented on GitHub (Dec 12, 2017):
Hmm but that's the host code - it would be the same every time 😆 and who would write the kernel?
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: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
That function is trivial. Putting it all together is not hard.
@jfoug commented on GitHub (Dec 27, 2018):
Please test using the PR: #3568
@jfoug commented on GitHub (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.
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)
I used this script to generate the input file for that last sample data:
@kholia commented on GitHub (Dec 28, 2018):
The
cmp_one() failed. This format will FAIL and needs the Slower dyna-compiler formattext is confusing, especially thewill FAILpart.This needs to be reworded I think.
Should we say
would have failed with the fast code path...?@kholia commented on GitHub (Dec 28, 2018):
It's crazy that RDP stuff can handle such complex expressions ❤️
@kholia commented on GitHub (Dec 28, 2018):
Proposed text,
@frank-dittrich Do you have a better sounding message?
@jfoug commented on GitHub (Dec 28, 2018):
On 12/27/2018 9:32 PM, Dhiru Kholia wrote:
Change of the verbiage (or even total removal), is extreme trivial. Just
give a consensus of what we want, and it will be easy to do.
@jfoug commented on GitHub (Dec 28, 2018):
On 12/27/2018 9:40 PM, Dhiru Kholia wrote:
Since the runtime 'matches' the lexer/parser code, and uses a stack to
handle all of the recursive data objects, there really should be no
limit on complexity. For certain type parsing (math like expressions
such as this case), a recursive decent parser is actually a VERY GOOD
match for handling the 'language'. So simply matching up a stack based
code engine onto the RDP is a very natural fit. It is also pretty
simple to 'prove' that it is correct, vs working on the expressions
within dynamic. In that format, we could match the logic to the code
running engine (the dynamic engine), but getting things correct (and
PROVING them correct), was much more difficult.