Skip to content

Commit

Permalink
Add some rules optimizations (mostly rejection flags/commands).
Browse files Browse the repository at this point in the history
  • Loading branch information
magnumripper committed Dec 14, 2018
1 parent 059d4e6 commit 15163f4
Showing 1 changed file with 111 additions and 105 deletions.
216 changes: 111 additions & 105 deletions run/john.conf
Original file line number Diff line number Diff line change
Expand Up @@ -650,20 +650,20 @@ MaxDiff = 7
# These are currently Jumbo-specific.
[List.Rules:JumboSingle]
/?d @?d >4
/?d @?d M @?A Q >4
/?d @?d >4 M [lc] Q
/?d @?d M @?A Q >4 M [lc] Q
/?d @?d M @?A >4 Q
-c /?d @?d >4 M [lc] Q
-c /?d @?d M @?A >4 Q M [lc] Q
@?D Q >4
/?d @?d >3 <* $[0-9] Q
/?d @?d M >3 <* [lc] Q $[0-9] Q
/?d @?d >3 <- Az"12" Q
/?d @?d M >3 <- [lc] Q Az"12"
/?d @?d >3 Az"123" Q <+
/?d @?d M >3 [lc] Q Az"123" <+
/?d @?d >2 d Q <+
/?d @?d >2 M [lc] Q d<+
(?a )?d /?d 'p Xpz0
)?a (?d /?a 'p Xpz0
-c /?d @?d >3 <* M [lc] Q $[0-9]
/?d @?d >3 <- Az"12" <+ Q
-c /?d @?d >3 <- M [lc] Q Az"12" <+
/?d @?d >3 Az"123" <+ Q
-c /?d @?d >3 M [lc] Q Az"123" <+
/?d @?d >2 al d
-c /?d @?d >2 al M [lc] Q d
(?a )?d /?d a0 'p Xpz0
)?a (?d /?a a0 'p Xpz0


# "Single crack" mode rules
Expand All @@ -676,69 +676,69 @@ MaxDiff = 7
-s-c x** /?u l
# These were not included in crackers I've seen, but are pretty efficient,
# so I include them near the beginning
-<6 >6 '6
-<7 >7 '7 l
-<6 -c >6 '6 /?u l
-<5 >5 '5
-<6 ->6 >6 '6
-<7 ->7 >7 '7 l
-<6 ->6 -c >6 '6 /?u l
-<5 ->5 >5 '5

# Wedge the Jumbo-specific addons in here!
.include [List.Rules:JumboSingle]

# Weird order, eh? Can't do anything about it, the order is based on the
# number of successful cracks...
<* d
r c
-c <* (?a d c
-<5 -c >5 '5 /?u l
-c u Q
-c )?a r l
al d
a0 r c
-c al (?a d c
-<5 ->5 -c >5 '5 /?u l
-c a0 u Q
-c a0 )?a r l
-[:c] <* !?A \p1[lc] p
-c <* c Q d
-<7 -c >7 '7 /?u
-<4 >4 '4 l
-c <+ (?l c r
-c <+ )?l l Tm
-<3 >3 '3
-<4 -c >4 '4 /?u
-<3 -c >3 '3 /?u l
-c u Q r
<* d M 'l f Q
-c <* l Q d M 'l f Q
-c al c Q d
-<7 ->7 -c >7 '7 /?u
-<4 ->4 >4 '4 l
-c a0 (?l c r
-c a0 )?l l Tm
-<3 ->3 >3 '3
-<4 ->4 -c >4 '4 /?u
-<3 ->3 -c >3 '3 /?u l
-c a0 u Q r
al d M 'l f Q
-c al l Q d M 'l f Q
# About 50% of single-mode-crackable passwords get cracked by now...
# >2 x12 ... >8 x18
>[2-8] x1\1
>9 \[
->[3-9] >\p[2-8] x1\0
->9 >9 \[
# >3 x22 ... >9 x28
>[3-9] x2\p[2-8]
->[4-9A] >\p[3-9] x2\p[2-8]
# >4 x32 ... >9 x37
>[4-9] x3\p[2-7]
->[5-9A] >\p[4-9] x3\p[2-7]
# >2 x12 /?u l ... >8 x18 /?u l
-c >[2-8] x1\1 /?u l
-c >9 \[ /?u l
-c ->[3-9] >\p[2-8] x1\0 /?u l
-c ->9 >9 \[ /?u l
# >3 x22 /?u l ... >9 x28 /?u l
-c >[3-9] x2\p[2-8] /?u l
-c ->[4-9A] >\p[3-9] x2\p[2-8] /?u l
# >4 x32 /?u l ... >9 x37 /?u l
-c >[4-9] x3\p[2-7] /?u l
-c ->[5-9A] >\p[4-9] x3\p[2-7] /?u l
# Now to the suffix stuff...
<* l $[1-9!0a-rt-z"-/:-@\[-`{-~]
-c <* (?a c $[1-9!0a-rt-z"-/:-@\[-`{-~]
-[:c] <* !?A (?\p1[za] \p1[lc] $s M 'l p Q X0z0 'l $s
-[:c] <* /?A (?\p1[za] \p1[lc] $s
<* l r $[1-9!]
-c <* /?a u $[1-9!]
-[:c] <- (?\p1[za] \p1[lc] Az"'s"
-[:c] <- (?\p1[za] \p1[lc] Az"!!"
-[:c] (?\p1[za] \p1[lc] $! <- Az"!!"
a1 l $[1-9!0a-rt-z"-/:-@\[-`{-~]
-c a1 (?a c $[1-9!0a-rt-z"-/:-@\[-`{-~]
-[:c] a1 !?A (?\p1[za] \p1[lc] $s M 'l p Q X0z0 'l $s
-[:c] a1 /?A (?\p1[za] \p1[lc] $s
a1 l r $[1-9!]
-c a1 /?a u $[1-9!]
-[:c] a2 (?\p1[za] \p1[lc] Az"'s"
-[:c] a2 (?\p1[za] \p1[lc] Az"!!"
-[:c] a3 (?\p1[za] \p1[lc] Az"!!!"
# Removing vowels...
-[:c] /?v @?v >2 (?\p1[za] \p1[lc]
/?v @?v >2 <* d
-[:c] b1 /?v @?v >2 (?\p1[za] \p1[lc]
/?v @?v >2 al d
# crack -> cracked, crack -> cracking
<* l [PI]
-c <* l [PI] (?a c
# mary -> marie
-[:c] <* (?\p1[za] \p1[lc] )y omi $e
-[:c] a1 (?\p1[za] \p1[lc] )y omi $e
# marie -> mary
-[:c] (?\p1[za] \p1[lc] )e \] <+ )i val1 oay
-[:c] b1 (?\p1[za] \p1[lc] )e \] )i val1 oay
# The following are some 3l33t rules
-[:c] l /[aelos] s\0\p[4310$] (?\p1[za] \p1[:c]
-[:c] l /a /[elos] sa4 s\0\p[310$] (?\p1[za] \p1[:c]
Expand Down Expand Up @@ -878,7 +878,7 @@ l Az"[1-90][0-9][0-9]" <+
# Capitalize pure alphabetic words and append '1'
-c <* >2 !?A c $1
# Duplicate reasonably short pure alphabetic words (fred -> fredfred)
<7 >1 !?A l d
<7 >1 al !?A l d
# Lowercase and reverse pure alphabetic words
>3 !?A l M r Q
# Prefix pure alphabetic words with '1'
Expand All @@ -894,13 +894,13 @@ l Az"[1-90][0-9][0-9]" <+
# Words containing whitespace, which is then squeezed out, lowercase
/?w @?w >3 l
# Capitalize and duplicate short pure alphabetic words (fred -> FredFred)
-c <7 >1 !?A c d
-c <7 >1 al !?A c d
# Capitalize and reverse pure alphabetic words (fred -> derF)
-c <+ >2 !?A c r
# Reverse and capitalize pure alphabetic words (fred -> Derf)
-c >2 !?A l M r Q c
# Lowercase and reflect pure alphabetic words (fred -> fredderf)
<7 >1 !?A l d M 'l f Q
<7 >1 al !?A l d M 'l f Q
# Uppercase the last letter of pure alphabetic words (fred -> freD)
-c <+ >2 !?A l M r Q c r
# Prefix pure alphabetic words with '2' or '4'
Expand All @@ -922,40 +922,40 @@ l Az"[1-90][0-9][0-9]" <+
# given already cracked DES-based LM hashes. Use --rules=NT to use this.
[List.Rules:NT]
:
-c >@ T0
-c ->2 >@ >1 T1QT[z0]
-c ->3 >@ >2 T2QT[z0]T[z1]
-c ->4 >@ >3 T3QT[z0]T[z1]T[z2]
-c ->5 >@ >4 T4QT[z0]T[z1]T[z2]T[z3]
-c ->6 >@ >5 T5QT[z0]T[z1]T[z2]T[z3]T[z4]
-c ->7 >@ >6 T6QT[z0]T[z1]T[z2]T[z3]T[z4]T[z5]
-c ->8 >@ >7 T7QT[z0]T[z1]T[z2]T[z3]T[z4]T[z5]T[z6]
-c ->9 >@ >8 T8QT[z0]T[z1]T[z2]T[z3]T[z4]T[z5]T[z6]T[z7]
-c ->A >@ >9 T9QT[z0]T[z1]T[z2]T[z3]T[z4]T[z5]T[z6]T[z7]T[z8]
-c ->B >@ >A TAQT[z0]T[z1]T[z2]T[z3]T[z4]T[z5]T[z6]T[z7]T[z8]T[z9]
-c ->C >@ >B TBQT[z0]T[z1]T[z2]T[z3]T[z4]T[z5]T[z6]T[z7]T[z8]T[z9]T[zA]
-c ->D >@ >C TCQT[z0]T[z1]T[z2]T[z3]T[z4]T[z5]T[z6]T[z7]T[z8]T[z9]T[zA]T[zB]
-c ->E >@ >D TDQT[z0]T[z1]T[z2]T[z3]T[z4]T[z5]T[z6]T[z7]T[z8]T[z9]T[zA]T[zB]T[z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]W[z1]W[z2]W[z3]W[z4]W[z5]W[z6]W[z7]W[z8]W[z9]W[zA]W[zB]W[zC]W[zD]
->G a0 WFQW[z0]W[z1]W[z2]W[z3]W[z4]W[z5]W[z6]W[z7]W[z8]W[z9]W[zA]W[zB]W[zC]W[zD]W[zE]

# Used for loopback. This rule will produce candidates "PASSWOR" and "D" for
# an input of "PASSWORD" (assuming LM, which has halves of length 7).
Expand All @@ -966,44 +966,50 @@ l Az"[1-90][0-9][0-9]" <+
# Some Office <=2003 files have passwords truncated at 15
[List.Rules:OldOffice]
:
->F>F'F
->F -<F >F 'F

# Rules from Hash Runner 2014
[List.Rules:o1]
o[0-9A-Z][ -~]
# o[0-9A-Z][ -~]
->\r[1-9A-ZZ] >\p[0-9A-Z] o\0[ -~] Q

[List.Rules:o2]
o[0-9A-E][ -~] Q M o[0-9A-E][ -~] Q
# o[0-9A-E][ -~] Q M o[0-9A-E][ -~] Q
->[1-9A-F] ->[1-9A-F] >\p1[0-9A-E] >\p2[0-9A-E] o\3[ -~] Q M o\4[ -~] Q

[List.Rules:o3]
o[0-9][ -~] Q M o[0-9][ -~] Q M o[0-9][ -~] Q
# o[0-9][ -~] Q M o[0-9][ -~] Q M o[0-9][ -~] Q
->[1-9A] ->[1-9A] ->[1-9A] >\p1[0-9] >\p2[0-9] >\p3[0-9] o\4[ -~] Q M o\5[ -~] Q M o\6[ -~] Q

[List.Rules:o]
o[0-9A-Z][ -~]
o[0-9A-E][ -~] Q M o[0-9A-E][ -~] Q
.include [List.Rules:o1]
.include [List.Rules:o2]

[List.Rules:i1]
i[0-9A-Z][ -~]
# i[0-9A-Z][ -~]
->\r[2-9A-ZZZ] >\p1[0-9A-Z] i\0[ -~]

[List.Rules:i2]
i[0-9A-E][ -~] i[0-9A-E][ -~]
# i[0-9A-E][ -~] i[0-9A-E][ -~]
->[2-9A-G] ->[2-9A-G] >\p1[0-9A-E] >\p2[0-9A-E] i\3[ -~] i\4[ -~]

[List.Rules:i3]
i[0-9][ -~] i[0-9][ -~] i[0-9][ -~]
# i[0-9][ -~] i[0-9][ -~] i[0-9][ -~]
->[4-9A-D] ->[4-9A-D] ->[4-9A-D] >\p1[0-9] >\p2[0-9] >\p3[0-9] i\4[ -~] i\5[ -~] i\6[ -~]

[List.Rules:i]
i[0-9A-Z][ -~]
i[0-9A-E][ -~] i[0-9A-E][ -~]
.include [List.Rules:i1]
.include [List.Rules:i2]

[List.Rules:oi]
o[0-9A-Z][ -~]
i[0-9A-Z][ -~]
o[0-9A-E][ -~] Q M o[0-9A-E][ -~] Q
i[0-9A-E][ -~] i[0-9A-E][ -~]
.include [List.Rules:o1]
.include [List.Rules:i1]
.include [List.Rules:o2]
.include [List.Rules:i2]

[List.Rules:T9]
/?D l sa2 sb2 sc2 sd3 se3 sf3 sg4 sh4 si4 sj5 sk5 sl5 sm6 sn6 so6 sp7 sq7 sr7 ss7 st8 su8 sv8 sw9 sx9 sy9 sz9 s?D*
/?D l sa2 sb2 sc2 sd3 se3 sf3 sg4 sh4 si4 sj5 sk5 sl5 sm6 sn6 so6 sp7 sq7 sr7 ss7 st8 su8 sv8 sw9 sx9 sy9 sz9 /?D s?D#
a0 /?D l sa2 sb2 sc2 sd3 se3 sf3 sg4 sh4 si4 sj5 sk5 sl5 sm6 sn6 so6 sp7 sq7 sr7 ss7 st8 su8 sv8 sw9 sx9 sy9 sz9 s?D*
a0 /?D l sa2 sb2 sc2 sd3 se3 sf3 sg4 sh4 si4 sj5 sk5 sl5 sm6 sn6 so6 sp7 sq7 sr7 ss7 st8 su8 sv8 sw9 sx9 sy9 sz9 /?D s?D#

# A few rule sets from hashcat (taken as-is from https://github.com/hashcat/)
#
Expand Down Expand Up @@ -1073,7 +1079,7 @@ i[0-9A-E][ -~] i[0-9A-E][ -~]
+m
-m
!! hashcat logic OFF
>1 ]
b1 ]

# For Single Mode against fast hashes
[List.Rules:Single-Extra]
Expand Down

2 comments on commit 15163f4

@solardiz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@magnumripper Have you confirmed this produces the exact same lists of candidate passwords that it did before, on large and weird enough input and with different settings (per-hash-type flags, max lengths)?

I'm concerned e.g. the added -c before lines with [lc] will probably miss candidate passwords that we would have produced previously if there's no corresponding line working on the non-case-altered input word. Maybe you meant to add the -c conditionally to one of the l or c. I mean lines like:

-c /?d @?d >3 <* M [lc] Q $[0-9]

where you could have needed to use my approach of:

-[:c] /?d @?d >3 <* M \p1[lc] Q $[0-9]

@magnumripper
Copy link
Member Author

@magnumripper magnumripper commented on 15163f4 Dec 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did test it and verify but I probably forgot about the FMT_CASE thing. I'll hack -stdout to announce itself as case insignificant and see what happens.

I opened #3517 for these potential issues.

Please sign in to comment.