From e911ea581dcf1f4319f5f3ca2f86bc1e02f77b21 Mon Sep 17 00:00:00 2001 From: edoardottt Date: Sun, 28 Nov 2021 12:43:58 +0100 Subject: [PATCH] update --- crawler/colly.go | 2 +- scanner/errors.go | 19 +++++++++++++++++++ scanner/secrets.go | 17 ++--------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/crawler/colly.go b/crawler/colly.go index 47741e8..603d4cf 100644 --- a/crawler/colly.go +++ b/crawler/colly.go @@ -346,7 +346,7 @@ func huntSecrets(secretsFile []string, target string, body string) []scanner.Sec func SecretsMatch(url string, body string, secretsFile []string) []scanner.SecretMatched { var secrets []scanner.SecretMatched if len(secretsFile) == 0 { - for _, secret := range scanner.GetRegexes() { + for _, secret := range scanner.GetSecretRegexes() { if matched, err := regexp.Match(secret.Regex, []byte(body)); err == nil && matched { re := regexp.MustCompile(secret.Regex) match := re.FindStringSubmatch(body) diff --git a/scanner/errors.go b/scanner/errors.go index f544cc8..2bb81c0 100644 --- a/scanner/errors.go +++ b/scanner/errors.go @@ -29,3 +29,22 @@ type ErrorMatched struct { Error Error Url string } + +//GetErrorRegexes returns all the error regexes +func GetErrorRegexes() []Error { + var regexes = []Error{ + { + "PHP error", + `(php warning|php error|include_path|undefined index|undefined variable|\\?php|expects parameter [0-9]*)`, + }, + { + "General error", + `(((fatal|critical|severe|high|medium) error)|uncaught exception)`, + }, + { + "Debug information", + `(Debug trace|stack trace\\:)`, + }, + } + return regexes +} diff --git a/scanner/secrets.go b/scanner/secrets.go index 9210859..a884438 100644 --- a/scanner/secrets.go +++ b/scanner/secrets.go @@ -39,8 +39,8 @@ type SecretMatched struct { Match string } -//GetRegexes returns all the regexes -func GetRegexes() []Secret { +//GetSecretRegexes returns all the secret regexes +func GetSecretRegexes() []Secret { var regexes = []Secret{ { "AWS Access Key", @@ -327,16 +327,3 @@ func GetRegexes() []Secret { } return regexes } - -//RemoveDuplicateSecrets removes duplicates from secrets found -func RemoveDuplicateSecrets(input []SecretMatched) []SecretMatched { - keys := make(map[string]bool) - list := []SecretMatched{} - for _, entry := range input { - if _, value := keys[entry.Url]; !value { - keys[entry.Url] = true - list = append(list, entry) - } - } - return list -}