mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #704] Thin formats fail after format enumeration due to nested mess of init() #349
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#349
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 @magnumripper on GitHub (Jul 24, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/704
Originally assigned to: @jfoug on GitHub.
These formats fail in Test Suite...
...but not in --test:
Very likely related to recent changes.
@jfoug commented on GitHub (Jul 24, 2014):
your --test does NOT test using --fork.
NOTE, I am still pretty sure that for some reason, when running under --fork, that either split or prepare is NOT always being called.
@magnumripper commented on GitHub (Jul 25, 2014):
I can't picture how that could be possible at all. But it should be easy to prove with some debug code.
@magnumripper commented on GitHub (Jul 25, 2014):
Hmm --test is supported with MPI, which mostly uses the same code as --fork. So I should test that.
@jfoug commented on GitHub (Jul 25, 2014):
The reason I claim this is because HEX leaking into dynas salt. There should be no way that happens either, but it does for fork.
@magnumripper commented on GitHub (Jul 25, 2014):
Not triggered with MPI and --test.
But it is reproducible using the TS command line, replacing fork with MPI:
@magnumripper commented on GitHub (Jul 25, 2014):
That makes it even stranger. This means --node must be affected too... yep it is.
@magnumripper commented on GitHub (Jul 25, 2014):
The good thing about it is it's easier to debug. Just use --node=1/2 and debug one single threaded process.
@magnumripper commented on GitHub (Aug 4, 2014):
The split/prepare issue was fixed but this issue remains.
@magnumripper commented on GitHub (Aug 8, 2014):
Bug does not surface if
--formatis given explicitly - I suspect this is a fmt_init() problem.@magnumripper commented on GitHub (Aug 8, 2014):
Same bug, different test case (no node/fork/MPI)
@magnumripper commented on GitHub (Aug 8, 2014):
@jfoug I try to understand the thin dynamic formats. For prepare(), valid() and split() to support being called before init(), they call each format's own get_ptr() function which sets the function pointers but also calls dynamic_THIN_FORMAT_LINK() which in turn does call dynamic_fmt's init(). I think the normal mechanism that prevents executing init() more than once is circumvented this way but that may be OK here. Or not?
Is there no better way to ensure all thin pre-init functions' pointers (and params.label etc) are initialized very early? Like in dynamic_Register_formats() or something?
@magnumripper commented on GitHub (Aug 8, 2014):
With some debug prints:
What's with that last
init(dynamic_19)? That is probably the problem but why does it happen?EDIT: It's because we enumerate alternative formats for this ciphertext, because --format was not given.
EDIT no, the last init() is phpass from john_load() so that should not be a big deal.
@magnumripper commented on GitHub (Aug 8, 2014):
...and using
--formatBug does not surface because we do not enumerate alternate formats.
@magnumripper commented on GitHub (Aug 8, 2014):
But that IS the problem. Because the THIN_FORMAT_LINK() overrides the "format already initialized" but fmt_init() does not. So the last fmt_init(phpass) is a NO-OP and dynamic remains (half?) initialized for dynamic 19 instead of 17.
@magnumripper commented on GitHub (Aug 10, 2014):
This bug is caused by
6cbc3065alone.@jfoug commented on GitHub (Aug 18, 2014):
I believe this is fixed in
bb1b1aa@jfoug commented on GitHub (Aug 18, 2014):
--test=0 works
Running a PHPS hash without using --format works (also works if you use the --format=phps)
test suite works.
tested cygwin32/64 and ubuntu64.
Also, we now properly link salt/prepare, etc early. This was the reason for the change before. We had 'work around' code to skip some stuff for dyna formats. We hopefully can remove that now. Their functions which should work prior to init now 'should' work, even for thin dynas. That was not an easy task to get done, but I think it now IS done. There are a lot of nuances within john, where things get done, dont get done, etc, depending upon modes, on loading a file, loading a pot, etc, etc. Hopefully now that dyna is there, we can start to remove some of these.
I am leaving bug open, until magnum can validate that he's happy with this. Hmm, I never closed this, but github may have done so, based upon my comments.
@magnumripper commented on GitHub (Aug 18, 2014):
Seems fine to me.
How come this is needed though? The thin formats have a normal format struct (though not fully populated) that already initializes eg. valid() to our_valid(). So why do we need link_funcs()? I can see it is needed but I do not really get why.
@jfoug commented on GitHub (Aug 18, 2014):
Within the call to link_dyna, the dyna code copies pointers from the 'built in' dyna format. All of those method pointers are to canned dyna functions. In the original code I had, I was setting our thin methods (salt, binary, etc) in the init of the thin format. I moved that code into the get_ptr, but it was only called the first time. However, the linkage was being done also in init. This would reset the format structure's methods to default dyna. THIS was the bug.
So I pulled that code out and put it into a function. Now get_ptr calls this function after calling the dyna_link function with the 'also call init' flag clear. This will give us our pointer AND set all the methods to be part of the thin. So now things like split/prepare will properly work using the thin methods (if thin overrides them). Then when init is called, the dyna_link is also called settingthe 'also call init' flag to set.