mirror of
https://github.com/openwall/john.git
synced 2026-12-03 20:43:49 +07:00
[GH-ISSUE #837] Mask mode: Truncated (max length) mask give wrong progress/ETA #448
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#448
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 (Oct 30, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/837
Originally assigned to: @sayan1an on GitHub.
The mask as given is length 7 and mask_tot_cand is not adjusted for the truncation by -max-len.
@magnumripper commented on GitHub (Oct 30, 2014):
Is this anywhere near a valid fix? I don't dare committing it :-)
@magnumripper commented on GitHub (Oct 30, 2014):
The really tricky situation is hybrid mode with a mask like ?l?w?l?l?l?l?l and a fairly short max key length. The number of candidates per key will vary with each parent-key's length. Yet we do not want a performance hit (this is merely a cosmetic issue after all) so we might need to make assumptions and give a "best-effort" figure. Perhaps something like assume a parent key length of 8.
@sayan1an commented on GitHub (Oct 30, 2014):
On Thu, Oct 30, 2014 at 10:08 PM, magnum notifications@github.com wrote:
Without considering hybrid mode, the patch would not work with mask like
'aaaa?laa?l'. It is fixable though.
For hybrid mode, it is tricky indeed and I don't see a quick solution to
the problem as it will be difficult or impossible(in case of wordlist mode)
to predict the size of the words beforehand.
So to fix progress reporting for hybrid mode, I suggest we drop the
contrbution of mask mode entirely. I have something like this in mind:
progress = number of key genrated by parent mode alone / total number of
keys generated by parent mode alone.
Or do something like this for more accurate progress reporting:
fract = 1/total number of keys generated by parent mode.
progress = current number of key generated by parent mode alone / total
number of keys generated by parent mode alone + frac * (current number of
keys generated by mask mode for the given word / total number of keys
generated by mask mode for given word.)
The difficult part is to find the two numerator i.e the current number of
keys generated by both modes separately.
@magnumripper commented on GitHub (Oct 30, 2014):
For that, we'd just set mask_tot_cand to 1. Maybe this is what we should do to start with.
@magnumripper commented on GitHub (Oct 30, 2014):
Hmm no it might not be that easy. A couple of modes use the actual total candidates generated, and divide it with (parent_mode_total * mask_tot_cand)
@magnumripper commented on GitHub (Oct 30, 2014):
This is probably doable. The "hard" work will only be done in get_progress() so isn't very perfomance critical.
@magnumripper commented on GitHub (Oct 30, 2014):
I thought it would, I tested it a little with masks like that. But I confess there was a slight discrepancy I could not account for.
@sayan1an commented on GitHub (Oct 30, 2014):
I can get the two variables
current number of keys generated by mask mode for the given wordandtotal number of keys generated by mask mode for given word.. But you'll need to get the other two variables form the parent mode. To get the variablecurrent number of key generated by parent mode aloneyou could count the number of times do_mask_crack() is called with a valid word.@magnumripper commented on GitHub (Oct 30, 2014):
This can easily be accomplished with code in mask.c, and should not hurt performance too much.
@magnumripper commented on GitHub (Oct 31, 2014):
I can't find a case where it fails (except hybrid mode).
@magnumripper commented on GitHub (Oct 31, 2014):
I think we need to export mask_add_len or something like that, telling the parent mode how much mask mode will increase the key length.
Using
-inc:digits -mask:?l?l?w -max-len=10, the mask_add_len would be 2 (we are adding 2 characters to each input word) and max-len for incremental should be decreased to 8 (normal max len - mask_add_len). So inc would be producing max length 8 and hybrid would be producing max length 10.This mask_add_len must always be < max_keylen though. So for an overlong mask (longer than will be used) and -max-len=10 we could report 9. But I'm not sure this is exactly what we want.
@sayan1an commented on GitHub (Oct 31, 2014):
On Fri, Oct 31, 2014 at 5:13 PM, magnum notifications@github.com wrote:
@frank-dittrich commented on GitHub (Oct 31, 2014):
But for modes with input words of varying kength, the number of characters to be appendend by mask mode varies as well.
with --mask=1?w2?a34?l, there is even a huge variation in how many candidates mask mode will generate per input word.
@sayan1an commented on GitHub (Oct 31, 2014):
On Fri, Oct 31, 2014 at 6:55 PM, frank-dittrich notifications@github.com
wrote:
I was referring to any generic mask such as 1?w2?a?w34?l. When we export
mask_add_len we calculate it as (net_mask_length_including_?w - number of
?w). That way we take into account the length perpended, appended or in
between ?w placeholders. So the parent mode only sends those words which
can fit into the max-length restriction.
Indirectly it also solves the problem of ETA calculation as mask mode
always generates fixed number of candidates.
@frank-dittrich commented on GitHub (Oct 31, 2014):
On 10/31/2014 03:04 PM, Sayantan Datta wrote:
That means, even if max. length is just 1 more than the length of the
current word, mask mode will produce 95*26 candidates which after
cutting to max. length will all be the same?
@sayan1an commented on GitHub (Oct 31, 2014):
On Fri, Oct 31, 2014 at 7:39 PM, frank-dittrich notifications@github.com
wrote:
I meant it in the reverse sense. In this case, say max-length=10,
total_net_mask_len_including_?w = 8, number_of_?w = 2. So the parent mode
is only allowed to send words to mask mode having max length of (max-len -
(total_net_mask_len_including_?w - number_of_?w)) / number_of_?w = (10 - 8
@magnumripper commented on GitHub (Nov 1, 2014):
Perhaps the hot ones, yes. That's a good side effect!
@magnumripper commented on GitHub (Nov 1, 2014):
@Sayantan2048 please implement this, I'm not sure where to get it properly :)
@magnumripper commented on GitHub (Nov 1, 2014):
Note that if -max-len=10 and mask is abc?l?w?w?l, we export mask_add_len of 5 and incremental will produce max-len of 5. Mask mode still need to truncate or we'd be ending up with length 15.
@magnumripper commented on GitHub (Nov 1, 2014):
Another way to implement it is to export max_parent_len. For a max total length of 10 and a mask of abc?l?w?w?l we'd have a max_parent_len of 2.5, rounded to 2. This may or may not be better, I'm not sure.
@magnumripper commented on GitHub (Nov 1, 2014):
Just thinking loud. For non hybrid masks, you can use a fixed (eg john.conf default) overlength mask, eg. ?l?l?l?l?l?l?l?l?l?l?l?l?l and just vary max-len for different runs to produce short or long words. This will not be possible for hybrid mode if we implement the above but it's probably not a problem.
@sayan1an commented on GitHub (Nov 1, 2014):
On Sat, Nov 1, 2014 at 1:51 PM, magnum notifications@github.com wrote:
We'd implement another variable number_of_?w and use it to divide the
max_len. i.e incremental_max_len = (input_max_len - mask_add_len) /
number_of_?w. = (10-5)/2 = 2.5 or rounded to 2. That way we won't need to
truncate.
@sayan1an commented on GitHub (Nov 1, 2014):
On Sat, Nov 1, 2014 at 6:20 PM, Sayantan Datta std2048@gmail.com wrote:
Done. Commit
001122d3d5.I'll add a non-hybrid-mask static max-length truncate in mask_init() after
you re-configure the parent modes. Also remove the max-length truncation
from do_mask_crack().
@magnumripper commented on GitHub (Nov 2, 2014):
Initial work in
8d847e7. mask_num_qw is not yet used.@magnumripper commented on GitHub (Nov 2, 2014):
mask_num_qw implemented in
3ca37f9. This needs a lot of testing.@magnumripper commented on GitHub (Nov 2, 2014):
@Sayantan2048 I committed my fix for the original issue, as stated above (along with other minor things), in
de613585. If it's not the right fix, just change it. Maybe it's obsoleted by the truncation you are about to add.@magnumripper commented on GitHub (Nov 3, 2014):
I get wrong mask_add_len in this case:
mask_add_len is reported as 5 although it should be 4
@sayan1an commented on GitHub (Nov 3, 2014):
On Mon, Nov 3, 2014 at 6:03 AM, magnum notifications@github.com wrote:
@magnumripper commented on GitHub (Nov 7, 2014):
Closing this. Will re-test all parent modes and produce new issues if needed.
@magnumripper commented on GitHub (Nov 12, 2014):
3a7fd0ffixes some issues (see discussion in commit)4aa96ebfixes some moreRemaining issue:
Here, mask_add_len is reduced to 3 so parent mode gets one to use. But mask_tot_cand does not reflect the truncation.
@magnumripper commented on GitHub (Nov 12, 2014):
@Sayantan2048 maybe truncate_mask() should decrease mask_tot_cand? Or something else is wrong. Actually for things like this:
we should probably use mask_add_len instead, something like
but it doesn't work just like that.
@sayan1an commented on GitHub (Nov 12, 2014):
On Wed, Nov 12, 2014 at 6:28 AM, magnum notifications@github.com wrote:
Before moving on to a fix, I would like to be clear on what's going on.
After adjusting for mask_add_len, if options.force_maxlen is 1, then it
means mask must be truncated and we should adjust mask_tot_len. Otherwise,
there is no need to adjust mask_tot_candidate.
The above patch may not be a valid fix, as cpu_mask_ctx.ranges[i].pos also
includes length of '?w' as static placeholders. The actual position is
cpu_mask_ctx.ranges[i].pos + cpu_mask_ctx.ranges[i].offset. Unfortunately,
the offset is only calculated in generate_template_keys(). So, I think,
truncate_mask would be the right place to do it.
@magnumripper commented on GitHub (Nov 12, 2014):
The correct number of candidates are produced, it's just mask_tot_cand that is wrong.
@sayan1an commented on GitHub (Nov 12, 2014):
On Wed, Nov 12, 2014 at 1:37 PM, magnum notifications@github.com wrote:
Fixed. commit
d451370747@magnumripper commented on GitHub (Nov 12, 2014):
For some reason I do not quite understand,
d451370broke several other uses:@magnumripper commented on GitHub (Nov 12, 2014):
No, sorry. It wasn't that commit that broke it. Must be
4aa96eba@magnumripper commented on GitHub (Nov 12, 2014):
OK, this is what makes it fail
I really do not understand why. The rationale of this change is to leave at least one character for the parent mode to fill in.
@magnumripper commented on GitHub (Nov 12, 2014):
Fixed in
b61bd73. Must have been some missing paren but I re-worked it to be more readable as well, and also added a bailout in case -max-len is less than 2 in hybrid mode. That's not allowed - we must get at least one character from parent and one from mask or hybrid mode would be useless.@magnumripper commented on GitHub (Nov 12, 2014):
This makes sense now
@magnumripper commented on GitHub (Nov 12, 2014):
Here is another issue we need to consider.
If we gave a -max-len (as opposed to fmt_maxlen) that is longer than the given mask, we could opt to warn. I do not think we should bail out. Actually I'm not even sure we should warn at all.
@magnumripper commented on GitHub (Nov 12, 2014):
@frank-dittrich what's your opinion?
@magnumripper commented on GitHub (Nov 12, 2014):
A handy (but perhaps confusing) feature for this situation would be to re-use the last placeholder (or character, or whatever was last in mask) to fill the missing space. That way, you could do this:
...and it would produce anything from "a" to "zzzzzzzz".
@frank-dittrich commented on GitHub (Nov 12, 2014):
I don't really care.
@magnumripper commented on GitHub (Nov 13, 2014):
I added that in
c158314.Note: -stdout=N is equivalent to a format's max length of N.
@magnumripper commented on GitHub (Nov 13, 2014):
I am closing this until I see any new problems.
@sayan1an commented on GitHub (Nov 13, 2014):
We can do this by adding the extra placeholders at the end of mask before beginng the parsing sequence and the best part is, it shouldn't add any extra overhead(to the performance critical section). Do we want to implement it ?
@magnumripper commented on GitHub (Nov 13, 2014):
Yes, please do. Note that it only applies to pure mask mode.
@sayan1an commented on GitHub (Nov 15, 2014):
Done. Commit
78212ea68d. Please test.On Thu, Nov 13, 2014 at 3:35 PM, magnum notifications@github.com wrote:
@magnumripper commented on GitHub (Nov 17, 2014):
Doesn't seem to work for me
@frank-dittrich commented on GitHub (Nov 17, 2014):
Should we support a --min-length that is greater than the length of the mask?
@magnumripper commented on GitHub (Nov 17, 2014):
The -min-len was redundant in that last example but the -max-len=3 should have expanded the mask to ?d?d?d
@magnumripper commented on GitHub (Nov 17, 2014):
I see now it doesn't kick in unless min is used and smaller than (as opposed to same as) max. Even then, it fills the mask with wrong stuff
@magnumripper commented on GitHub (Nov 17, 2014):
OK, that problem is only with custom placeholder. This works:
Yet I think it should not depend on -min-len being used at all. Or do we get weird side effects otherwise?
@sayan1an commented on GitHub (Nov 17, 2014):
Although the above problems have been fixed, I noticed that using
-min-len=3 and -max-len=3 produces all candidates of length 1,2 and 3. Is
this behavior expected ?
@sayan1an commented on GitHub (Nov 17, 2014):
On Mon, Nov 17, 2014 at 3:24 PM, Sayantan Datta std2048@gmail.com wrote:
@magnumripper commented on GitHub (Nov 17, 2014):
I can't see how/why that would happen. I'll have a look at it.
@magnumripper commented on GitHub (Nov 17, 2014):
Fixed in
1488ab9