[GH-ISSUE #380] Mask mode should honour --min-len and --max-len #117

Closed
opened 2026-10-14 02:53:23 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @magnumripper on GitHub (Sep 30, 2013).
Original GitHub issue: https://github.com/openwall/john/issues/380

Originally assigned to: @sayan1an on GitHub.

For example, using --mask=?l?l?l?l?l?l?l?l -min-len=1 should exhaust ?l then exhaust ?l?l and so on.

If --max-len is longer than mask, eg. using --mask=?l?d --max-len=7 I think we can repeat the mask (either whole, effectively ?l?d?l?d?l?d?l - or just repeat last mask as in ?l?d?d?d?d?d?d) and default to a --min-len of 2 because that's the length of original mask.

This way we can brute force from 1 to 8 chars just using --mask=?a --max-len=8

Originally created by @magnumripper on GitHub (Sep 30, 2013). Original GitHub issue: https://github.com/openwall/john/issues/380 Originally assigned to: @sayan1an on GitHub. For example, using `--mask=?l?l?l?l?l?l?l?l -min-len=1` should exhaust ?l then exhaust ?l?l and so on. If --max-len is longer than mask, eg. using `--mask=?l?d --max-len=7` I think we can repeat the mask (either whole, effectively `?l?d?l?d?l?d?l` - or just repeat last mask as in `?l?d?d?d?d?d?d`) and default to a --min-len of 2 because that's the length of original mask. This way we can brute force from 1 to 8 chars just using `--mask=?a --max-len=8`
bsakaguchi 2026-10-14 02:53:23 +07:00
Author
Owner

@magnumripper commented on GitHub (Sep 30, 2013):

Not sure how to handle cases like --mask=pass?d?dword?d?d --min-len=10 --max-len=14though.

At length 10, we'd probably want "pass?d?dword"
At length 11, we'd probably want "pass?d?dword?d"

At length 13, we could produce "pass?d?d?dword?d?d" or "pass?d?dword?d?d?d" - or both! But a simpler approach to handle --max-len exceeding mask input length is to simply disallow it.

<!-- gh-comment-id:25412284 --> @magnumripper commented on GitHub (Sep 30, 2013): Not sure how to handle cases like `--mask=pass?d?dword?d?d --min-len=10 --max-len=14`though. At length 10, we'd probably want "pass?d?dword" At length 11, we'd probably want "pass?d?dword?d" At length 13, we could produce "pass?d?d?dword?d?d" or "pass?d?dword?d?d?d" - or both! But a simpler approach to handle --max-len exceeding mask input length is to simply disallow it.
Author
Owner

@ukasz commented on GitHub (Sep 30, 2013):

You're trying to suggest something similar to --incremental option of hashcat:
http://hashcat.net/wiki/doku.php?id=mask_attack#password_length_increment

<!-- gh-comment-id:25412898 --> @ukasz commented on GitHub (Sep 30, 2013): You're trying to suggest something similar to --incremental option of hashcat: http://hashcat.net/wiki/doku.php?id=mask_attack#password_length_increment
Author
Owner

@magnumripper commented on GitHub (Jan 11, 2014):

The very minimum fix before releasing Jumbo-1 would be to bug out if min or max length is requested with mask mode.

<!-- gh-comment-id:32083654 --> @magnumripper commented on GitHub (Jan 11, 2014): The very minimum fix before releasing Jumbo-1 would be to bug out if min or max length is requested with mask mode.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2014):

Reopening for future enhancement (with revised tags/milestone)

<!-- gh-comment-id:34385381 --> @magnumripper commented on GitHub (Feb 6, 2014): Reopening for future enhancement (with revised tags/milestone)
Author
Owner

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

@Sayantan2048 do you think you could have a go at this too? Or will you proceed with GPU first?

The behavior we wish is:

  • A candidate longer than format->params.plaintext_length is truncated - but in Mask mode, it should never be generated.
  • A candidate longer than --max-len option is rejected (never sent to crk_process_key) but in Mask mode, it better not even be generated.
  • A candidate shorter than --min-len option is rejected/never generated in a similar way.

For mask mode this is trickier than all other modes. Or maybe not? Also, like I said in OP above, a command line like -mask=?l?l?l?l?l?l?l?l?l?l -min-len=4 -max-len=6 should loop in do_mask_crack() and produce the same result as three separate sessions of ?l?l?l?l, ?l?l?l?l?l and ?l?l?l?l?l?l.

<!-- gh-comment-id:60462948 --> @magnumripper commented on GitHub (Oct 24, 2014): @Sayantan2048 do you think you could have a go at this too? Or will you proceed with GPU first? The behavior we wish is: - A candidate longer than format->params.plaintext_length is truncated - but in Mask mode, it should never be generated. - A candidate longer than `--max-len` option is rejected (never sent to crk_process_key) but in Mask mode, it better not even be generated. - A candidate shorter than `--min-len` option is rejected/never generated in a similar way. For mask mode this is trickier than all other modes. Or maybe not? Also, like I said in OP above, a command line like `-mask=?l?l?l?l?l?l?l?l?l?l -min-len=4 -max-len=6` should loop in do_mask_crack() and produce the same result as three separate sessions of ?l?l?l?l, ?l?l?l?l?l and ?l?l?l?l?l?l.
Author
Owner

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

On Sat, Oct 25, 2014 at 5:14 AM, magnum notifications@github.com wrote:

@Sayantan2048 https://github.com/Sayantan2048 do you think you could
have a go at this too? Or will you proceed with GPU first?

The behavior we wish is:

  • A candidate longer than format->params.plaintext_length is truncated
  • but in Mask mode, it should never be generated.
  • A candidate longer than --max-len option is rejected (never sent to
    crk_process_key) but in Mask mode, it better not even be generated.
  • A candidate shorter than --min-len option is rejected in a similar
    way.

For mask mode this is trickier than all other modes. Also, like I said in
OP above, a command line like -mask=?l?l?l?l?l?l?l?l?l?l -min-len=4
-max-len=6 should loop in do_mask_crack() and produce the same result as
three separate sessions of ?l?l?l?l, ?l?l?l?l?l and ?l?l?l?l?l?l.

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

For hybrid modes, I'm assuming we'll check max-len, min-length in both the
parent mode and mask mode. For max-length restriction, an early reject in
parent mode shouldn't be a problem. However for min-length, the parent mode
might reject the candidate due to short length which could have ended up
being transformed into an optimal sized key after addition of mask.

So, for hybrid modes, I think we should disable min-length check while keep
the max-length check intact in the parent mode. We'll check for both
max-length and min-length in mask mode though.

<!-- gh-comment-id:60469465 --> @sayan1an commented on GitHub (Oct 25, 2014): On Sat, Oct 25, 2014 at 5:14 AM, magnum notifications@github.com wrote: > @Sayantan2048 https://github.com/Sayantan2048 do you think you could > have a go at this too? Or will you proceed with GPU first? > > The behavior we wish is: > - A candidate longer than format->params.plaintext_length is truncated > - but in Mask mode, it should never be generated. > - A candidate longer than --max-len option is rejected (never sent to > crk_process_key) but in Mask mode, it better not even be generated. > - A candidate shorter than --min-len option is rejected in a similar > way. > > For mask mode this is trickier than all other modes. Also, like I said in > OP above, a command line like -mask=?l?l?l?l?l?l?l?l?l?l -min-len=4 > -max-len=6 should loop in do_mask_crack() and produce the same result as > three separate sessions of ?l?l?l?l, ?l?l?l?l?l and ?l?l?l?l?l?l. > > — > Reply to this email directly or view it on GitHub > https://github.com/magnumripper/JohnTheRipper/issues/380#issuecomment-60462948 > . For hybrid modes, I'm assuming we'll check max-len, min-length in both the parent mode and mask mode. For max-length restriction, an early reject in parent mode shouldn't be a problem. However for min-length, the parent mode might reject the candidate due to short length which could have ended up being transformed into an optimal sized key after addition of mask. So, for hybrid modes, I think we should disable min-length check while keep the max-length check intact in the parent mode. We'll check for both max-length and min-length in mask mode though.
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#117
No description provided.