[GH-ISSUE #998] Implement "unrule" #600

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

Originally created by @magnumripper on GitHub (Jan 5, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/998

Brainstorming...

Say you had a utility you could run like this:

./unrule --rules=jumbo --input-enc:utf8 --internal-enc:cp1252 rockyou.txt > rockyou-jumbo.txt

Goal: Produce the smallest possible wordlist that will still cover 100% of rockyou.txt when run with --rules=jumbo

One thing that makes this project interesting is we can actually start out pretty rough (even just supporting a single rule) and best-effort and improve it over time. Even if not perfect it will never be a bad thing.

I initially thought this would be a perl script - but then we'd need to port a whole lot of code to perl for reading config files and include directives, and pre-processing rules. And possibly even support those encoding options.

Originally created by @magnumripper on GitHub (Jan 5, 2015). Original GitHub issue: https://github.com/openwall/john/issues/998 Brainstorming... Say you had a utility you could run like this: ``` ./unrule --rules=jumbo --input-enc:utf8 --internal-enc:cp1252 rockyou.txt > rockyou-jumbo.txt ``` Goal: Produce the smallest possible wordlist that will still cover 100% of rockyou.txt when run with --rules=jumbo One thing that makes this project interesting is we can actually start out pretty rough (even just supporting a single rule) and best-effort and improve it over time. Even if not perfect it will never be a bad thing. I initially thought this would be a perl script - but then we'd need to port a whole lot of code to perl for reading config files and include directives, and pre-processing rules. And possibly even support those encoding options.
bsakaguchi 2026-10-14 03:14:49 +07:00
  • closed this issue
  • added the
    new tool
    label
Author
Owner

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

Found this http://hashcat.net/forum/thread-1305.html

<!-- gh-comment-id:69197992 --> @magnumripper commented on GitHub (Jan 8, 2015): Found this http://hashcat.net/forum/thread-1305.html
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

I really think this is something that could be done in perl. The rules themselves are not that complex, and would work wonderful in perl (just like I put the dynamic 'language' into pass_gen.pl). It would be no where near as fast as rule processing in JtR (it would likely be a recursive decent parser), BUT speed is not what we are looking for.

This might be a fun project to greater improve my Perl.

Now, the tr-sed 1 liner from epixiop is a wonderful pre-screening tool. We would assume that stripping out that crap would often be a good step to find many base words. Should it always be done, hard to say. If for instance, your rules did not have the 1337 rulez, then that is not good. Same thing for removing things like 143345password$ => password (or passwords) IF your rules do not have append of 6 numbers.

Now, if it would be better to pre-process a wordlist, or to build a 'proper' unruler to simply run rules in reverse order to find minimal valids.

I guess, what we should do, is to do some of these BY hand, talking them out. Algorithms will fall out of talk like that.

<!-- gh-comment-id:69201093 --> @jfoug commented on GitHub (Jan 8, 2015): I really think this is something that could be done in perl. The rules themselves are not that complex, and would work wonderful in perl (just like I put the dynamic 'language' into pass_gen.pl). It would be no where near as fast as rule processing in JtR (it would likely be a recursive decent parser), BUT speed is not what we are looking for. This might be a fun project to greater improve my Perl. Now, the tr-sed 1 liner from epixiop is a wonderful pre-screening tool. We would assume that stripping out that crap would often be a good step to find many base words. Should it always be done, hard to say. If for instance, your rules did not have the 1337 rulez, then that is not good. Same thing for removing things like 143345password$ => password (or passwords) IF your rules do not have append of 6 numbers. Now, if it would be better to pre-process a wordlist, or to build a 'proper' unruler to simply run rules in reverse order to find minimal valids. I guess, what we should do, is to do some of these BY hand, talking them out. Algorithms will fall out of talk like that.
Author
Owner

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

Making it "perfect" for an exact set of rules is probably a very complex task though.

Say we start with this wordlist

Password
Password123

Say we un-rule "capitalize" and change it to

password
password123

Then we un-rule "append three digits" and drop the dupe so we end up with

password

This looks good. But the problem is that running this with those two rules will produce this:

Password
password123

So we never produce the original Password123 because we never apply both rules at once.

<!-- gh-comment-id:69203582 --> @magnumripper commented on GitHub (Jan 8, 2015): Making it "perfect" for an exact set of rules is probably a very complex task though. Say we start with this wordlist ``` Password Password123 ``` Say we un-rule "capitalize" and change it to ``` password password123 ``` Then we un-rule "append three digits" and drop the dupe so we end up with ``` password ``` This looks good. But the problem is that running this with those two rules will produce this: ``` Password password123 ``` So we never produce the original `Password123` because we never apply both rules at once.
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

It has to be done 1 rule at a time (in current john compat mode).

You really need to have this: 1 starting word list, and mimimized word list for each rule.
So here, original list is:

Password
Password123

The unrule list for append 3 digits is:
Password

The unrule list for capitialize is
password
password123

As you see, the Capitalize rule does not come into play. We have found a smaller wordlist from just the append-3num.

<!-- gh-comment-id:69208430 --> @jfoug commented on GitHub (Jan 8, 2015): It has to be done 1 rule at a time (in current john compat mode). You really need to have this: 1 starting word list, and mimimized word list for each rule. So here, original list is: Password Password123 The unrule list for append 3 digits is: Password The unrule list for capitialize is password password123 As you see, the Capitalize rule does not come into play. We have found a smaller wordlist from just the append-3num.
Author
Owner

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

So we should finally look at both lists and somehow produce either

password
Password

or

password
password123
<!-- gh-comment-id:69214750 --> @magnumripper commented on GitHub (Jan 8, 2015): So we should finally look at both lists and somehow produce either ``` password Password ``` or ``` password password123 ```
Author
Owner

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

And given 4,000,000 rules after PP, how would we write that!?

<!-- gh-comment-id:69214859 --> @magnumripper commented on GitHub (Jan 8, 2015): And given 4,000,000 rules after PP, how would we write that!?
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

by handing pp inline, and not 'creating' pseudo rules from the pre-processor.

If the rule is:

$[0-9]$[0-9]$[0-9]

we do not have to create 1000 separate rules. we simply write code that handles this.

Keep in mind, that 'really' is 1 rule, and to properly 'unrule' it, you should treat all 1000 separate rules as being the 'same' rule.

Thus,

password123
password234
password456

would simply generate a single

password

hash. If we had 1000 'separate' rules, then that would not help us out. Everything that happens within the macro rule, should be taken into account, not just each micro-rule part.

<!-- gh-comment-id:69216208 --> @jfoug commented on GitHub (Jan 8, 2015): by handing pp inline, and not 'creating' pseudo rules from the pre-processor. If the rule is: $[0-9]$[0-9]$[0-9] we do not have to create 1000 separate rules. we simply write code that handles this. Keep in mind, that 'really' is 1 rule, and to properly 'unrule' it, you should treat all 1000 separate rules as being the 'same' rule. Thus, password123 password234 password456 would simply generate a single password hash. If we had 1000 'separate' rules, then that would not help us out. Everything that happens within the macro rule, should be taken into account, not just each micro-rule part.
Author
Owner

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

I mean if we are to keep a list from each unrule to process later, we'll have 4M lists...

But perhaps my example is bad. Given an original wordlist of

password
Password
password123
Password456

After processing "Capitalize" we could definitely drop "Password" for good.

password
password123
Password456

And after processing "append3" (with no "memory" of the previous operation except our one list is shorter now) we could definitely change the words with numbers in the end to not have them.

password
password
Password

And this re-inserts "Password". So after dropping dupes we'd end up with

password
Password

This is doable and it will produce all original words.

<!-- gh-comment-id:69216678 --> @magnumripper commented on GitHub (Jan 8, 2015): I mean if we are to keep a list from each unrule to process later, we'll have 4M lists... But perhaps my example is bad. Given an original wordlist of ``` password Password password123 Password456 ``` After processing "Capitalize" we could definitely drop "Password" for good. ``` password password123 Password456 ``` And after processing "append3" (with no "memory" of the previous operation except our one list is shorter now) we could definitely _change_ the words with numbers in the end to not have them. ``` password password Password ``` And _this re-inserts "Password"_. So after dropping dupes we'd end up with ``` password Password ``` This is doable and it will produce all original words.
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

This is getting uglier and uglier. There are some really ugly things to take into account:

s?CY
@X
@?CY

Note, that we have no way to 'undo' that, in any 1 to 1 manner. What we would need to do for each of these, is to attempt to find words which would satisfy the purge/replacement, BUT still satisfy as many as possible OTHER words.

Many of the rules are easy to 'undo'. They are all 1 to 1, and done if a very specific order. Some of these purge / replacements may end up being close to show stoppers.

<!-- gh-comment-id:69220792 --> @jfoug commented on GitHub (Jan 8, 2015): This is getting uglier and uglier. There are some really ugly things to take into account: s?CY @X @?CY Note, that we have no way to 'undo' that, in any 1 to 1 manner. What we would need to do for each of these, is to attempt to find words which would satisfy the purge/replacement, BUT still satisfy as many as possible OTHER words. Many of the rules are easy to 'undo'. They are all 1 to 1, and done if a very specific order. Some of these purge / replacements may end up being close to show stoppers.
Author
Owner

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

So s?CY is "replace all chars of class ?C with Y" and @X is "purge all X"

I see no problem. The quest is not really to undo anything. The quest is to remove all words from the initial wordlist that will be produced by some other word + rule.

The result from original rockyou.txt + rules will produce a whole lot of dupes. I think after processing, we'll have a much shorter rockyou2.txt, that will still produce all the original words with rules applied, and more (eg. an original word of password123 may now be password + any tree digits).

<!-- gh-comment-id:69228686 --> @magnumripper commented on GitHub (Jan 8, 2015): So s?CY is "replace all chars of class ?C with Y" and @X is "purge all X" I see no problem. The quest is not really to _undo_ anything. The quest is to remove all words from the initial wordlist that will be produced by some other word + rule. The result from original rockyou.txt + rules will produce a whole lot of dupes. I think after processing, we'll have a much shorter rockyou2.txt, that will still produce all the original words with rules applied, and more (eg. an original word of password123 may now be password + any tree digits).
Author
Owner

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

Goal: Produce the smallest possible wordlist that will still cover 100% of rockyou.txt when run with --rules=jumbo

Maybe this is ambigous - and I'm not 100% sure what we want. It's either "original without rules is 100% covered with new list + rules" or "original + rules is a subset of new list + rules" and I think the latter is a superset of the former.

<!-- gh-comment-id:69229365 --> @magnumripper commented on GitHub (Jan 8, 2015): > Goal: Produce the smallest possible wordlist that will still cover 100% of rockyou.txt when run with --rules=jumbo Maybe this is ambigous - and I'm not 100% sure what we want. It's either "original without rules is 100% covered with new list + rules" or "original + rules is a subset of new list + rules" and I think the latter is a superset of the former.
Author
Owner

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

I think we need to stick with "original without rules is 100% covered with new list + rules" or this will be hairy.

<!-- gh-comment-id:69229913 --> @magnumripper commented on GitHub (Jan 8, 2015): I think we need to stick with "original without rules is 100% covered with new list + rules" or this will be hairy.
Author
Owner

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

But perhaps my example is bad. Given an original wordlist of

password
Password
password123
Password456

After processing "Capitalize" we could definitely drop "Password" for good.

password
password123
Password456

And after processing "append3" (with no "memory" of the previous operation except our one list is shorter now) we could definitely change the words with numbers in the end to not have them.

password
password
Password

And this re-inserts "Password". So after dropping dupes we'd end up with

password
Password

This is doable and it will produce all original words.

This is still not it. If we proceed to process a rule "append 'ord' to the end" we would end up like this

passw
Passw

But this will never produce "password123" or "Password456"

<!-- gh-comment-id:69232636 --> @magnumripper commented on GitHub (Jan 8, 2015): > But perhaps my example is bad. Given an original wordlist of > > ``` > password > Password > password123 > Password456 > ``` > > After processing "Capitalize" we could definitely drop "Password" for good. > > ``` > password > password123 > Password456 > ``` > > And after processing "append3" (with no "memory" of the previous operation except our one list is shorter now) we could definitely _change_ the words with numbers in the end to not have them. > > ``` > password > password > Password > ``` > > And _this re-inserts "Password"_. So after dropping dupes we'd end up with > > ``` > password > Password > ``` > > This is doable and it will produce all original words. This is still not it. If we proceed to process a rule "append 'ord' to the end" we would end up like this ``` passw Passw ``` But this will never produce "password123" or "Password456"
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

Ok, here is an algorithm (note, typing on the fly)

nCnt = LoadWords(@words);
@newwords = ();
do {
  nRemoved = 0;
  $best_rule  = "";
  foreach $rule (@rules) {
    nRemove = find_best($rule, @words);
    if (nRemove > nRemoved) {
      nRemoved = nRemoved;
      $best = $best_rule;
    }
  }
  if (nRemoved > 0) {
     @newwords.add(RemoveWords(@words, $best_rule, nCnt));
  }
} while (nRemoved > 1);
print "Here is our new wordlist:  There are ", scalar @newwords + scalar @words, " final words\n";
foreach $word(@newwords) {print "$word\n";}
foreach $word(@words) {print "$word\n";}

Ok, what find_best() does, is find the highest number of multiple words within the current word list that will be replaced by a single word, having that single word run through the rules. So something like password password1 password2 ... password9 would return 9 for Az,[0-9], since 10 words would be replaced by the single input password.

Then the RemoveWords() would return the proper 'base' word (which is added to the @newwords array, and all of the words would be removed from the @words array. In this case the word 'password' should probably also be removed, even though it did not satisfy the "Az,[0-9]," rule, the base word was contained within the output wordlist proper. Also, nCnt would be reduced by 10 for this 'hit'.

In this algorithm, we look for the 'best' hit, remove that word (based upon the rule), then look for the remaining 'best' hit based upon the words that are still left.

This ALMOST CERTAILY is not an optimal algorithm, but I assure you, it is valid, AND will exit when complete. There are only so many words in the @words array. As long as we can make that list smaller we continue. Once we can no longer make it smaller, we exit, and print both the replacement words, and whatever was left over. That should be a complete replacement set.

<!-- gh-comment-id:69235683 --> @jfoug commented on GitHub (Jan 8, 2015): Ok, here is an algorithm (note, typing on the fly) ``` Perl nCnt = LoadWords(@words); @newwords = (); do { nRemoved = 0; $best_rule = ""; foreach $rule (@rules) { nRemove = find_best($rule, @words); if (nRemove > nRemoved) { nRemoved = nRemoved; $best = $best_rule; } } if (nRemoved > 0) { @newwords.add(RemoveWords(@words, $best_rule, nCnt)); } } while (nRemoved > 1); print "Here is our new wordlist: There are ", scalar @newwords + scalar @words, " final words\n"; foreach $word(@newwords) {print "$word\n";} foreach $word(@words) {print "$word\n";} ``` Ok, what find_best() does, is find the highest number of multiple words within the current word list that will be replaced by a single word, having that single word run through the rules. So something like password password1 password2 ... password9 would return 9 for Az,[0-9], since 10 words would be replaced by the single input password. Then the RemoveWords() would return the proper 'base' word (which is added to the @newwords array, and all of the words would be removed from the @words array. In this case the word 'password' should probably also be removed, even though it did not satisfy the "Az,[0-9]," rule, the base word was contained within the output wordlist proper. Also, nCnt would be reduced by 10 for this 'hit'. In this algorithm, we look for the 'best' hit, remove that word (based upon the rule), then look for the remaining 'best' hit based upon the words that are still left. This ALMOST CERTAILY is not an optimal algorithm, but I assure you, it is valid, AND will exit when complete. There are only so many words in the @words array. As long as we can make that list smaller we continue. Once we can no longer make it smaller, we exit, and print both the replacement words, and whatever was left over. That should be a complete replacement set.
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

Ok, using the above algorithm, (very brain dead method, yes I know). I also created a hard coded specific 'simple' rule to check.

I created code for this rule:

# Lowercase every pure alphanumeric word
-c >3 !?X l Q

A simple lower case. I have done NO optimizations. My code simply loads the rockyou.txt file like this:

my @words = <IN>; That takes 45s by itself and consumes a boat load of memory.

My main loop is then this:

my %map = ();
foreach my $word (@working_words) {
    chomp $word;
                                           # ignore the -c
    next if (length($word) < 4);           # handle >3
    next if (contains_class($word, "X"));  # handle !?   X
    $word = lc $word;                      # handle the l
    $map{$word} += 1;
    if ($map{$word} > $bestCnt) {
        $base = $word;
        $bestCnt = $map{$word};
    }
}
$_[1] = $base;
return $bestCnt;

This takes right at 2 minutes to run. It returns 34 and password. If I grep -i -w password and cut 'only' pure password stuff, I get 34, so the count done by hash is working just fine

But it is probably WAY too slow (to satisfy usability in the original algorithm), and uses a shit load of memory.

NOTE, this rule 'could' be improved, and could removed a boat load of items. If we ran this 1 time, and then removed all words with > X number of reductions, and set X to 10, then 1 run and we remove quite a few.

I added this code (to count number where more than 10 were removed by lc), and here is results:

my $key; my $value; my $tot=0; my $cnt = 0;
while ( ($key, $value) = each %map )
{
    if ($value > 10) {
        print "key: $key, value: $map{$key}\n";
        $tot += $value;
        $cnt += 1;
    }
}
print "count=$cnt total_values = $tot\n";

and here were the results:

key: mariposa, value: 11
key: victoria, value: 11
key: harrypotter, value: 14
key: ilovejesus, value: 12
key: butterfly, value: 12
key: phoenix, value: 11
key: iloveyou, value: 26
key: jordan, value: 11
key: jonathan, value: 11
key: manuel, value: 11
key: password1, value: 13
key: forever, value: 13
key: patricia, value: 11
key: basketball, value: 12
key: mariana, value: 13
key: alejandra, value: 15
key: jennifer, value: 17
key: danielle, value: 11
key: sebastian, value: 11
key: iloveme, value: 13
key: iloveu, value: 12
key: spongebob, value: 12
key: jessica, value: 16
key: america, value: 11
key: michelle, value: 14
key: rockyou, value: 21
key: ilovegod, value: 12
key: greenday, value: 11
key: monkey, value: 12
key: sunshine, value: 11
key: secret, value: 11
key: passw0rd, value: 12
key: ihateyou, value: 11
key: playboy, value: 13
key: babygirl, value: 13
key: slipknot, value: 13
key: flower, value: 11
key: jasmine, value: 12
key: angels, value: 11
key: vanessa, value: 11
key: iloveu2, value: 13
key: daniel, value: 12
key: password, value: 34
key: nicole, value: 12
key: fuckyou, value: 13
key: princess, value: 20
key: liverpool, value: 12
key: soccer, value: 12
key: teamobb, value: 11
key: elizabeth, value: 12
key: blink182, value: 13
key: angel, value: 12
key: amanda, value: 11
key: angelica, value: 12
key: teamo, value: 11
count=55 total_values = 719
<!-- gh-comment-id:69248682 --> @jfoug commented on GitHub (Jan 8, 2015): Ok, using the above algorithm, (very brain dead method, yes I know). I also created a hard coded specific 'simple' rule to check. I created code for this rule: ``` # Lowercase every pure alphanumeric word -c >3 !?X l Q ``` A simple lower case. I have done NO optimizations. My code simply loads the rockyou.txt file like this: `my @words = <IN>;` That takes 45s by itself and consumes a boat load of memory. My main loop is then this: ``` Perl my %map = (); foreach my $word (@working_words) { chomp $word; # ignore the -c next if (length($word) < 4); # handle >3 next if (contains_class($word, "X")); # handle !? X $word = lc $word; # handle the l $map{$word} += 1; if ($map{$word} > $bestCnt) { $base = $word; $bestCnt = $map{$word}; } } $_[1] = $base; return $bestCnt; ``` This takes right at 2 minutes to run. It returns 34 and password. If I grep -i -w password and cut 'only' pure password stuff, I get 34, so the count done by hash is working just fine But it is probably WAY too slow (to satisfy usability in the original algorithm), and uses a shit load of memory. NOTE, this rule 'could' be improved, and could removed a boat load of items. If we ran this 1 time, and then removed all words with > X number of reductions, and set X to 10, then 1 run and we remove quite a few. I added this code (to count number where more than 10 were removed by lc), and here is results: ``` Perl my $key; my $value; my $tot=0; my $cnt = 0; while ( ($key, $value) = each %map ) { if ($value > 10) { print "key: $key, value: $map{$key}\n"; $tot += $value; $cnt += 1; } } print "count=$cnt total_values = $tot\n"; ``` and here were the results: ``` key: mariposa, value: 11 key: victoria, value: 11 key: harrypotter, value: 14 key: ilovejesus, value: 12 key: butterfly, value: 12 key: phoenix, value: 11 key: iloveyou, value: 26 key: jordan, value: 11 key: jonathan, value: 11 key: manuel, value: 11 key: password1, value: 13 key: forever, value: 13 key: patricia, value: 11 key: basketball, value: 12 key: mariana, value: 13 key: alejandra, value: 15 key: jennifer, value: 17 key: danielle, value: 11 key: sebastian, value: 11 key: iloveme, value: 13 key: iloveu, value: 12 key: spongebob, value: 12 key: jessica, value: 16 key: america, value: 11 key: michelle, value: 14 key: rockyou, value: 21 key: ilovegod, value: 12 key: greenday, value: 11 key: monkey, value: 12 key: sunshine, value: 11 key: secret, value: 11 key: passw0rd, value: 12 key: ihateyou, value: 11 key: playboy, value: 13 key: babygirl, value: 13 key: slipknot, value: 13 key: flower, value: 11 key: jasmine, value: 12 key: angels, value: 11 key: vanessa, value: 11 key: iloveu2, value: 13 key: daniel, value: 12 key: password, value: 34 key: nicole, value: 12 key: fuckyou, value: 13 key: princess, value: 20 key: liverpool, value: 12 key: soccer, value: 12 key: teamobb, value: 11 key: elizabeth, value: 12 key: blink182, value: 13 key: angel, value: 12 key: amanda, value: 11 key: angelica, value: 12 key: teamo, value: 11 count=55 total_values = 719 ```
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

Now again, "l" is not the 'best' rule, but I wanted to start there, since it is pretty much the easiest and quickest type of rule. But even here, 719 removals out of 14.34 million is pretty minor. However, this rule is O(n) in complexity. 1 word output for every one word input (well, less than this, since rejection rules will reject many from the wordlist). So this one is a pretty fast rule. It will run as fast or faster (close to it) as running the wordlist with no rules.

One other 'fun' thing, is that the rule rejections have to almost be done later on. So we will probably have to un-run the rule mangling, and only then, check to see if the rejection rules are satisfied.

<!-- gh-comment-id:69250685 --> @jfoug commented on GitHub (Jan 8, 2015): Now again, "l" is not the 'best' rule, but I wanted to start there, since it is pretty much the easiest and quickest type of rule. But even here, 719 removals out of 14.34 million is pretty minor. However, this rule is O(n) in complexity. 1 word output for every one word input (well, less than this, since rejection rules will reject many from the wordlist). So this one is a pretty fast rule. It will run as fast or faster (close to it) as running the wordlist with no rules. One other 'fun' thing, is that the rule rejections have to almost be done later on. So we will probably have to un-run the rule mangling, and only then, check to see if the rejection rules are satisfied.
Author
Owner

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

Could you not use (ie. remove) all of keys(%map) after one run, instead of just the best hit? I'm not sure I follow.

<!-- gh-comment-id:69251752 --> @magnumripper commented on GitHub (Jan 8, 2015): Could you not use (ie. remove) all of `keys(%map)` after one run, instead of just the best hit? I'm not sure I follow.
Author
Owner

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

I think I meant all of keys(%map) that has a value larger than 1...

<!-- gh-comment-id:69252784 --> @magnumripper commented on GitHub (Jan 8, 2015): I think I meant all of `keys(%map)` that has a value larger than 1...
Author
Owner

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

It took only 40s on my laptop.

Why limit to 10? I get a total of 513143 possible removals using this code (after yours)

my $total = 0;

#foreach my $key (sort { $map{$b} <=> $map{$a} } keys %map) {
foreach my $key (keys %map) {
    next if $map{$key} <= 1;
    $total += $map{$key} - 1;
    #printf "%d\t%s\n", $map{$key}, $key;
}

printf "\nTotal: %d\n", $total;

I had the contains_class thing commented out though.

<!-- gh-comment-id:69256265 --> @magnumripper commented on GitHub (Jan 8, 2015): It took only 40s on my laptop. Why limit to 10? I get a total of 513143 possible removals using this code (after yours) ``` perl my $total = 0; #foreach my $key (sort { $map{$b} <=> $map{$a} } keys %map) { foreach my $key (keys %map) { next if $map{$key} <= 1; $total += $map{$key} - 1; #printf "%d\t%s\n", $map{$key}, $key; } printf "\nTotal: %d\n", $total; ``` I had the `contains_class` thing commented out though.
Author
Owner

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

Adding contains_class() decreased it to 493062 (and it took 57s)

<!-- gh-comment-id:69257994 --> @magnumripper commented on GitHub (Jan 8, 2015): Adding contains_class() decreased it to 493062 (and it took 57s)
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

What we are looking for is finding 'base' words, in the proper order, that each word replaces the most original words from the wordlist based upon 'some' rule. So to do that (in an ideal manner), we would use an algorithm like I first mentioned, which is to fine the BEST overall word (against all rules), and add that word to our 'new' set of words, removing all of the words which that rule would have found. Then repeat the same steps. Now, the repeat really 'could' be improved a lot. We could re-compute data for each rule, by simply removing the words. So after the initial load, we find that adding the word 'password' removed 250000 lines, based upon rule X, then we remove all 250000 of those 'final wordlist' words, and update each of the rule sets, undoing those 250k words. Then the next best word is rockyou. Say some specific rule and that base-word removes 63500 original words that are still left. We then remove those 63500 words, and recompute all the rules removing these words.

New thought. When we 'find' a base-word, we should then run that base-word through EVERY rule, and remove all found words for that base word. So take password. Then simply play that word back through the wordlist, using every rule and whatever words are still left, removing each of them.

That would be a pretty big speedup. We know probably 1000 (or 2500) GOOD base words. We could play each of those original 'known' good base-words through each rule, and remove those items out of the original list, so that instead of loading 14.34 million words, we only load 3 or 4 million of them. That is a pretty huge improvement. I will look at something like that first. This really is a O(N^3) or possibly a O(N^4) problem. Reducing the size of input greatly improves this problem.

<!-- gh-comment-id:69263042 --> @jfoug commented on GitHub (Jan 8, 2015): What we are looking for is finding 'base' words, in the proper order, that each word replaces the most original words from the wordlist based upon 'some' rule. So to do that (in an ideal manner), we would use an algorithm like I first mentioned, which is to fine the BEST overall word (against all rules), and add that word to our 'new' set of words, removing all of the words which that rule would have found. Then repeat the same steps. Now, the repeat really 'could' be improved a lot. We could re-compute data for each rule, by simply removing the words. So after the initial load, we find that adding the word 'password' removed 250000 lines, based upon rule X, then we remove all 250000 of those 'final wordlist' words, and update each of the rule sets, undoing those 250k words. Then the next best word is rockyou. Say some specific rule and that base-word removes 63500 original words that are still left. We then remove those 63500 words, and recompute all the rules removing these words. New thought. When we 'find' a base-word, we should then run that base-word through EVERY rule, and remove all found words for that base word. So take password. Then simply play that word back through the wordlist, using every rule and whatever words are still left, removing each of them. That would be a pretty big speedup. We know probably 1000 (or 2500) GOOD base words. We could play each of those original 'known' good base-words through each rule, and remove those items out of the original list, so that instead of loading 14.34 million words, we only load 3 or 4 million of them. That is a pretty huge improvement. I will look at something like that first. This really is a O(N^3) or possibly a O(N^4) problem. Reducing the size of input greatly improves this problem.
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

The time may be limited upon memory (also the perl). I am using cygwin, and I ASSURE you, it is slow. I also only have 8GB on this box. More memory would almost certainly run quite a bit faster.

<!-- gh-comment-id:69263432 --> @jfoug commented on GitHub (Jan 8, 2015): The time may be limited upon memory (also the perl). I am using cygwin, and I ASSURE you, it is slow. I also only have 8GB on this box. More memory would almost certainly run quite a bit faster.
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

Side thought.

../run/pass_gen.pl raw-md5 -count=15000000 < rockyou.txt > rockyou.in

creates a quick 'input' file. (980mb). This took about a minute to create.

Then

../run/john -w=../run/password.lst -rules=jumbo rockyou.in -pot=password-lst.pot -form=raw-md5 >/dev/null

This took about 20s to load but only 10s to run.

$ ../run/john -w=../run/password.lst -rules=jumbo rockyou.in -pot=password-lst.pot -form=raw-md5 >/dev/null
Warning: poor OpenMP scalability for this hash type
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
642146g 0:00:00:03 14.30% (ETA: 16:49:30) 177437g/s 2526Kp/s 2526Kc/s 42330GC/s Forum486..Nirvana516
756521g 0:00:00:07 DONE (2015-01-08 16:49) 107490g/s 2654Kp/s 2654Kc/s 36736GC/s RAstAFAriaN..WINNIETHEPOOH
Use the "--show" option to display all of the cracked passwords reliably
Session completed
At Program Exit
MemDbg_Validate level 0 checking Passed

It only found 756521 hashes however (5%). I was expecting MUCH more than this to be removed.

<!-- gh-comment-id:69264907 --> @jfoug commented on GitHub (Jan 8, 2015): Side thought. ``` ../run/pass_gen.pl raw-md5 -count=15000000 < rockyou.txt > rockyou.in ``` creates a quick 'input' file. (980mb). This took about a minute to create. Then ``` ../run/john -w=../run/password.lst -rules=jumbo rockyou.in -pot=password-lst.pot -form=raw-md5 >/dev/null ``` This took about 20s to load but only 10s to run. ``` $ ../run/john -w=../run/password.lst -rules=jumbo rockyou.in -pot=password-lst.pot -form=raw-md5 >/dev/null Warning: poor OpenMP scalability for this hash type Will run 8 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status 642146g 0:00:00:03 14.30% (ETA: 16:49:30) 177437g/s 2526Kp/s 2526Kc/s 42330GC/s Forum486..Nirvana516 756521g 0:00:00:07 DONE (2015-01-08 16:49) 107490g/s 2654Kp/s 2654Kc/s 36736GC/s RAstAFAriaN..WINNIETHEPOOH Use the "--show" option to display all of the cracked passwords reliably Session completed At Program Exit MemDbg_Validate level 0 checking Passed ``` It only found 756521 hashes however (5%). I was expecting MUCH more than this to be removed.
Author
Owner

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

Cracking 750K/5% of a real password database using a 3546 line wordlist is a feat. Also, the real database had lots and lots of dupe passwords so it would be a LOT more than that.

<!-- gh-comment-id:69265685 --> @magnumripper commented on GitHub (Jan 8, 2015): Cracking 750K/5% of a real password database using a 3546 line wordlist is a feat. Also, the real database had lots and lots of dupe passwords so it would be a LOT more than that.
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

Ok, I am not 100% sure things are working properly, but it 'could' be due to other words being in password.lst file.

This data was generated from -rules:jumbo using password.lst

$ grep -i password password-lst.pot  | wc
   1277    1277   71004

This was a complete new run, using 'just' the line "password" in a input file:

$ echo -n password | ../run/john -pipe -rules=jumbo rockyou.in -pot=password.pot -form=raw-md5 >/dev/null
1115g 0:00:00:00 DONE (2015-01-08 16:56) 12528g/s 65235p/s 65235c/s 83279MC/s password..PASSWORD
<!-- gh-comment-id:69266081 --> @jfoug commented on GitHub (Jan 8, 2015): Ok, I am not 100% sure things are working properly, but it 'could' be due to other words being in password.lst file. This data was generated from -rules:jumbo using password.lst ``` $ grep -i password password-lst.pot | wc 1277 1277 71004 ``` This was a complete new run, using 'just' the line "password" in a input file: ``` $ echo -n password | ../run/john -pipe -rules=jumbo rockyou.in -pot=password.pot -form=raw-md5 >/dev/null 1115g 0:00:00:00 DONE (2015-01-08 16:56) 12528g/s 65235p/s 65235c/s 83279MC/s password..PASSWORD ```
Author
Owner

@jfoug commented on GitHub (Jan 8, 2015):

Yes, I know, the data that I am using is greatly reduced, since the duplication has been removed. This is rockyou 'unique' words. But I did expect a higher success with the -rules:jumbo AND a high quality wordlist.

<!-- gh-comment-id:69266226 --> @jfoug commented on GitHub (Jan 8, 2015): Yes, I know, the data that I am using is greatly reduced, since the duplication has been removed. This is rockyou 'unique' words. But I did expect a higher success with the -rules:jumbo AND a high quality wordlist.
Author
Owner

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

Try -rules:all and see how much better it gets...

<!-- gh-comment-id:69266330 --> @magnumripper commented on GitHub (Jan 8, 2015): Try -rules:all and see how much better it gets...
Author
Owner

@frank-dittrich commented on GitHub (Jan 8, 2015):

And "unrule" password.lst first!

<!-- gh-comment-id:69266779 --> @frank-dittrich commented on GitHub (Jan 8, 2015): And "unrule" password.lst first!
Author
Owner

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

Here is a 'new' better baseword sorted list:

run epixoip baseword 1-liner:

cat rockyou.dic | tr A-Z a-z | sed 's/^[^a-z]//g; s/[^a-z]$//g; y/112345677890@$!#/ilzeasbzvbgoasih/; s/[^a-z]//g; /^$/d' >basewords

sort it by count:

LC_ALL='C' sort < basewords | LC_ALL='C' uniq -c -d | sort -n -r > basewords.cnt

head -7830 basewords.cnt | awk '{print $2;}' > bestbase.lst

7830 was all lines with 100 or more 'base' words.

Now I will run with THIS file, and see how things go (both jumbo, and then all rules), and follow up.

<!-- gh-comment-id:69274963 --> @jfoug commented on GitHub (Jan 9, 2015): Here is a 'new' better baseword sorted list: run epixoip baseword 1-liner: cat rockyou.dic | tr A-Z a-z | sed 's/^[^a-z]_//g; s/[^a-z]_$//g; y/112345677890@\$!#/ilzeasbzvbgoasih/; s/[^a-z]//g; /^$/d' >basewords sort it by count: LC_ALL='C' sort < basewords | LC_ALL='C' uniq -c -d | sort -n -r > basewords.cnt head -7830 basewords.cnt | awk '{print $2;}' > bestbase.lst 7830 was all lines with 100 or more 'base' words. Now I will run with THIS file, and see how things go (both jumbo, and then all rules), and follow up.
Author
Owner

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

$ ../run/john -rules:jumbo -w=bestbase.lst rockyou.in -form=raw-md5 -pot=ru-jumbo-rules-bestbase.pot >/dev/null
1170310g 0:00:00:12 11.23% (ETA: 18:32:17) 93251g/s 1185Kp/s 1185Kc/s 16835GC/s far831..raptor835
1477174g 0:00:00:29 DONE (2015-01-08 18:31) 49699g/s 1382Kp/s 1382Kc/s 18735GC/s PiNkPANTheR..CHEEKYMONKEY

So here, we have 10% processed with -rules:jumbo and the top 7800 'base' words. This shows that the 3500 words in 'password.lst' is very strong, since it was general words, and not specifically FROM the RU list. These 7800, were specially built data right from the RU data.

<!-- gh-comment-id:69277399 --> @jfoug commented on GitHub (Jan 9, 2015): ``` $ ../run/john -rules:jumbo -w=bestbase.lst rockyou.in -form=raw-md5 -pot=ru-jumbo-rules-bestbase.pot >/dev/null 1170310g 0:00:00:12 11.23% (ETA: 18:32:17) 93251g/s 1185Kp/s 1185Kc/s 16835GC/s far831..raptor835 1477174g 0:00:00:29 DONE (2015-01-08 18:31) 49699g/s 1382Kp/s 1382Kc/s 18735GC/s PiNkPANTheR..CHEEKYMONKEY ``` So here, we have 10% processed with -rules:jumbo and the top 7800 'base' words. This shows that the 3500 words in 'password.lst' is very strong, since it was general words, and not specifically FROM the RU list. These 7800, were specially built data right from the RU data.
Author
Owner

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

Here's rockyou with original dupes

$ ../run/pass_gen.pl dummy -count=99000000 < rockyou.original.dlst > rockyou.dupes.dummy

$ rm -f test.pot && ../run/john -w -rules=jumbo rockyou.dupes.dummy -pot=test.pot -form=dummy -verb=1
Loaded 14343707 password hashes with no different salts (dummy [N/A])
Press 'q' or Ctrl-C to abort, almost any other key for status
756521g 0:00:00:14 DONE (2015-01-09 00:15) 52030g/s 1285Kp/s 1285Kc/s 18365GC/s WINNIethEpOOH..WINNIETHEPOOH
Session completed

$ ../run/john rockyou.dupes.dummy -pot=test.pot -form=dummy -show | tail -1
9417519 password hashes cracked, 23185176 left

That's over 28% of the passwords using a 3500 line wordlist. Pure awsomeness!

And using -rules=all

$ rm -f test2.pot && ../run/john -w -rules=all rockyou.dupes.dummy -pot=test2.pot -form=dummy -verb=1
Loaded 14343707 password hashes with no different salts (dummy [N/A])
Press 'q' or Ctrl-C to abort, almost any other key for status
1362862g 0:01:08:43 DONE (2015-01-09 01:27) 330.5g/s 5883Kp/s 5883Kc/s 77075GC/s informix999999..sss999999
Session completed

$ ../run/john rockyou.dupes.dummy -pot=test2.pot -form=dummy -show | tail -1
10870135 password hashes cracked, 21732560 left

This took it past 33%. Solar's wordlist is amazing. Add -loopback for even more cracks without actually adding any new data. I can't test this, it will take a month using -rules=all but it cracked yet another 3.5 million passwords (counting dupes, it was 1 million unique ones) in three minutes which took the total crack rate over 44%. This is almost unbelievably good.

<!-- gh-comment-id:69277689 --> @magnumripper commented on GitHub (Jan 9, 2015): Here's rockyou _with_ original dupes ``` $ ../run/pass_gen.pl dummy -count=99000000 < rockyou.original.dlst > rockyou.dupes.dummy $ rm -f test.pot && ../run/john -w -rules=jumbo rockyou.dupes.dummy -pot=test.pot -form=dummy -verb=1 Loaded 14343707 password hashes with no different salts (dummy [N/A]) Press 'q' or Ctrl-C to abort, almost any other key for status 756521g 0:00:00:14 DONE (2015-01-09 00:15) 52030g/s 1285Kp/s 1285Kc/s 18365GC/s WINNIethEpOOH..WINNIETHEPOOH Session completed $ ../run/john rockyou.dupes.dummy -pot=test.pot -form=dummy -show | tail -1 9417519 password hashes cracked, 23185176 left ``` That's over 28% of the passwords using a 3500 line wordlist. Pure awsomeness! And using -rules=all ``` $ rm -f test2.pot && ../run/john -w -rules=all rockyou.dupes.dummy -pot=test2.pot -form=dummy -verb=1 Loaded 14343707 password hashes with no different salts (dummy [N/A]) Press 'q' or Ctrl-C to abort, almost any other key for status 1362862g 0:01:08:43 DONE (2015-01-09 01:27) 330.5g/s 5883Kp/s 5883Kc/s 77075GC/s informix999999..sss999999 Session completed $ ../run/john rockyou.dupes.dummy -pot=test2.pot -form=dummy -show | tail -1 10870135 password hashes cracked, 21732560 left ``` This took it past 33%. Solar's wordlist is amazing. Add -loopback for even more cracks without actually adding any new data. I can't test this, it will take a month using -rules=all but it cracked yet another 3.5 million passwords (counting dupes, it was 1 million unique ones) in three minutes which took the total crack rate over 44%. This is almost unbelievably good.
Author
Owner

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

Add -loopback for even more cracks without actually adding any new data. I can't test this, it will take a month using -rules=all but it cracked yet another 3.5 million passwords (counting dupes, it was 1 million unique ones)

For -rules=jumbo it's much faster though. Starting with the 28% cracked with -w -rules=jumbo from above and running loopback:

$ ../run/john -loop -rules=jumbo rockyou.dupes.dummy -pot=test.pot -form=dummy -verb=1
Loaded 14343707 password hashes with no different salts (dummy [N/A])
Remaining 13587186 password hashes with no different salts
Press 'q' or Ctrl-C to abort, almost any other key for status
2444417g 0:00:26:58 DONE (2015-01-09 02:32) 1510g/s 2298Kp/s 2298Kc/s 26707GC/s WINNIETHEPOOHZ..winniethepooh19
Session completed

$ ../run/john rockyou.dupes.dummy -pot=test.pot -form=dummy -show | tail -1
16344475 password hashes cracked, 16258220 left

...we got over 50% of the passwords in no time using a 3500 line wordlist. Amazing!

<!-- gh-comment-id:69281784 --> @magnumripper commented on GitHub (Jan 9, 2015): > Add -loopback for even more cracks without actually adding any new data. I can't test this, it will take a month using -rules=all but it cracked yet another 3.5 million passwords (counting dupes, it was 1 million unique ones) For -rules=jumbo it's much faster though. Starting with the 28% cracked with -w -rules=jumbo from above and running loopback: ``` $ ../run/john -loop -rules=jumbo rockyou.dupes.dummy -pot=test.pot -form=dummy -verb=1 Loaded 14343707 password hashes with no different salts (dummy [N/A]) Remaining 13587186 password hashes with no different salts Press 'q' or Ctrl-C to abort, almost any other key for status 2444417g 0:00:26:58 DONE (2015-01-09 02:32) 1510g/s 2298Kp/s 2298Kc/s 26707GC/s WINNIETHEPOOHZ..winniethepooh19 Session completed $ ../run/john rockyou.dupes.dummy -pot=test.pot -form=dummy -show | tail -1 16344475 password hashes cracked, 16258220 left ``` ...we got **over 50% of the passwords** in no time using a 3500 line wordlist. Amazing!
Author
Owner

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

I added a perl script that does it the "epixoip way" plus removes dupes and outputs sorted by count. It's a very good start.

<!-- gh-comment-id:70282956 --> @magnumripper commented on GitHub (Jan 16, 2015): I added a perl script that does it the "epixoip way" plus removes dupes and outputs sorted by count. It's a very good start.
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#600
No description provided.