[GH-ISSUE #2316] wpapsk (or any format setting a min length) #1550

Closed
opened 2026-10-15 04:19:53 +07:00 by bsakaguchi · 21 comments
Owner

Originally created by @jfoug on GitHub (Oct 31, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2316

Originally assigned to: @magnumripper on GitHub.

Hello,

I'm trying to use john (v1.8.0) to test wpa security. I want it to generate 10-character passwords, so I've added this to `john.conf`:

[Incremental:Test]
File = $JOHN/alnum.chr
MinLen = 10
MaxLen = 10
CharCount = 62

However, when I run `john --format=wpapsk --session=mysession --incremental=Test data`, it prints:

    Note: minimum length forced to 8

and still starts with 8-character passwords. What am I missing? 

So if we have a min length > the min length for the format, then the format should NOT change the min-length in a forced manner.

The user was using 1.8.0 but I have validated this still exists in bleeding-jumbo.

Originally created by @jfoug on GitHub (Oct 31, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2316 Originally assigned to: @magnumripper on GitHub. ``` Hello, I'm trying to use john (v1.8.0) to test wpa security. I want it to generate 10-character passwords, so I've added this to `john.conf`: [Incremental:Test] File = $JOHN/alnum.chr MinLen = 10 MaxLen = 10 CharCount = 62 However, when I run `john --format=wpapsk --session=mysession --incremental=Test data`, it prints: Note: minimum length forced to 8 and still starts with 8-character passwords. What am I missing? ``` So if we have a min length > the min length for the format, then the format should NOT change the min-length in a forced manner. The user was using 1.8.0 but I have validated this still exists in bleeding-jumbo.
bsakaguchi 2026-10-15 04:19:53 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

This is not a support forum and the example isn't intended use at all. As a quick solution (off the top of my head), simply add options --min-len=10 --max-len=10 and Bob will be your uncle's best grandma ever.

<!-- gh-comment-id:257434589 --> @magnumripper commented on GitHub (Oct 31, 2016): This is not a support forum and the example isn't intended use at all. As a quick solution (off the top of my head), simply add options `--min-len=10 --max-len=10` and Bob will be your uncle's best grandma ever.
Author
Owner

@jfoug commented on GitHub (Oct 31, 2016):

So you believe 'forcing' the minimum length to be LESS than the wanted minimum length is ok???

<!-- gh-comment-id:257435600 --> @jfoug commented on GitHub (Oct 31, 2016): So you believe 'forcing' the minimum length to be LESS than the wanted minimum length is ok???
Author
Owner

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

I'm not sure, but I think it's a matter of syntax defintion. What comes first? What option over-rides the other?

<!-- gh-comment-id:257436138 --> @magnumripper commented on GitHub (Oct 31, 2016): I'm not sure, but I think it's a matter of syntax defintion. What comes first? What option over-rides the other?
Author
Owner

@jfoug commented on GitHub (Oct 31, 2016):

I would think that the inc file should 'imply' --min-len and --max-len Would there be reasons why that is not correct logic?

<!-- gh-comment-id:257436186 --> @jfoug commented on GitHub (Oct 31, 2016): I would think that the inc file should 'imply' --min-len and --max-len Would there be reasons why that is not correct logic?
Author
Owner

@jfoug commented on GitHub (Oct 31, 2016):

I agree that it is an 'order' or precedence issue.

<!-- gh-comment-id:257436269 --> @jfoug commented on GitHub (Oct 31, 2016): I agree that it is an 'order' or precedence issue.
Author
Owner

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

I will have to ponder this. I never saw this issue until now.

<!-- gh-comment-id:257436288 --> @magnumripper commented on GitHub (Oct 31, 2016): I will have to ponder this. I never saw this issue until now.
Author
Owner

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

And I'm open for ideas.

<!-- gh-comment-id:257436335 --> @magnumripper commented on GitHub (Oct 31, 2016): And I'm open for ideas.
Author
Owner

@jfoug commented on GitHub (Oct 31, 2016):

Neither have I. I was pretty shocked at seeing it, and it DOES work this way in bleeding.

<!-- gh-comment-id:257436362 --> @jfoug commented on GitHub (Oct 31, 2016): Neither have I. I was pretty shocked at seeing it, and it DOES work this way in bleeding.
Author
Owner

@jfoug commented on GitHub (Oct 31, 2016):

The only thing I can think of off my head woudl be combining inc and mask.
Then the min-len in inc may be 10 and max-len=10, but then --mask=?w?d?d and thus all words are 12 (but that would be outside of range).

<!-- gh-comment-id:257436561 --> @jfoug commented on GitHub (Oct 31, 2016): The only thing I can think of off my head woudl be combining inc and mask. Then the min-len in inc may be 10 and max-len=10, but then --mask=?w?d?d and thus all words are 12 (but that would be outside of range).
Author
Owner

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

I never saw those inc options as something you'd use this way. But again, I need to think. Perhaps there's a super simple fix that will make everyone happy.

<!-- gh-comment-id:257436665 --> @magnumripper commented on GitHub (Oct 31, 2016): I never saw those inc options as something you'd use this way. But again, I need to think. Perhaps there's a super simple fix that will make everyone happy.
Author
Owner

@jfoug commented on GitHub (Oct 31, 2016):

but I do not know if --mask and --inc are valid together (Probably are). But requesting candidate engine to spew out only 10 char words, and having the format override that, certainly looks wrong.

<!-- gh-comment-id:257436825 --> @jfoug commented on GitHub (Oct 31, 2016): but I do not know if --mask and --inc are valid together (Probably are). But requesting candidate engine to spew out only 10 char words, and having the format override that, certainly looks wrong.
Author
Owner

@jfoug commented on GitHub (Oct 31, 2016):

I use that in inc all the time.

<!-- gh-comment-id:257436861 --> @jfoug commented on GitHub (Oct 31, 2016): I use that in inc all the time.
Author
Owner

@jfoug commented on GitHub (Nov 1, 2016):

I looked at the code change within john.c where the 'force min length' code is set, but the parsing of the inc file has not been done at that point. We 'could' add code there to also check if we are in inc mode, and if the mode has a length > the forced min length. BUT that would be pretty ugly.

This simple code does kick the length of the minimal value created within the inc mode up to what is in the inc section

$ git diff inc.c
diff --git a/src/inc.c b/src/inc.c
index a437ebe..c029538 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -521,6 +521,8 @@ void do_incremental_crack(struct db_main *db, char *mode)
        if ((max_length = cfg_get_int(SECTION_INC, mode, "MaxLen")) < 0)
                max_length = CHARSET_LENGTH;
        max_count = cfg_get_int(SECTION_INC, mode, "CharCount");
+       if (options.req_minlength != -1 && min_length > options.req_minlength)
+               options.req_minlength = min_length;

        /* Hybrid mask */
        min_length -= mask_add_len;

This is not a 'perfect' solution. The 'forcing length to 8' message still does show up, but the actual work load is the larger of this 'forced size', or the min size in the inc section.

There may be a better way to do this. But the simple 2 line hack above 'does' get the final end results.

<!-- gh-comment-id:257478345 --> @jfoug commented on GitHub (Nov 1, 2016): I looked at the code change within john.c where the 'force min length' code is set, but the parsing of the inc file has not been done at that point. We 'could' add code there to also check if we are in inc mode, and if the mode has a length > the forced min length. BUT that would be pretty ugly. This simple code does kick the length of the minimal value created within the inc mode up to what is in the inc section ``` diff $ git diff inc.c diff --git a/src/inc.c b/src/inc.c index a437ebe..c029538 100644 --- a/src/inc.c +++ b/src/inc.c @@ -521,6 +521,8 @@ void do_incremental_crack(struct db_main *db, char *mode) if ((max_length = cfg_get_int(SECTION_INC, mode, "MaxLen")) < 0) max_length = CHARSET_LENGTH; max_count = cfg_get_int(SECTION_INC, mode, "CharCount"); + if (options.req_minlength != -1 && min_length > options.req_minlength) + options.req_minlength = min_length; /* Hybrid mask */ min_length -= mask_add_len; ``` This is not a 'perfect' solution. The 'forcing length to 8' message still does show up, but the actual work load is the larger of this 'forced size', or the min size in the inc section. There may be a better way to do this. But the simple 2 line hack above 'does' get the final end results.
Author
Owner

@jfoug commented on GitHub (Nov 1, 2016):

The above patch is not right. I have been digging into inc.c and there are all sorts of bugs. That it does not crash astounds me. We subtract mask counts from min (and max and format max). Also do -1 in regex mode. So if min is 1, then -mask=?w?d?d?d?d sets min to -3 (this is for all formats that do not have a forced min). Fixing a lot of that should be easy.

I am not really sure how to proceed here. It looks like there was lots of work to track mask (but with bugs). Also something is being done with rexgen (not sure what).

But I do feel that if an inc mode lists a min, that the values returned by the inc mode should honor that value. For the non-mask/non-rexgen mode (i.e. no hybrid), we can work around this issue by having the user issue a -min=xxx command line arg. But I do not think that is an ideal solution either.

<!-- gh-comment-id:257481975 --> @jfoug commented on GitHub (Nov 1, 2016): The above patch is not right. I have been digging into inc.c and there are all sorts of bugs. That it does not crash astounds me. We subtract mask counts from min (and max and format max). Also do -1 in regex mode. So if min is 1, then -mask=?w?d?d?d?d sets min to -3 (this is for all formats that do not have a forced min). Fixing a lot of that should be easy. I am not really sure how to proceed here. It looks like there was lots of work to track mask (but with bugs). Also something is being done with rexgen (not sure what). But I do feel that if an inc mode lists a min, that the values returned by the inc mode should honor that value. For the non-mask/non-rexgen mode (i.e. no hybrid), we can work around this issue by having the user issue a -min=xxx command line arg. But I do not think that is an ideal solution either.
Author
Owner

@jfoug commented on GitHub (Nov 1, 2016):

Here is some example showing some of this buggy behavior:

$ ../run/john -mask=?wxxx -inc:digits -stdout -min-len=7
MaxLen = 122 exceeds the compile-time limit of 24
<!-- gh-comment-id:257483476 --> @jfoug commented on GitHub (Nov 1, 2016): Here is some example showing some of this buggy behavior: ``` $ ../run/john -mask=?wxxx -inc:digits -stdout -min-len=7 MaxLen = 122 exceeds the compile-time limit of 24 ```
Author
Owner

@jfoug commented on GitHub (Nov 1, 2016):

NOTE, I can see reducing the max count for inc and the format if there are things like -mask (or other hybrid stuff), but only reduce the max count for inc, IF that count + the hybrid count goes over the max length of the format. But I really think the min length of the inc should be honored. That value is defined for what the inc engine produces. But that is not todays behavior. It was how i thought it worked, but obviously, it is not working in that manner.

<!-- gh-comment-id:257484180 --> @jfoug commented on GitHub (Nov 1, 2016): NOTE, I can see reducing the max count for inc and the format if there are things like -mask (or other hybrid stuff), but only reduce the max count for inc, IF that count + the hybrid count goes over the max length of the format. But I really think the min length of the inc should be honored. That value is defined for what the inc engine produces. But that is not todays behavior. It was how i thought it worked, but obviously, it is not working in that manner.
Author
Owner

@magnumripper commented on GitHub (Nov 4, 2016):

I will have a look at this. The current logic is sort-of correct but lacks a few tests.

Here is some example showing some of this buggy behavior:

$ ../run/john -mask=?wxxx -inc:digits -stdout -min-len=7
MaxLen = 122 exceeds the compile-time limit of 24

It goes like this:

  1. The --stdout "format" has a max length of 125 (unless you say --stdout=N)
  2. The mask ?wxxx will add 3 mask characters to the base word, so we tell incremental mode that the max is 125-3 == 122.

When corrected, it should be something like this:

  1. inc_max_len is set from the "digits" incremental mode (to 24)
  2. fmt_max_len is set from format (to 125)
  3. mask_add_len is derived from mask (to 3)
  4. effective_max_len is MIN(inc_max_len, fmt_max_len - mask_add_len)

...so with your example, inc mode will run with a max len of 24. and the candidates will be up to 27 characters after applying the hybrid mask.

<!-- gh-comment-id:258532091 --> @magnumripper commented on GitHub (Nov 4, 2016): I will have a look at this. The current logic is sort-of correct but lacks a few tests. > Here is some example showing some of this buggy behavior: > > ``` > $ ../run/john -mask=?wxxx -inc:digits -stdout -min-len=7 > MaxLen = 122 exceeds the compile-time limit of 24 > ``` It goes like this: 1. The --stdout "format" has a max length of 125 (unless you say --stdout=N) 2. The mask ?wxxx will add 3 mask characters to the base word, so we tell incremental mode that the max is 125-3 == 122. When corrected, it should be something like this: 1. `inc_max_len` is set from the "digits" incremental mode (to 24) 2. `fmt_max_len` is set from format (to 125) 3. `mask_add_len` is derived from mask (to 3) 4. `effective_max_len` is `MIN(inc_max_len, fmt_max_len - mask_add_len)` ...so with your example, inc mode will run with a max len of 24. and the candidates will be up to 27 characters after applying the hybrid mask.
Author
Owner

@solardiz commented on GitHub (Nov 5, 2016):

An instance of this bug? -

$ ./john -form=descrypt-ztex -inc=alpha -min-len=4 -max-len=4 -mask='?w?l?l?l?l' ~/john/pw-fake-unix
1 device(s) ZTEX 1.15y ready
SN: .......... productId: 10.15.0.0 "inouttraffic UFM 1.15y" busnum:2 devnum:29
Using default input encoding: UTF-8
Loaded 3269 password hashes with 2243 different salts (descrypt-ztex, traditional crypt(3) [DES ZTEX])
Warning: Slow communication channel to the device. Increase mask or expect performance degradation.
Press 'q' or Ctrl-C to abort, almost any other key for status
Format internal ranges cannot be truncated!
Use a bigger key length or non-gpu format.

I wanted it to use 4-char incremental plus 4-char mask, for 8 total, but it refuses.

<!-- gh-comment-id:258616145 --> @solardiz commented on GitHub (Nov 5, 2016): An instance of this bug? - $ ./john -form=descrypt-ztex -inc=alpha -min-len=4 -max-len=4 -mask='?w?l?l?l?l' ~/john/pw-fake-unix 1 device(s) ZTEX 1.15y ready SN: .......... productId: 10.15.0.0 "inouttraffic UFM 1.15y" busnum:2 devnum:29 Using default input encoding: UTF-8 Loaded 3269 password hashes with 2243 different salts (descrypt-ztex, traditional crypt(3) [DES ZTEX]) Warning: Slow communication channel to the device. Increase mask or expect performance degradation. Press 'q' or Ctrl-C to abort, almost any other key for status Format internal ranges cannot be truncated! Use a bigger key length or non-gpu format. I wanted it to use 4-char incremental plus 4-char mask, for 8 total, but it refuses.
Author
Owner

@magnumripper commented on GitHub (Nov 5, 2016):

I wanted it to use 4-char incremental plus 4-char mask, for 8 total, but it refuses.

It may be poorly documented but the intended way to say that is -min-len=8 -max-len=8 -mask='?w?l?l?l?l'. The -max-len option specifies the final candidate length, so it will end up with incremental mode automatically being limited to length 4 and then mask mode will add its 4 characters.

<!-- gh-comment-id:258636798 --> @magnumripper commented on GitHub (Nov 5, 2016): > I wanted it to use 4-char incremental plus 4-char mask, for 8 total, but it refuses. It may be poorly documented but the intended way to say that is `-min-len=8 -max-len=8 -mask='?w?l?l?l?l'`. The -max-len option specifies the final candidate length, so it will end up with incremental mode automatically being limited to length 4 and then mask mode will add its 4 characters.
Author
Owner

@solardiz commented on GitHub (Nov 6, 2016):

Oh, so that's where the implementation complexity comes from. OK, this actually works with descrypt-ztex here.

<!-- gh-comment-id:258671799 --> @solardiz commented on GitHub (Nov 6, 2016): Oh, so that's where the implementation complexity comes from. OK, this actually works with descrypt-ztex here.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2016):

This is still not 100% perfect but the issue as reported is fixed.

<!-- gh-comment-id:267850868 --> @magnumripper commented on GitHub (Dec 18, 2016): This is still not 100% perfect but the issue as reported is fixed.
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#1550
No description provided.