[GH-ISSUE #837] Mask mode: Truncated (max length) mask give wrong progress/ETA #448

Closed
opened 2026-10-14 03:08:07 +07:00 by bsakaguchi · 57 comments
Owner

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.

$ echo 'mockup:$dummy$09' > pw-dummy 

$ ../run/john pw-dummy -enc:ascii -prog:1 -mask:?l?l?l?l?l?l
Loaded 1 password hash (dummy [N/A])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:01 12.90% (ETA: 16:27:32) 0g/s 39863Kp/s 39863Kc/s 39863KC/s mdcgjd..zjcgjd
0g 0:00:00:01 25.30% (ETA: 16:27:29) 0g/s 39269Kp/s 39269Kc/s 39269KC/s eafapg..rgfapg
0g 0:00:00:02 37.29% (ETA: 16:27:31) 0g/s 38531Kp/s 38531Kc/s 38531KC/s onycsj..buycsj
0g 0:00:00:03 48.85% (ETA: 16:27:32) 0g/s 37821Kp/s 37821Kc/s 37821KC/s medgsm..zkdgsm
0g 0:00:00:04 60.38% (ETA: 16:27:32) 0g/s 37380Kp/s 37380Kc/s 37380KC/s aqresp..nwresp
0g 0:00:00:05 72.32% (ETA: 16:27:32) 0g/s 37295Kp/s 37295Kc/s 37295KC/s gslwus..tylwus
0g 0:00:00:06 84.53% (ETA: 16:27:33) 0g/s 37355Kp/s 37355Kc/s 37355KC/s wkmkzv..jrmkzv
0g 0:00:00:07 95.71% (ETA: 16:27:33) 0g/s 37005Kp/s 37005Kc/s 37005KC/s svjaxy..fckaxy
0g 0:00:00:08 DONE (2014-10-30 16:27) 0g/s 36907Kp/s 36907Kc/s 36907KC/s yvzzzz..zzzzzz
Session completed

$ ../run/john pw-dummy -enc:ascii -prog:1 -mask:?l?l?l?l?l?l?l -max-length=6
Loaded 1 password hash (dummy [N/A])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:01 0.49% (ETA: 16:34:57) 0g/s 39427Kp/s 39427Kc/s 39427KC/s ichhid..vihhid
0g 0:00:00:02 0.99% (ETA: 16:34:56) 0g/s 39576Kp/s 39576Kc/s 39576KC/s ygmfrg..lnmfrg
0g 0:00:00:03 1.48% (ETA: 16:34:56) 0g/s 39718Kp/s 39718Kc/s 39718KC/s cqntak..pwntak
0g 0:00:00:04 1.98% (ETA: 16:34:56) 0g/s 39663Kp/s 39663Kc/s 39663KC/s yovejn..lvvejn
0g 0:00:00:05 2.47% (ETA: 16:34:56) 0g/s 39700Kp/s 39700Kc/s 39700KC/s kvaksq..xbbksq
0g 0:00:00:06 2.97% (ETA: 16:34:56) 0g/s 39757Kp/s 39757Kc/s 39757KC/s kteacu..xzeacu
0g 0:00:00:07 3.47% (ETA: 16:34:55) 0g/s 39818Kp/s 39818Kc/s 39818KC/s afrylx..nlrylx
0g 0:00:00:07 3.85% (ETA: 16:34:37) 0g/s 39808Kp/s 39808Kc/s 39808KC/s yvzzzz..zzzzzz
Session completed

The mask as given is length 7 and mask_tot_cand is not adjusted for the truncation by -max-len.

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. ``` $ echo 'mockup:$dummy$09' > pw-dummy $ ../run/john pw-dummy -enc:ascii -prog:1 -mask:?l?l?l?l?l?l Loaded 1 password hash (dummy [N/A]) Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:01 12.90% (ETA: 16:27:32) 0g/s 39863Kp/s 39863Kc/s 39863KC/s mdcgjd..zjcgjd 0g 0:00:00:01 25.30% (ETA: 16:27:29) 0g/s 39269Kp/s 39269Kc/s 39269KC/s eafapg..rgfapg 0g 0:00:00:02 37.29% (ETA: 16:27:31) 0g/s 38531Kp/s 38531Kc/s 38531KC/s onycsj..buycsj 0g 0:00:00:03 48.85% (ETA: 16:27:32) 0g/s 37821Kp/s 37821Kc/s 37821KC/s medgsm..zkdgsm 0g 0:00:00:04 60.38% (ETA: 16:27:32) 0g/s 37380Kp/s 37380Kc/s 37380KC/s aqresp..nwresp 0g 0:00:00:05 72.32% (ETA: 16:27:32) 0g/s 37295Kp/s 37295Kc/s 37295KC/s gslwus..tylwus 0g 0:00:00:06 84.53% (ETA: 16:27:33) 0g/s 37355Kp/s 37355Kc/s 37355KC/s wkmkzv..jrmkzv 0g 0:00:00:07 95.71% (ETA: 16:27:33) 0g/s 37005Kp/s 37005Kc/s 37005KC/s svjaxy..fckaxy 0g 0:00:00:08 DONE (2014-10-30 16:27) 0g/s 36907Kp/s 36907Kc/s 36907KC/s yvzzzz..zzzzzz Session completed $ ../run/john pw-dummy -enc:ascii -prog:1 -mask:?l?l?l?l?l?l?l -max-length=6 Loaded 1 password hash (dummy [N/A]) Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:01 0.49% (ETA: 16:34:57) 0g/s 39427Kp/s 39427Kc/s 39427KC/s ichhid..vihhid 0g 0:00:00:02 0.99% (ETA: 16:34:56) 0g/s 39576Kp/s 39576Kc/s 39576KC/s ygmfrg..lnmfrg 0g 0:00:00:03 1.48% (ETA: 16:34:56) 0g/s 39718Kp/s 39718Kc/s 39718KC/s cqntak..pwntak 0g 0:00:00:04 1.98% (ETA: 16:34:56) 0g/s 39663Kp/s 39663Kc/s 39663KC/s yovejn..lvvejn 0g 0:00:00:05 2.47% (ETA: 16:34:56) 0g/s 39700Kp/s 39700Kc/s 39700KC/s kvaksq..xbbksq 0g 0:00:00:06 2.97% (ETA: 16:34:56) 0g/s 39757Kp/s 39757Kc/s 39757KC/s kteacu..xzeacu 0g 0:00:00:07 3.47% (ETA: 16:34:55) 0g/s 39818Kp/s 39818Kc/s 39818KC/s afrylx..nlrylx 0g 0:00:00:07 3.85% (ETA: 16:34:37) 0g/s 39808Kp/s 39808Kc/s 39808KC/s yvzzzz..zzzzzz Session completed ``` The mask as given is length 7 and mask_tot_cand is not adjusted for the truncation by -max-len.
bsakaguchi 2026-10-14 03:08:07 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Oct 30, 2014):

Is this anywhere near a valid fix? I don't dare committing it :-)

diff --git a/src/mask.c b/src/mask.c
index 636cbe6..9e913ee 100644
--- a/src/mask.c
+++ b/src/mask.c
@@ -1233,6 +1233,7 @@ static unsigned long long divide_work(cpu_mask_context *cpu_mask_ctx)
        offset = 1;
        for (i = 0; i < cpu_mask_ctx->count; i++)
                if ((int)(cpu_mask_ctx->active_positions[i]))
+               if (cpu_mask_ctx->ranges[i].pos < max_keylen)
                        offset *= cpu_mask_ctx->ranges[i].count;

        total_candidates = offset;
@@ -1393,6 +1394,7 @@ void mask_init(struct db_main *db, char *unprocessed_mask)
                cand = 1;
                for (i = 0; i < cpu_mask_ctx.count; i++)
                        if ((int)(cpu_mask_ctx.active_positions[i]))
+                       if (cpu_mask_ctx.ranges[i].pos < max_keylen)
                                cand *= cpu_mask_ctx.ranges[i].count;
        }
        mask_tot_cand = cand;
<!-- gh-comment-id:61123516 --> @magnumripper commented on GitHub (Oct 30, 2014): Is this anywhere near a valid fix? I don't dare committing it :-) ``` diff --git a/src/mask.c b/src/mask.c index 636cbe6..9e913ee 100644 --- a/src/mask.c +++ b/src/mask.c @@ -1233,6 +1233,7 @@ static unsigned long long divide_work(cpu_mask_context *cpu_mask_ctx) offset = 1; for (i = 0; i < cpu_mask_ctx->count; i++) if ((int)(cpu_mask_ctx->active_positions[i])) + if (cpu_mask_ctx->ranges[i].pos < max_keylen) offset *= cpu_mask_ctx->ranges[i].count; total_candidates = offset; @@ -1393,6 +1394,7 @@ void mask_init(struct db_main *db, char *unprocessed_mask) cand = 1; for (i = 0; i < cpu_mask_ctx.count; i++) if ((int)(cpu_mask_ctx.active_positions[i])) + if (cpu_mask_ctx.ranges[i].pos < max_keylen) cand *= cpu_mask_ctx.ranges[i].count; } mask_tot_cand = cand; ```
Author
Owner

@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.

<!-- gh-comment-id:61124351 --> @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.
Author
Owner

@sayan1an commented on GitHub (Oct 30, 2014):

On Thu, Oct 30, 2014 at 10:08 PM, magnum notifications@github.com wrote:

The really tricky situation is hybrid mode with a mask like
?l?w?l?l?l?l?l. The number of candidates per parent key will vary with its
length.

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61124351
.

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.

<!-- gh-comment-id:61133426 --> @sayan1an commented on GitHub (Oct 30, 2014): On Thu, Oct 30, 2014 at 10:08 PM, magnum notifications@github.com wrote: > The really tricky situation is hybrid mode with a mask like > ?l?w?l?l?l?l?l. The number of candidates per parent key will vary with its > length. > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61124351 > . 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.
Author
Owner

@magnumripper commented on GitHub (Oct 30, 2014):

progress = number of key genrated by parent mode alone / total number of keys generated by parent mode alone.

For that, we'd just set mask_tot_cand to 1. Maybe this is what we should do to start with.

<!-- gh-comment-id:61134499 --> @magnumripper commented on GitHub (Oct 30, 2014): > progress = number of key genrated by parent mode alone / total number of keys generated by parent mode alone. For that, we'd just set mask_tot_cand to 1. Maybe this is what we should do to start with.
Author
Owner

@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.

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)

<!-- gh-comment-id:61134818 --> @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. 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)
Author
Owner

@magnumripper commented on GitHub (Oct 30, 2014):

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.)

This is probably doable. The "hard" work will only be done in get_progress() so isn't very perfomance critical.

<!-- gh-comment-id:61144486 --> @magnumripper commented on GitHub (Oct 30, 2014): > 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.) This is probably doable. The "hard" work will only be done in get_progress() so isn't very perfomance critical.
Author
Owner

@magnumripper commented on GitHub (Oct 30, 2014):

Without considering hybrid mode, the patch would not work with mask like 'aaaa?laa?l'. It is fixable though.

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.

<!-- gh-comment-id:61144817 --> @magnumripper commented on GitHub (Oct 30, 2014): > Without considering hybrid mode, the patch would not work with mask like 'aaaa?laa?l'. It is fixable though. 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.
Author
Owner

@sayan1an 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.

I can get the two variables current number of keys generated by mask mode for the given word and total 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 variable current number of key generated by parent mode alone you could count the number of times do_mask_crack() is called with a valid word.

<!-- gh-comment-id:61148942 --> @sayan1an 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. I can get the two variables `current number of keys generated by mask mode for the given word` and `total 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 variable `current number of key generated by parent mode alone` you could count the number of times do_mask_crack() is called with a valid word.
Author
Owner

@magnumripper commented on GitHub (Oct 30, 2014):

To get the variable current number of key generated by parent mode alone you could count the number of times do_mask_crack() is called with a valid word.

This can easily be accomplished with code in mask.c, and should not hurt performance too much.

<!-- gh-comment-id:61187846 --> @magnumripper commented on GitHub (Oct 30, 2014): > To get the variable current number of key generated by parent mode alone you could count the number of times do_mask_crack() is called with a valid word. This can easily be accomplished with code in mask.c, and should not hurt performance too much.
Author
Owner

@magnumripper commented on GitHub (Oct 31, 2014):

the patch would not work with mask like 'aaaa?laa?l'. It is fixable though.

I can't find a case where it fails (except hybrid mode).

$ ../run/john pw-dummy -enc:ascii -prog:1 -mask:a?lb?lc?ld?l?l?l?l -max-length=10
Loaded 1 password hash (dummy [N/A])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:00 14.98% (ETA: 12:17:08) 0g/s 46730Kp/s 46730Kc/s 46730KC/s agbicedgxd..atbocedgxd
0g 0:00:00:01 29.96% (ETA: 12:17:11) 0g/s 46500Kp/s 46500Kc/s 46500KC/s ambzcydmuh..azbfczdmuh
0g 0:00:00:02 45.02% (ETA: 12:17:12) 0g/s 46515Kp/s 46515Kc/s 46515KC/s aqbgcfdjsl..adbncfdjsl
0g 0:00:00:03 60.20% (ETA: 12:17:12) 0g/s 46610Kp/s 46610Kc/s 46610KC/s aibbcfdzqp..avbhcfdzqp
0g 0:00:00:04 75.36% (ETA: 12:17:13) 0g/s 46651Kp/s 46651Kc/s 46651KC/s awbkctdkpt..ajbrctdkpt
0g 0:00:00:05 90.50% (ETA: 12:17:13) 0g/s 46673Kp/s 46673Kc/s 46673KC/s ambucrdunx..azbacsdunx
0g 0:00:00:06 DONE (2014-10-31 12:17) 0g/s 46734Kp/s 46734Kc/s 46734KC/s aybvczdzzz..azbzczdzzz
Session completed
<!-- gh-comment-id:61247066 --> @magnumripper commented on GitHub (Oct 31, 2014): > the patch would not work with mask like 'aaaa?laa?l'. It is fixable though. I can't find a case where it fails (except hybrid mode). ``` $ ../run/john pw-dummy -enc:ascii -prog:1 -mask:a?lb?lc?ld?l?l?l?l -max-length=10 Loaded 1 password hash (dummy [N/A]) Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:00 14.98% (ETA: 12:17:08) 0g/s 46730Kp/s 46730Kc/s 46730KC/s agbicedgxd..atbocedgxd 0g 0:00:00:01 29.96% (ETA: 12:17:11) 0g/s 46500Kp/s 46500Kc/s 46500KC/s ambzcydmuh..azbfczdmuh 0g 0:00:00:02 45.02% (ETA: 12:17:12) 0g/s 46515Kp/s 46515Kc/s 46515KC/s aqbgcfdjsl..adbncfdjsl 0g 0:00:00:03 60.20% (ETA: 12:17:12) 0g/s 46610Kp/s 46610Kc/s 46610KC/s aibbcfdzqp..avbhcfdzqp 0g 0:00:00:04 75.36% (ETA: 12:17:13) 0g/s 46651Kp/s 46651Kc/s 46651KC/s awbkctdkpt..ajbrctdkpt 0g 0:00:00:05 90.50% (ETA: 12:17:13) 0g/s 46673Kp/s 46673Kc/s 46673KC/s ambucrdunx..azbacsdunx 0g 0:00:00:06 DONE (2014-10-31 12:17) 0g/s 46734Kp/s 46734Kc/s 46734KC/s aybvczdzzz..azbzczdzzz Session completed ```
Author
Owner

@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.

<!-- gh-comment-id:61249247 --> @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.
Author
Owner

@sayan1an commented on GitHub (Oct 31, 2014):

On Fri, Oct 31, 2014 at 5:13 PM, magnum notifications@github.com wrote:

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).

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61249247
.

Yes it is great idea. Does that mean we can remove the max-length check
from mask mode ?

<!-- gh-comment-id:61251121 --> @sayan1an commented on GitHub (Oct 31, 2014): On Fri, Oct 31, 2014 at 5:13 PM, magnum notifications@github.com wrote: > 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). > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61249247 > . > > Yes it is great idea. Does that mean we can remove the max-length check > from mask mode ?
Author
Owner

@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.

<!-- gh-comment-id:61259153 --> @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.
Author
Owner

@sayan1an commented on GitHub (Oct 31, 2014):

On Fri, Oct 31, 2014 at 6:55 PM, frank-dittrich notifications@github.com
wrote:

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.

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61259153
.

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.

<!-- gh-comment-id:61264333 --> @sayan1an commented on GitHub (Oct 31, 2014): On Fri, Oct 31, 2014 at 6:55 PM, frank-dittrich notifications@github.com wrote: > 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. > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61259153 > . 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.
Author
Owner

@frank-dittrich commented on GitHub (Oct 31, 2014):

On 10/31/2014 03:04 PM, Sayantan Datta 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.

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?

<!-- gh-comment-id:61264937 --> @frank-dittrich commented on GitHub (Oct 31, 2014): On 10/31/2014 03:04 PM, Sayantan Datta 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. 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?
Author
Owner

@sayan1an commented on GitHub (Oct 31, 2014):

On Fri, Oct 31, 2014 at 7:39 PM, frank-dittrich notifications@github.com
wrote:

On 10/31/2014 03:04 PM, Sayantan Datta 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.

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?

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61264937
.

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

  • 2)/ 2 = 2.
<!-- gh-comment-id:61266528 --> @sayan1an commented on GitHub (Oct 31, 2014): On Fri, Oct 31, 2014 at 7:39 PM, frank-dittrich notifications@github.com wrote: > On 10/31/2014 03:04 PM, Sayantan Datta 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. > > 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? > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61264937 > . 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 - 2)/ 2 = 2.
Author
Owner

@magnumripper commented on GitHub (Nov 1, 2014):

Yes it is great idea. Does that mean we can remove the max-length check from mask mode ?

Perhaps the hot ones, yes. That's a good side effect!

<!-- gh-comment-id:61361208 --> @magnumripper commented on GitHub (Nov 1, 2014): > Yes it is great idea. Does that mean we can remove the max-length check from mask mode ? Perhaps the hot ones, yes. That's a good side effect!
Author
Owner

@magnumripper commented on GitHub (Nov 1, 2014):

I think we need to export mask_add_len

@Sayantan2048 please implement this, I'm not sure where to get it properly :)

<!-- gh-comment-id:61361363 --> @magnumripper commented on GitHub (Nov 1, 2014): > I think we need to export mask_add_len @Sayantan2048 please implement this, I'm not sure where to get it properly :)
Author
Owner

@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.

<!-- gh-comment-id:61361482 --> @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.
Author
Owner

@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.

<!-- gh-comment-id:61361551 --> @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.
Author
Owner

@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.

<!-- gh-comment-id:61361865 --> @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.
Author
Owner

@sayan1an commented on GitHub (Nov 1, 2014):

On Sat, Nov 1, 2014 at 1:51 PM, magnum notifications@github.com wrote:

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.

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.

<!-- gh-comment-id:61367213 --> @sayan1an commented on GitHub (Nov 1, 2014): On Sat, Nov 1, 2014 at 1:51 PM, magnum notifications@github.com wrote: > 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. 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.
Author
Owner

@sayan1an commented on GitHub (Nov 1, 2014):

On Sat, Nov 1, 2014 at 6:20 PM, Sayantan Datta std2048@gmail.com wrote:

On Sat, Nov 1, 2014 at 1:51 PM, magnum notifications@github.com wrote:

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.

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.

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().

<!-- gh-comment-id:61368053 --> @sayan1an commented on GitHub (Nov 1, 2014): On Sat, Nov 1, 2014 at 6:20 PM, Sayantan Datta std2048@gmail.com wrote: > On Sat, Nov 1, 2014 at 1:51 PM, magnum notifications@github.com wrote: > > > 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. > > 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. Done. Commit 001122d3d592f. 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().
Author
Owner

@magnumripper commented on GitHub (Nov 2, 2014):

Initial work in 8d847e7. mask_num_qw is not yet used.

<!-- gh-comment-id:61428455 --> @magnumripper commented on GitHub (Nov 2, 2014): Initial work in 8d847e7. mask_num_qw is not yet used.
Author
Owner

@magnumripper commented on GitHub (Nov 2, 2014):

mask_num_qw implemented in 3ca37f9. This needs a lot of testing.

<!-- gh-comment-id:61429519 --> @magnumripper commented on GitHub (Nov 2, 2014): mask_num_qw implemented in 3ca37f9. This needs a lot of testing.
Author
Owner

@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.

<!-- gh-comment-id:61429975 --> @magnumripper commented on GitHub (Nov 2, 2014): @Sayantan2048 I committed my fix for the original issue, as stated [above](https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61123516) (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.
Author
Owner

@magnumripper commented on GitHub (Nov 3, 2014):

I get wrong mask_add_len in this case:

$ ../run/john pw-dummy -enc:ascii -prog:1 -inc -mask:?w?d?d?d?d -max-length=7
Loaded 1 password hash (dummy [N/A])
Warning: no OpenMP support for this hash type, consider --fork=8
qw 1 minlen -1 maxlen 7 fmt_len 7 mask_add_len 5
effective minlen -1 maxlen 2 fmt_len 2
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:01 42.75% (ETA: 01:31:59) 0g/s 38988Kp/s 38988Kc/s 38988KC/s 3x0998..3x9519
0g 0:00:00:01 86.03% (ETA: 01:31:59) 0g/s 39429Kp/s 39429Kc/s 39429KC/s :a0814..:a9434
0g 0:00:00:02 DONE (2014-11-03 01:31) 0g/s 39310Kp/s 39310Kc/s 39310KC/s ||0099..||9999
Session completed

mask_add_len is reported as 5 although it should be 4

<!-- gh-comment-id:61431297 --> @magnumripper commented on GitHub (Nov 3, 2014): I get wrong mask_add_len in this case: ``` $ ../run/john pw-dummy -enc:ascii -prog:1 -inc -mask:?w?d?d?d?d -max-length=7 Loaded 1 password hash (dummy [N/A]) Warning: no OpenMP support for this hash type, consider --fork=8 qw 1 minlen -1 maxlen 7 fmt_len 7 mask_add_len 5 effective minlen -1 maxlen 2 fmt_len 2 Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:01 42.75% (ETA: 01:31:59) 0g/s 38988Kp/s 38988Kc/s 38988KC/s 3x0998..3x9519 0g 0:00:00:01 86.03% (ETA: 01:31:59) 0g/s 39429Kp/s 39429Kc/s 39429KC/s :a0814..:a9434 0g 0:00:00:02 DONE (2014-11-03 01:31) 0g/s 39310Kp/s 39310Kc/s 39310KC/s ||0099..||9999 Session completed ``` mask_add_len is reported as 5 although it should be 4
Author
Owner

@sayan1an commented on GitHub (Nov 3, 2014):

On Mon, Nov 3, 2014 at 6:03 AM, magnum notifications@github.com wrote:

I get wrong mask_add_len in this case:

$ ../run/john pw-dummy -enc:ascii -prog:1 -inc -mask:?w?d?d?d?d -max-length=7
Loaded 1 password hash (dummy [N/A])
Warning: no OpenMP support for this hash type, consider --fork=8
qw 1 minlen -1 maxlen 7 fmt_len 7 mask_add_len 5
effective minlen -1 maxlen 2 fmt_len 2
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:01 42.75% (ETA: 01:31:59) 0g/s 38988Kp/s 38988Kc/s 38988KC/s 3x0998..3x9519
0g 0:00:00:01 86.03% (ETA: 01:31:59) 0g/s 39429Kp/s 39429Kc/s 39429KC/s :a0814..:a9434
0g 0:00:00:02 DONE (2014-11-03 01:31) 0g/s 39310Kp/s 39310Kc/s 39310KC/s ||0099..||9999
Session completed

mask_add_len is reported as 5 although it should be 4

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61431297
.

Fixed. Commit e421c24c43.

<!-- gh-comment-id:61435947 --> @sayan1an commented on GitHub (Nov 3, 2014): On Mon, Nov 3, 2014 at 6:03 AM, magnum notifications@github.com wrote: > I get wrong mask_add_len in this case: > > $ ../run/john pw-dummy -enc:ascii -prog:1 -inc -mask:?w?d?d?d?d -max-length=7 > Loaded 1 password hash (dummy [N/A]) > Warning: no OpenMP support for this hash type, consider --fork=8 > qw 1 minlen -1 maxlen 7 fmt_len 7 mask_add_len 5 > effective minlen -1 maxlen 2 fmt_len 2 > Press 'q' or Ctrl-C to abort, almost any other key for status > 0g 0:00:00:01 42.75% (ETA: 01:31:59) 0g/s 38988Kp/s 38988Kc/s 38988KC/s 3x0998..3x9519 > 0g 0:00:00:01 86.03% (ETA: 01:31:59) 0g/s 39429Kp/s 39429Kc/s 39429KC/s :a0814..:a9434 > 0g 0:00:00:02 DONE (2014-11-03 01:31) 0g/s 39310Kp/s 39310Kc/s 39310KC/s ||0099..||9999 > Session completed > > mask_add_len is reported as 5 although it should be 4 > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-61431297 > . > > Fixed. Commit e421c24c432684.
Author
Owner

@magnumripper commented on GitHub (Nov 7, 2014):

Closing this. Will re-test all parent modes and produce new issues if needed.

<!-- gh-comment-id:62231051 --> @magnumripper commented on GitHub (Nov 7, 2014): Closing this. Will re-test all parent modes and produce new issues if needed.
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

3a7fd0f fixes some issues (see discussion in commit)
4aa96eb fixes some more

Remaining issue:

$ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d?d?d?d?d?d?d -max-len=4
qw 1 minlen -1 maxlen 1 fmt_len 125 mask_add_len 3 mask_tot_cand 10000000000

Here, mask_add_len is reduced to 3 so parent mode gets one to use. But mask_tot_cand does not reflect the truncation.

<!-- gh-comment-id:62652080 --> @magnumripper commented on GitHub (Nov 12, 2014): 3a7fd0f fixes some issues (see discussion in commit) 4aa96eb fixes some more Remaining issue: ``` $ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d?d?d?d?d?d?d -max-len=4 qw 1 minlen -1 maxlen 1 fmt_len 125 mask_add_len 3 mask_tot_cand 10000000000 ``` Here, mask_add_len is reduced to 3 so parent mode gets one to use. But mask_tot_cand does not reflect the truncation.
Author
Owner

@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:

            if ((options.flags & FLG_MASK_STACKED) ||
                cpu_mask_ctx.ranges[i].pos < max_keylen)
                cand *= cpu_mask_ctx.ranges[i].count;

we should probably use mask_add_len instead, something like

            if (cpu_mask_ctx.ranges[i].pos < mask_add_len)
                cand *= cpu_mask_ctx.ranges[i].count;

but it doesn't work just like that.

<!-- gh-comment-id:62652761 --> @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: ``` if ((options.flags & FLG_MASK_STACKED) || cpu_mask_ctx.ranges[i].pos < max_keylen) cand *= cpu_mask_ctx.ranges[i].count; ``` we should probably use mask_add_len instead, something like ``` if (cpu_mask_ctx.ranges[i].pos < mask_add_len) cand *= cpu_mask_ctx.ranges[i].count; ``` but it doesn't work just like that.
Author
Owner

@sayan1an commented on GitHub (Nov 12, 2014):

On Wed, Nov 12, 2014 at 6:28 AM, magnum notifications@github.com wrote:

@Sayantan2048 https://github.com/Sayantan2048 maybe truncate_mask()
should decrease mask_tot_cand? Or something else is wrong. Actually for
things like this:

        if ((options.flags & FLG_MASK_STACKED) ||
            cpu_mask_ctx.ranges[i].pos < max_keylen)
            cand *= cpu_mask_ctx.ranges[i].count;

we should probably use mask_add_len instead, something like

        if (cpu_mask_ctx.ranges[i].pos < mask_add_len)
            cand *= cpu_mask_ctx.ranges[i].count;

but it doesn't work just like that.

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-62652761
.

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.

<!-- gh-comment-id:62662862 --> @sayan1an commented on GitHub (Nov 12, 2014): On Wed, Nov 12, 2014 at 6:28 AM, magnum notifications@github.com wrote: > @Sayantan2048 https://github.com/Sayantan2048 maybe truncate_mask() > should decrease mask_tot_cand? Or something else is wrong. Actually for > things like this: > > ``` > if ((options.flags & FLG_MASK_STACKED) || > cpu_mask_ctx.ranges[i].pos < max_keylen) > cand *= cpu_mask_ctx.ranges[i].count; > ``` > > we should probably use mask_add_len instead, something like > > ``` > if (cpu_mask_ctx.ranges[i].pos < mask_add_len) > cand *= cpu_mask_ctx.ranges[i].count; > ``` > > but it doesn't work just like that. > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-62652761 > . 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.
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

$ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d?d?d?d?d?d?d -max-len=4
qw 1 minlen -1 maxlen 1 fmt_len 125 mask_add_len 3 mask_tot_cand 10000000000
95000p 0:00:00:00 0.00% 380000p/s |999

The correct number of candidates are produced, it's just mask_tot_cand that is wrong.

<!-- gh-comment-id:62683132 --> @magnumripper commented on GitHub (Nov 12, 2014): ``` $ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d?d?d?d?d?d?d -max-len=4 qw 1 minlen -1 maxlen 1 fmt_len 125 mask_add_len 3 mask_tot_cand 10000000000 95000p 0:00:00:00 0.00% 380000p/s |999 ``` The correct number of candidates are produced, it's just mask_tot_cand that is wrong.
Author
Owner

@sayan1an commented on GitHub (Nov 12, 2014):

On Wed, Nov 12, 2014 at 1:37 PM, magnum notifications@github.com wrote:

john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d?d?d?d?d?d?d -max-len=4

Fixed. commit d451370747

<!-- gh-comment-id:62726771 --> @sayan1an commented on GitHub (Nov 12, 2014): On Wed, Nov 12, 2014 at 1:37 PM, magnum notifications@github.com wrote: > john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d?d?d?d?d?d?d -max-len=4 Fixed. commit d4513707474aa438c
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

For some reason I do not quite understand, d451370 broke several other uses:

$ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d -max-len=5
950000p 0:00:00:00 100.00% (2014-11-13 00:05) 3518Kp/s |9999

$ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d -max-len=6
950000p 0:00:00:00 100.00% (2014-11-13 00:05) 3392Kp/s |9999

$ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d -max-len=7
950000p 0:00:00:00 100.00% (2014-11-13 00:05) 3392Kp/s |9999

$ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d -max-len=8
950000p 0:00:00:00 100.00% (2014-11-13 00:05) 3518Kp/s |9999

$ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w         
0p 0:00:00:00 0.00% 0p/s
<!-- gh-comment-id:62812253 --> @magnumripper commented on GitHub (Nov 12, 2014): For some reason I do not quite understand, d451370 broke several other uses: ``` $ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d -max-len=5 950000p 0:00:00:00 100.00% (2014-11-13 00:05) 3518Kp/s |9999 $ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d -max-len=6 950000p 0:00:00:00 100.00% (2014-11-13 00:05) 3392Kp/s |9999 $ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d -max-len=7 950000p 0:00:00:00 100.00% (2014-11-13 00:05) 3392Kp/s |9999 $ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w?d?d?d?d -max-len=8 950000p 0:00:00:00 100.00% (2014-11-13 00:05) 3518Kp/s |9999 $ ../run/john -inc -stdout -verb=1 -prog=1 -mask=?w 0p 0:00:00:00 0.00% 0p/s ```
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

For some reason I do not quite understand, d451370 broke several other uses:

No, sorry. It wasn't that commit that broke it. Must be 4aa96eba

<!-- gh-comment-id:62812647 --> @magnumripper commented on GitHub (Nov 12, 2014): > For some reason I do not quite understand, d451370 broke several other uses: No, sorry. It wasn't that commit that broke it. Must be 4aa96eba
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

OK, this is what makes it fail

diff --git b/src/mask.c a/src/mask.c
index 1c38c4d..35b66ae 100644
--- b/src/mask.c
+++ a/src/mask.c
@@ -1505,8 +1505,10 @@ void mask_init(struct db_main *db, char *unprocessed_mask)
                        mask_add_len++;
                }
        }
-       if (mask_add_len > max_keylen)
-               mask_add_len = max_keylen;
+       if (mask_add_len >
+           (options.flags & FLG_MASK_STACKED) ? max_keylen - 1 : max_keylen)
+               mask_add_len = (options.flags & FLG_MASK_STACKED) ?
+                       max_keylen - 1 : max_keylen;

        if ((options.flags & FLG_MASK_STACKED) && mask_num_qw == 0) {
                if (john_main_process)

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.

<!-- gh-comment-id:62813602 --> @magnumripper commented on GitHub (Nov 12, 2014): OK, this is what makes it fail ``` diff --git b/src/mask.c a/src/mask.c index 1c38c4d..35b66ae 100644 --- b/src/mask.c +++ a/src/mask.c @@ -1505,8 +1505,10 @@ void mask_init(struct db_main *db, char *unprocessed_mask) mask_add_len++; } } - if (mask_add_len > max_keylen) - mask_add_len = max_keylen; + if (mask_add_len > + (options.flags & FLG_MASK_STACKED) ? max_keylen - 1 : max_keylen) + mask_add_len = (options.flags & FLG_MASK_STACKED) ? + max_keylen - 1 : max_keylen; if ((options.flags & FLG_MASK_STACKED) && mask_num_qw == 0) { if (john_main_process) ``` 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.
Author
Owner

@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.

<!-- gh-comment-id:62815093 --> @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.
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

This makes sense now

$ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=1
Too short max-length for hybrid mask
$ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=2
360p 0:00:00:00 100.00% (2014-11-13 00:33) 1636p/s 9z
$ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=3
2600p 0:00:00:00 100.00% (2014-11-13 00:33) 11818p/s 9z9
$ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=4
26000p 0:00:00:00 100.00% (2014-11-13 00:33) 118181p/s 9z99
$ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=5
260000p 0:00:00:00 100.00% (2014-11-13 00:33) 1083Kp/s 9z999
$ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=6
7020000p 0:00:00:00 100.00% (2014-11-13 00:33) 12103Kp/s 9xq999
$ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=7
182790000p 0:00:00:10 100.00% (2014-11-13 00:34) 17729Kp/s 9xqj999
<!-- gh-comment-id:62815542 --> @magnumripper commented on GitHub (Nov 12, 2014): This makes sense now ``` $ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=1 Too short max-length for hybrid mask $ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=2 360p 0:00:00:00 100.00% (2014-11-13 00:33) 1636p/s 9z $ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=3 2600p 0:00:00:00 100.00% (2014-11-13 00:33) 11818p/s 9z9 $ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=4 26000p 0:00:00:00 100.00% (2014-11-13 00:33) 118181p/s 9z99 $ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=5 260000p 0:00:00:00 100.00% (2014-11-13 00:33) 1083Kp/s 9z999 $ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=6 7020000p 0:00:00:00 100.00% (2014-11-13 00:33) 12103Kp/s 9xq999 $ ../run/john -stdout -verb=1 -inc:lower -mask=?d?w?d?d?d -max-len=7 182790000p 0:00:00:10 100.00% (2014-11-13 00:34) 17729Kp/s 9xqj999 ```
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

Here is another issue we need to consider.

$ ../run/john -stdout -verb=1 -mask=?d?d?d?d?d -max-len=6
100000p 0:00:00:00 100.00% (2014-11-13 00:35) 400000p/s 99999

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.

<!-- gh-comment-id:62815873 --> @magnumripper commented on GitHub (Nov 12, 2014): Here is another issue we need to consider. ``` $ ../run/john -stdout -verb=1 -mask=?d?d?d?d?d -max-len=6 100000p 0:00:00:00 100.00% (2014-11-13 00:35) 400000p/s 99999 ``` 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.
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

Actually I'm not even sure we should warn at all.

@frank-dittrich what's your opinion?

<!-- gh-comment-id:62816183 --> @magnumripper commented on GitHub (Nov 12, 2014): > Actually I'm not even sure we should warn at all. @frank-dittrich what's your opinion?
Author
Owner

@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:

../run/john -mask=?l -min-len=1 -max-len=8

...and it would produce anything from "a" to "zzzzzzzz".

<!-- gh-comment-id:62816658 --> @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: ``` ../run/john -mask=?l -min-len=1 -max-len=8 ``` ...and it would produce anything from "a" to "zzzzzzzz".
Author
Owner

@frank-dittrich commented on GitHub (Nov 12, 2014):

Actually I'm not even sure we should warn at all.

@frank-dittrich https://github.com/frank-dittrich what's your opinion?

I don't really care.

<!-- gh-comment-id:62817452 --> @frank-dittrich commented on GitHub (Nov 12, 2014): > ``` > Actually I'm not even sure we should warn at all. > ``` > > @frank-dittrich https://github.com/frank-dittrich what's your opinion? I don't really care.
Author
Owner

@magnumripper commented on GitHub (Nov 13, 2014):

I added that in c158314.

$ ../run/john -stdout -verb=1 -mask=?d?d?d?d?d -max-len=6
Warning: mask is shorter than -max-length parameter
100000p 0:00:00:00 100.00% (2014-11-13 00:57) 434782p/s 99999

$ ../run/john -stdout=6 -verb=1 -mask=?d?d?d?d?d 
100000p 0:00:00:00 100.00% (2014-11-13 00:58) 454545p/s 99999

$ ../run/john -stdout=6 -verb=1 -mask=?d?d?d?d?d -max-len=6
Warning: mask is shorter than -max-length parameter
100000p 0:00:00:00 100.00% (2014-11-13 00:59) 454545p/s 99999

Note: -stdout=N is equivalent to a format's max length of N.

<!-- gh-comment-id:62818539 --> @magnumripper commented on GitHub (Nov 13, 2014): I added that in c158314. ``` $ ../run/john -stdout -verb=1 -mask=?d?d?d?d?d -max-len=6 Warning: mask is shorter than -max-length parameter 100000p 0:00:00:00 100.00% (2014-11-13 00:57) 434782p/s 99999 $ ../run/john -stdout=6 -verb=1 -mask=?d?d?d?d?d 100000p 0:00:00:00 100.00% (2014-11-13 00:58) 454545p/s 99999 $ ../run/john -stdout=6 -verb=1 -mask=?d?d?d?d?d -max-len=6 Warning: mask is shorter than -max-length parameter 100000p 0:00:00:00 100.00% (2014-11-13 00:59) 454545p/s 99999 ``` Note: -stdout=N is equivalent to a format's max length of N.
Author
Owner

@magnumripper commented on GitHub (Nov 13, 2014):

I am closing this until I see any new problems.

<!-- gh-comment-id:62819955 --> @magnumripper commented on GitHub (Nov 13, 2014): I am closing this until I see any new problems.
Author
Owner

@sayan1an commented on GitHub (Nov 13, 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:

../run/john -mask=?l -min-len=1 -max-len=8

...and it would produce anything from "a" to "zzzzzzzz".

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 ?

<!-- gh-comment-id:62832236 --> @sayan1an commented on GitHub (Nov 13, 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: > > ../run/john -mask=?l -min-len=1 -max-len=8 > > ...and it would produce anything from "a" to "zzzzzzzz". 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 ?
Author
Owner

@magnumripper commented on GitHub (Nov 13, 2014):

Yes, please do. Note that it only applies to pure mask mode.

<!-- gh-comment-id:62868159 --> @magnumripper commented on GitHub (Nov 13, 2014): Yes, please do. Note that it only applies to pure mask mode.
Author
Owner

@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:

Yes, please do. Note that it only applies to pure mask mode.

—
Reply to this email directly or view it on GitHub
https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-62868159
.

<!-- gh-comment-id:63158041 --> @sayan1an commented on GitHub (Nov 15, 2014): Done. Commit 78212ea68d89b8. Please test. On Thu, Nov 13, 2014 at 3:35 PM, magnum notifications@github.com wrote: > Yes, please do. Note that it only applies to pure mask mode. > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/837#issuecomment-62868159 > .
Author
Owner

@magnumripper commented on GitHub (Nov 17, 2014):

Doesn't seem to work for me

$ ../run/john -mask=?l -min-len=1 -max-len=8 -stdout
Can't nest custom placeholder ??.

$ ../run/john -mask=?d -min-len=3 -max-len=3 -stdout
Warning: mask is shorter than -max-length parameter
0
1
2
3
4
5
6
7
8
9
10p 0:00:00:00 100.00% (2014-11-17 08:37) 43.47p/s 9
<!-- gh-comment-id:63269344 --> @magnumripper commented on GitHub (Nov 17, 2014): Doesn't seem to work for me ``` $ ../run/john -mask=?l -min-len=1 -max-len=8 -stdout Can't nest custom placeholder ??. $ ../run/john -mask=?d -min-len=3 -max-len=3 -stdout Warning: mask is shorter than -max-length parameter 0 1 2 3 4 5 6 7 8 9 10p 0:00:00:00 100.00% (2014-11-17 08:37) 43.47p/s 9 ```
Author
Owner

@frank-dittrich commented on GitHub (Nov 17, 2014):

Should we support a --min-length that is greater than the length of the mask?

<!-- gh-comment-id:63270390 --> @frank-dittrich commented on GitHub (Nov 17, 2014): Should we support a --min-length that is greater than the length of the mask?
Author
Owner

@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

<!-- gh-comment-id:63270801 --> @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
Author
Owner

@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

$ ../run/john -1=?d -mask=?1 -stdout -min-len=2 -max-len=3 | tail
Press 'q' or Ctrl-C to abort, almost any other key for status
900p 0:00:00:00 100.00% (2014-11-17 09:03) 3913p/s 99ÿ
09ÿ
19ÿ
29ÿ
39ÿ
49ÿ
59ÿ
69ÿ
79ÿ
89ÿ
99ÿ
<!-- gh-comment-id:63271296 --> @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 ``` $ ../run/john -1=?d -mask=?1 -stdout -min-len=2 -max-len=3 | tail Press 'q' or Ctrl-C to abort, almost any other key for status 900p 0:00:00:00 100.00% (2014-11-17 09:03) 3913p/s 99ÿ 09ÿ 19ÿ 29ÿ 39ÿ 49ÿ 59ÿ 69ÿ 79ÿ 89ÿ 99ÿ ```
Author
Owner

@magnumripper commented on GitHub (Nov 17, 2014):

OK, that problem is only with custom placeholder. This works:

$ ../run/john -mask=?d -stdout -min-len=2 -max-len=3 | tail
Press 'q' or Ctrl-C to abort, almost any other key for status
1100p 0:00:00:00 100.00% (2014-11-17 09:07) 4782p/s 999
099
199
299
399
499
599
699
799
899
999

Yet I think it should not depend on -min-len being used at all. Or do we get weird side effects otherwise?

<!-- gh-comment-id:63271444 --> @magnumripper commented on GitHub (Nov 17, 2014): OK, that problem is only with custom placeholder. This works: ``` $ ../run/john -mask=?d -stdout -min-len=2 -max-len=3 | tail Press 'q' or Ctrl-C to abort, almost any other key for status 1100p 0:00:00:00 100.00% (2014-11-17 09:07) 4782p/s 999 099 199 299 399 499 599 699 799 899 999 ``` Yet I think it should not depend on -min-len being used at all. Or do we get weird side effects otherwise?
Author
Owner

@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 ?

<!-- gh-comment-id:63281581 --> @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 ?
Author
Owner

@sayan1an commented on GitHub (Nov 17, 2014):

On Mon, Nov 17, 2014 at 3:24 PM, Sayantan Datta std2048@gmail.com wrote:

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 ?

You may control when stretch_mask() is called by adjusting line 1574 and
1714.

<!-- gh-comment-id:63281899 --> @sayan1an commented on GitHub (Nov 17, 2014): On Mon, Nov 17, 2014 at 3:24 PM, Sayantan Datta std2048@gmail.com wrote: > 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 ? > > You may control when stretch_mask() is called by adjusting line 1574 and > 1714.
Author
Owner

@magnumripper commented on GitHub (Nov 17, 2014):

I noticed that using -min-len=3 and -max-len=3 produces all candidates of length 1,2 and 3. Is
this behavior expected ?

I can't see how/why that would happen. I'll have a look at it.

<!-- gh-comment-id:63336403 --> @magnumripper commented on GitHub (Nov 17, 2014): > I noticed that using -min-len=3 and -max-len=3 produces all candidates of length 1,2 and 3. Is > this behavior expected ? I can't see how/why that would happen. I'll have a look at it.
Author
Owner

@magnumripper commented on GitHub (Nov 17, 2014):

Fixed in 1488ab9

<!-- gh-comment-id:63337749 --> @magnumripper commented on GitHub (Nov 17, 2014): Fixed in 1488ab9
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#448
No description provided.