[GH-ISSUE #745] Test and/or implement rules x rules #380

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

Originally created by @magnumripper on GitHub (Sep 16, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/745

PoC: create a trivial program (perl script?) that parses john.conf and can generate a new ruleset from two different ones (or twice the same) as "rules x rules".

So from these two rule sets:

[List.Rules:case]
:
cQ
CQ

[List.Rules:prependappend]
$[0-9]
^[0-9]

...perhaps using a syntax like this:

$ ./rulesgen.pl case prependappend >>john.local.conf

...would read the existing rulesets from john.conf and create this new one:

[List.Rules:case+prependappend]
: $[0-9]
: ^[0-9]
cQ $[0-9]
cQ ^[0-9]
CQ $[0-9]
CQ ^[0-9]

There might be some situations where some "editing" will be needed. For example, rule reject flags might only be allowed at start of line (I'm not sure) and if so, should ones from the "right hand" set be ignored or moved?

Originally created by @magnumripper on GitHub (Sep 16, 2014). Original GitHub issue: https://github.com/openwall/john/issues/745 PoC: create a trivial program (perl script?) that parses john.conf and can generate a new ruleset from two different ones (or twice the same) as "rules x rules". So from these two rule sets: ``` [List.Rules:case] : cQ CQ [List.Rules:prependappend] $[0-9] ^[0-9] ``` ...perhaps using a syntax like this: ``` $ ./rulesgen.pl case prependappend >>john.local.conf ``` ...would read the existing rulesets from john.conf and create this new one: ``` [List.Rules:case+prependappend] : $[0-9] : ^[0-9] cQ $[0-9] cQ ^[0-9] CQ $[0-9] CQ ^[0-9] ``` There might be some situations where some "editing" will be needed. For example, rule reject flags might only be allowed at start of line (I'm not sure) and if so, should ones from the "right hand" set be ignored or moved?
bsakaguchi 2026-10-14 03:03:59 +07:00
Author
Owner

@magnumripper commented on GitHub (Sep 16, 2014):

BTW here is how to do this without such script: You run wordlist through first ruleset to stdout, then use -pipe and next ruleset:

$ ../run/john -w:dict -ru:case -stdout | ../run/john -pipe -ru:prependappend -ses:rulexrule hashfile
<!-- gh-comment-id:55811452 --> @magnumripper commented on GitHub (Sep 16, 2014): BTW here is how to do this without such script: You run wordlist through first ruleset to stdout, then use -pipe and next ruleset: ``` $ ../run/john -w:dict -ru:case -stdout | ../run/john -pipe -ru:prependappend -ses:rulexrule hashfile ```
Author
Owner

@jfoug commented on GitHub (Sep 16, 2014):

Would we possibly want to simply have JtR core do this:

./john input.txt -rules=case+prependappend or something like that ??

<!-- gh-comment-id:55811545 --> @jfoug commented on GitHub (Sep 16, 2014): Would we possibly want to simply have JtR core do this: ./john input.txt -rules=case+prependappend or something like that ??
Author
Owner

@magnumripper commented on GitHub (Sep 16, 2014):

Absolutely, but that is probably trickier. I thought we had an issue for that but we don't seem to have one.

<!-- gh-comment-id:55811942 --> @magnumripper commented on GitHub (Sep 16, 2014): Absolutely, but that is probably trickier. I thought we had an issue for that but we don't seem to have one.
Author
Owner

@jfoug commented on GitHub (Sep 16, 2014):

A PoC even if simply a simple perl script would allow us to at least get a taste for what is possible.

We could easily (well not 'super easily') do it in john, the same as I did for includes. But I think the PoC as you wrote it, would at least allow us to show that it would be a good thing.

<!-- gh-comment-id:55812242 --> @jfoug commented on GitHub (Sep 16, 2014): A PoC even if simply a simple perl script would allow us to at least get a taste for what is possible. We could easily (well not 'super easily') do it in john, the same as I did for includes. But I think the PoC as you wrote it, would at least allow us to show that it would be a good thing.
Author
Owner

@magnumripper commented on GitHub (Sep 16, 2014):

I imagine the best thing if/when doing it within JtR, is doing it on the fly in some way. That is, if you combine two rulesets that expand to 10,000 rules each, it would never be 100,000,000 rules in memory at once. But that's possibly even harder to achieve.

<!-- gh-comment-id:55816944 --> @magnumripper commented on GitHub (Sep 16, 2014): I imagine the best thing if/when doing it within JtR, is doing it on the fly in some way. That is, if you combine two rulesets that expand to 10,000 rules each, it would never be 100,000,000 rules in memory at once. But that's possibly even harder to achieve.
Author
Owner

@jfoug commented on GitHub (Sep 16, 2014):

That would be harder, but still not out of realm of what can be done. It is much easier to pre-permute the 2 (or more) rule tables into a larger table, and simply walking that table.

<!-- gh-comment-id:55819139 --> @jfoug commented on GitHub (Sep 16, 2014): That would be harder, but still not out of realm of what can be done. It is much easier to pre-permute the 2 (or more) rule tables into a larger table, and simply walking that table.
Author
Owner

@magnumripper commented on GitHub (Sep 16, 2014):

I think that last goal would be worth the effort if it can be done at all. I'm thinking short, very high quality wordlist (or Single mode!) - and a mindbogglingly massive number of rules applied. Most script kiddies do it the other way round with silly 15 GB wordlists full of utter crap.

<!-- gh-comment-id:55821140 --> @magnumripper commented on GitHub (Sep 16, 2014): I think that last goal would be worth the effort if it can be done at all. I'm thinking short, very high quality wordlist (or Single mode!) - and a mindbogglingly massive number of rules applied. Most script kiddies do it the other way round with silly 15 GB wordlists full of utter crap.
Author
Owner

@magnumripper commented on GitHub (Sep 16, 2014):

BTW regardless of implementing this in Perl or in core, I would think/hope it could be done in a way so we could do more than two rules (eg. rules x rules x rules). Ideally there should be no particular limit other than the resulting size.

<!-- gh-comment-id:55821611 --> @magnumripper commented on GitHub (Sep 16, 2014): BTW regardless of implementing this in Perl or in core, I would think/hope it could be done in a way so we could do more than two rules (eg. rules x rules x rules). Ideally there should be no particular limit other than the resulting size.
Author
Owner

@frank-dittrich commented on GitHub (Sep 16, 2014):

Is the output of

./john --list=list-data:list.rules:single

of any help?
At least, it already parsed john.conf sections.

<!-- gh-comment-id:55823447 --> @frank-dittrich commented on GitHub (Sep 16, 2014): Is the output of ``` ./john --list=list-data:list.rules:single ``` of any help? At least, it already parsed john.conf sections.
Author
Owner

@magnumripper commented on GitHub (Sep 16, 2014):

@frank-dittrich yeah a Perl script could do that internally. That saves a good number of lines of code (for supporting .include and --config=FILE and so on).

<!-- gh-comment-id:55823710 --> @magnumripper commented on GitHub (Sep 16, 2014): @frank-dittrich yeah a Perl script could do that internally. That saves a good number of lines of code (for supporting .include and --config=FILE and so on).
Author
Owner

@magnumripper commented on GitHub (Sep 16, 2014):

I thought we had an issue for that but we don't seem to have one.

I changed this issue to cover both (otherwise we'll end up discussing same things in two threads)

<!-- gh-comment-id:55823929 --> @magnumripper commented on GitHub (Sep 16, 2014): > I thought we had an issue for that but we don't seem to have one. I changed this issue to cover both (otherwise we'll end up discussing same things in two threads)
Author
Owner

@magnumripper commented on GitHub (Jan 9, 2015):

This was OT in #998 but not here: Here are results from rules x rules with the default wordlist, a good example of why a wordlist should be very carefully trimmed. Jumbo squares to 491,287,225 rules! For speed we only use single mode rules here which squares to 1,168,561 rules.

From scratch, using dummy hashes generated from Rockyou with dupes:

$ rm -f test3.pot && ../run/john -w -rules=single -stdout=95 | ../run/john -pipe -rules=single rockyou.dupes.dummy -pot=test3.pot -form=dummy -verb=1 -ses:r2
Press 'q' or Ctrl-C to abort, almost any other key for status
Loaded 14343707 password hashes with no different salts (dummy [N/A])
Warning: no OpenMP support for this hash type, consider --fork=8
Press Ctrl-C to abort, or send SIGUSR1 to john process for status
2942623p 0:00:14:03 100.00% (2015-01-09 03:11) 3490p/s sss1900
1636736g 0:00:13:39  1996g/s 2935Kp/s 2935Kc/s 38060GC/s kissa219001900..sss19001900
Session completed

$ ../run/john rockyou.dupes.dummy -pot=test3.pot -form=dummy -show | tail -1
11413250 password hashes cracked, 21189445 left

35% cracked, this is slightly better than a single -rules=all despite generating just 1/8 the number of candidates. Or in other words, single x single is over 8 times more effective than -rules=all.

Edit: By the g/s figures, it's 6 times more effective. This is probably more accurate, the other figure was not accounting for word rejects.

<!-- gh-comment-id:69284540 --> @magnumripper commented on GitHub (Jan 9, 2015): This was OT in #998 but not here: Here are results from _rules x rules_ with the default wordlist, a good example of why a wordlist should be very carefully trimmed. Jumbo squares to 491,287,225 rules! For speed we only use single mode rules here which squares to 1,168,561 rules. From scratch, using dummy hashes generated from Rockyou _with_ dupes: ``` $ rm -f test3.pot && ../run/john -w -rules=single -stdout=95 | ../run/john -pipe -rules=single rockyou.dupes.dummy -pot=test3.pot -form=dummy -verb=1 -ses:r2 Press 'q' or Ctrl-C to abort, almost any other key for status Loaded 14343707 password hashes with no different salts (dummy [N/A]) Warning: no OpenMP support for this hash type, consider --fork=8 Press Ctrl-C to abort, or send SIGUSR1 to john process for status 2942623p 0:00:14:03 100.00% (2015-01-09 03:11) 3490p/s sss1900 1636736g 0:00:13:39 1996g/s 2935Kp/s 2935Kc/s 38060GC/s kissa219001900..sss19001900 Session completed $ ../run/john rockyou.dupes.dummy -pot=test3.pot -form=dummy -show | tail -1 11413250 password hashes cracked, 21189445 left ``` 35% cracked, this is slightly better than a single -rules=all despite generating just 1/8 the number of candidates. Or in other words, _single x single_ is over 8 times more effective than -rules=all. **Edit:** By the g/s figures, it's 6 times more effective. This is probably more accurate, the other figure was not accounting for word rejects.
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#380
No description provided.