Skip to content

Commit

Permalink
revert a lot of the hotfixes for a much simpler solution; fixes many …
Browse files Browse the repository at this point in the history
…hashes

we just prepend the case-insensitive flag in our checkRegex wrapper
  • Loading branch information
CPunch committed Dec 18, 2023
1 parent 2680db4 commit ed82609
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ func checkRegex(regex, input string) bool {
var rexp *regexp.Regexp
val, ok := regexPool.Load(regex)
if !ok {
rexp = regexp.MustCompile(regex)
// we also set the case-insensitive flag here
rexp = regexp.MustCompile("(?i)" + regex)
regexPool.Store(regex, rexp)
} else {
rexp = val.(*regexp.Regexp)
Expand Down Expand Up @@ -108,7 +109,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^[a-zA-Z0-9\/.]{13}$`, input)
return checkRegex(`^[a-z0-9\/.]{13}$`, input)
},
mode: []HashInfo{
{"DES(Unix)", 1500, "descrypt", false},
Expand All @@ -118,7 +119,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^[a-f0-9]{16}$`, input)
return checkRegex(`(?i)^[a-f0-9]{16}$`, input)
},
mode: []HashInfo{
{"MySQL323", 200, "mysql", false},
Expand All @@ -131,7 +132,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^[a-zA-Z0-9\/.]{16}$`, input)
return checkRegex(`(?i)^[a-z0-9\/.]{16}$`, input)
},
mode: []HashInfo{
{"Cisco-PIX(MD5)", 2400, "pix-md5", false},
Expand Down Expand Up @@ -265,7 +266,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^\$1\$[a-zA-Z0-9\/.]{0,8}\$[a-zA-Z0-9\/.]{22}(:.*)?$`, input)
return checkRegex(`^\$1\$[a-z0-9\/.]{0,8}\$[a-z0-9\/.]{22}(:.*)?$`, input)
},
mode: []HashInfo{
{"MD5 Crypt", 500, "md5crypt", false},
Expand All @@ -283,7 +284,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^\$H\$[a-zA-Z0-9]{30}\.$`, input)
return checkRegex(`^\$H\$[a-z0-9]{30}\.$`, input)
},
mode: []HashInfo{
{"phpBB v3.x", 400, "phpass", false},
Expand All @@ -293,7 +294,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^\$P\$[a-zA-Z0-9]{30}\.$`, input)
return checkRegex(`^\$P\$[a-z0-9]{30}\.$`, input)
},
mode: []HashInfo{
{"Wordpress ≥ v2.6.2", 400, "phpass", false},
Expand All @@ -312,7 +313,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^\$apr1\$[a-zA-Z0-9\/.]{0,8}\$[a-zA-Z0-9\/.]{22}$`, input)
return checkRegex(`^\$apr1\$[a-z0-9\/.]{0,8}\$[a-z0-9\/.]{22}$`, input)
},
mode: []HashInfo{
{"MD5(APR)", 1600, "", false},
Expand Down Expand Up @@ -796,7 +797,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^\$6\$(rounds=[0-9]+\$)?[a-zA-Z0-9\/.]{0,16}\$[a-zA-Z0-9\/.]{86}$`, input)
return checkRegex(`^\$6\$(rounds=[0-9]+\$)?[a-z0-9\/.]{0,16}\$[a-z0-9\/.]{86}$`, input)
},
mode: []HashInfo{
{"SHA-512 Crypt", 1800, "sha512crypt", false},
Expand Down Expand Up @@ -960,7 +961,7 @@ var (
},
{
match: func(input string) bool {
return checkRegex(`^[a-zA-Z0-9\/.]{16}([:$].{1,})?$`, input)
return checkRegex(`^[a-z0-9\/.]{16}([:$].{1,})?$`, input)
},
mode: []HashInfo{
{"Cisco-ASA(MD5)", 2410, "asa-md5", false},
Expand Down

0 comments on commit ed82609

Please sign in to comment.