mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #2195] Common 'format' code for .pot chopped handling #1467
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#1467
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 @jfoug on GitHub (Aug 2, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2195
This is an RFC. I have made a branch to look into it.
I think adding a char * field (or 'array' of char * fields) into the format structure would allow loader to deal with validation of chopped .pot lines fully self contained.
But if we are to do this, are there other format items that we want to add (doing them all at one time makes sense to me, even if they are just place holders for a while). Also, are there older format versions which simply need to be dropped, under the assumption that master john has fully incorporated them. I thought we had an issue to do that merge of legacy format versions, but I could not find the issue page.
@jfoug commented on GitHub (Aug 2, 2016):
Here is a first 'version'
4eb0169@jfoug commented on GitHub (Aug 2, 2016):
@magnumripper have all of the *2john utilities already been modified to only emit full inline hashes?
@magnumripper commented on GitHub (Aug 2, 2016):
Can't remember... we need to check that. I'm pretty sure all of them that were using MAX_INLINE_SIZE are fixed.
@jfoug commented on GitHub (Aug 3, 2016):
I am spending this time to 'normalize' formats to all use FORMAT_TAG type defines (and length). NOTE, I do not use tag_length within the format structure, but do a strlen each time. I am not sure that there is too big of a performance hit here.
@magnumripper commented on GitHub (Aug 5, 2016):
A strlen of a constant is extremely likely to be optimized away.
@jfoug commented on GitHub (Aug 6, 2016):
Since it is in one place, and hits non constant data, I seriously doubt it. strlen("this is a test") 'can' be optimized away. But strlen(cp) especially across compile objects must check bytes, looking for a \0
When things are done, I will build a test script that makes .pot files of 10 million lines, and does load time comparisons to see how bad a hit this has. The only ones I really worry all that much about as some of the 'raw' ones, like LM, or raw-md5, etc.
I may simply have to remove the constant strings from these formats, for performance reasons, if it is a problem. Time will tell, once I am done.
But actually having the constant strings 'could' be used to speed things up also. What we may want to do is to add a "" string, for formats that have tags, BUT also allow raw hashes.
One thing I have thought of, is that we have to be DAMN careful to not be too promiscuous in this. If we have more than 1 hash that has the same signature line, for instance the lotus group, that all start with "0x", we need to make sure that we are NOT allowing a valid to be skipped if a hash does not match a format. This issue 'could' kill this PR. But I am hopeful that it can be worked around. This code will ONLY be used when loading from the .pot file, and we 'should' know the format wanted. I just need to make DAMN sure that we do not skip valid and start processing hashes that are NOT valid for a format.
@magnumripper commented on GitHub (Aug 6, 2016):
Is FORMAT_TAG not a constant?
@jfoug commented on GitHub (Aug 6, 2016):
Yes, BUT where it will be accessed is within loader.c So loader will never see a constant. What it sees is a char * value (actually an array of them) within the fmt_main structure. That is where the strlen() calls originate. So loader.c has no way to see the FORMAT_TAG data, nor 'could' it, since it would be different for each format.
@magnumripper commented on GitHub (Aug 6, 2016):
Not sure I follow. The tag is a macro, ie. a constant. The size is a strlen of it and optimized away to a constant. The loader sees that constant length. How/where would it ever become anything else?
Let's put it another way: The macro that says
strlen(FMT_TAG)is local to the format, no?@jfoug commented on GitHub (Aug 6, 2016):
No, it says
What this change does is to remove all of the 'special' logic for chopped pot lines from the formats themselves, and put it into loader. Before, each format that 'might' have chopped lines had to have extra code in it to check the 'is_chopped_pot_line(ct)' early on within valid. I have simply moved that code into loader, so it is 'automatic'. Now, we do not care if line_length changes. Say we drop it to 256. No problem. That one 'central' location for chopped .pot checking will simply handle it, vs having to change a bunch more formats.
BUT I simply have to make sure that the compare is valid. I think that having is_chopped_pot_line checking the 1024 - some bytes and having them be 100% the same, SHOULD make sure that no false valid's make it through. But we have to be pretty sure. NOTE, this strncmp (possibly multiples), and strlen's will be called for all formats, IF they have any values in the fmt.params.signature[] array of char* values.
@jfoug commented on GitHub (Aug 6, 2016):
Look at formats.h and loader.c in this commit for what the real code looks like:
https://github.com/magnumripper/JohnTheRipper/pull/2196/commits/4eb01693b225e2da1922585011aa3b944268511e
NOTE, signature count max is now at 4, not 3, but that commit should show what this change is doing.
@magnumripper commented on GitHub (Aug 6, 2016):
Right. I didn't understand the context fully until now.
@jfoug commented on GitHub (Aug 7, 2016):
#1296 is completed. Now I need to write some scripts to test loading speed to make sure there is not too much overhead here. I do not think there should be much if any overhead, but I want to double check things just to be sure.
What are your ideas on the PR? The first commit is the one to really look at. The rest are mostly normalizing FORMAT_TAG type stuff, and making sure that the formats filled in the signature[] array in the format_main structures.
@jfoug commented on GitHub (Aug 7, 2016):
Ok, testing NT, with 10 million line .pot file, the start time (where the type 'q' to quit), went from 10s to 11-12s Not a significant change IMHO.
rawmd5 was only 4s before and after. I will try it with {md5} tags to make sure that is not slower, since it is the 2nd signature. That one checks out about 4s also.
I see no real performance problems with this change.
@magnumripper commented on GitHub (Aug 7, 2016):
I may agree going from 10 secs to 12 is not the end of the world, but it is a regression. So can we get rid of it? I bet we can. You (or we) should profile the before and after.
@jfoug commented on GitHub (Aug 7, 2016):
I retested, paying a little closer attention this morning, and both of the NT's were right at 10s. The first time I tested, it was the first run of the new method, then immediately followed by a run on current bleeding. this time I 'primed' the pump, loading it first and ignoring time. Then I did a back to back test, and it was 10s each. I think those 2s were the disk read penalty, then the run against bleeding read from cache (thus 2s faster). This time both tests were against cache, and both were right at 10s (just using a wall clock reading. So they are virtually identical.