[GH-ISSUE #2684] Bump RULE_RANGES_MAX and add warning when limit is reached #1737

Open
opened 2026-10-15 04:23:48 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @magnumripper on GitHub (Aug 18, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2684

http://www.openwall.com/lists/john-users/2017/08/18/2

On Fri, Aug 18, 2017 at 03:09:36PM +0200, Virginie trinite wrote:
> I try to retrieve a password of mine, for which  I do not remember where I
> put the uppercase.
> I find this interesting rules, which do what I want but only for the first
> 14 characters, and my password is very long.
>
> [List.Rules:NT]
> l
> lMT[*0]T[*1]T[*2]T[*3]T[*4]T[*5]T[*6]T[*7]T[*8]T[*9]T[*A]T[*B]T[*C]T[*D]Q
>
> I try to extend it, but as soon as I arrive to G, it doesn't work anymore.
> As variable G has nothing specific, I wonder where is the problem
>
> [List.Rules:NT]
> l
> lMT[*0]T[*1]T[*2]T[*3]T[*4]T[*5]T[*6]T[*7]T[*8]T[*9]T[*A]T[*B]T[*C]T[*D]T[*E]T[*F]T[*G]Q
>
> It says Invalid rule in ./john.conf at line 631: Invalid position code

You're bumping into this limit in params.h:

/*
 * Maximum number of character ranges for rules.
 */
#define RULE_RANGES_MAX                 16

You can raise it and recompile.  And given your reasonable use case,
maybe we need to raise the default for this parameter, say, to 30.

Maybe we also need to report an error when this limit is hit, instead of
silently not performing the preprocessor expansion (which results in
confusing error messages from further processing, like you have seen).

Also related: JtR performs preprocessor expansion of the rules at
startup, to count the expanded rules (such as for progress reporting)
and validate their syntax.  With extreme use of the preprocessor like
this, JtR startup may be slow.  Too many expanded rules may also
overflow the integer variables (but your specific use is safe in this
respect, as long as you don't go beyond 30 preprocessor expansions).

Alexander
Originally created by @magnumripper on GitHub (Aug 18, 2017). Original GitHub issue: https://github.com/openwall/john/issues/2684 http://www.openwall.com/lists/john-users/2017/08/18/2 ``` On Fri, Aug 18, 2017 at 03:09:36PM +0200, Virginie trinite wrote: > I try to retrieve a password of mine, for which I do not remember where I > put the uppercase. > I find this interesting rules, which do what I want but only for the first > 14 characters, and my password is very long. > > [List.Rules:NT] > l > lMT[*0]T[*1]T[*2]T[*3]T[*4]T[*5]T[*6]T[*7]T[*8]T[*9]T[*A]T[*B]T[*C]T[*D]Q > > I try to extend it, but as soon as I arrive to G, it doesn't work anymore. > As variable G has nothing specific, I wonder where is the problem > > [List.Rules:NT] > l > lMT[*0]T[*1]T[*2]T[*3]T[*4]T[*5]T[*6]T[*7]T[*8]T[*9]T[*A]T[*B]T[*C]T[*D]T[*E]T[*F]T[*G]Q > > It says Invalid rule in ./john.conf at line 631: Invalid position code You're bumping into this limit in params.h: /* * Maximum number of character ranges for rules. */ #define RULE_RANGES_MAX 16 You can raise it and recompile. And given your reasonable use case, maybe we need to raise the default for this parameter, say, to 30. Maybe we also need to report an error when this limit is hit, instead of silently not performing the preprocessor expansion (which results in confusing error messages from further processing, like you have seen). Also related: JtR performs preprocessor expansion of the rules at startup, to count the expanded rules (such as for progress reporting) and validate their syntax. With extreme use of the preprocessor like this, JtR startup may be slow. Too many expanded rules may also overflow the integer variables (but your specific use is safe in this respect, as long as you don't go beyond 30 preprocessor expansions). Alexander ```
Author
Owner

@magnumripper commented on GitHub (Aug 21, 2017):

Now bumped. I didn't add an error yet though, not quite sure where to put it? Should be somewhere here:

$ git grep -C3 RULE_RANGES_MAX rpp.c
rpp.c-          if (!(c = *++input)) break;
rpp.c-          c1 = ctx->count ? '0' : '1';
rpp.c-          c2 = (ctx->count <= 9) ? '0' + ctx->count : '9';
rpp.c:          if (c >= c1 && c <= c2 && ctx->refs_count < RULE_RANGES_MAX) {
rpp.c-                  struct rpp_ref *ref = &ctx->refs[ctx->refs_count++];
rpp.c-                  ref->pos = (char *)output;
rpp.c-                  ref->range = (c == '0') ? ctx->count - 1 : c - '1';
rpp.c-          }
rpp.c-          input++;
rpp.c:          if (ctx->count < RULE_RANGES_MAX)
rpp.c-          switch (c) {
rpp.c-          case 'p':
rpp.c-                  if ((c2 = *input) == '[' || c2 == '\\') {
--
rpp.c-          break;
rpp.c-
rpp.c-  case '[':
rpp.c:          if (ctx->count >= RULE_RANGES_MAX) {
rpp.c-                  *output++ = *input++;
rpp.c-                  break;
rpp.c-          }
<!-- gh-comment-id:323811062 --> @magnumripper commented on GitHub (Aug 21, 2017): Now bumped. I didn't add an error yet though, not quite sure where to put it? Should be somewhere here: ``` $ git grep -C3 RULE_RANGES_MAX rpp.c rpp.c- if (!(c = *++input)) break; rpp.c- c1 = ctx->count ? '0' : '1'; rpp.c- c2 = (ctx->count <= 9) ? '0' + ctx->count : '9'; rpp.c: if (c >= c1 && c <= c2 && ctx->refs_count < RULE_RANGES_MAX) { rpp.c- struct rpp_ref *ref = &ctx->refs[ctx->refs_count++]; rpp.c- ref->pos = (char *)output; rpp.c- ref->range = (c == '0') ? ctx->count - 1 : c - '1'; rpp.c- } rpp.c- input++; rpp.c: if (ctx->count < RULE_RANGES_MAX) rpp.c- switch (c) { rpp.c- case 'p': rpp.c- if ((c2 = *input) == '[' || c2 == '\\') { -- rpp.c- break; rpp.c- rpp.c- case '[': rpp.c: if (ctx->count >= RULE_RANGES_MAX) { rpp.c- *output++ = *input++; rpp.c- break; rpp.c- } ```
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#1737
No description provided.