diff --git a/internal/slice/slice.go b/internal/slice/slice.go index fe63387..82b47cf 100644 --- a/internal/slice/slice.go +++ b/internal/slice/slice.go @@ -118,5 +118,6 @@ func Contains(slice []string, str string) bool { return true } } + return false } diff --git a/pkg/crawler/colly.go b/pkg/crawler/colly.go index b8e4c56..8ac73cf 100644 --- a/pkg/crawler/colly.go +++ b/pkg/crawler/colly.go @@ -151,12 +151,14 @@ func New(scan *Scan) *Results { filetype := &scanner.FileType{} // Skip if no scanning is enabled - if !(scan.EndpointsFlag || scan.SecretsFlag || (1 <= scan.FileType && scan.FileType <= 7) || scan.ErrorsFlag || scan.InfoFlag) { + if !(scan.EndpointsFlag || scan.SecretsFlag || (1 <= scan.FileType && scan.FileType <= 7) || + scan.ErrorsFlag || scan.InfoFlag) { return } // HERE SCAN FOR SECRETS - if scan.SecretsFlag && lengthOk && !sliceUtils.Contains(scan.IgnoreExtensions, urlUtils.GetURLExtension(r.Request.URL)) { + if scan.SecretsFlag && lengthOk && + !sliceUtils.Contains(scan.IgnoreExtensions, urlUtils.GetURLExtension(r.Request.URL)) { secretsSlice := huntSecrets(r.Request.URL.String(), bodyStr, &scan.SecretsSlice) results.Secrets = append(results.Secrets, secretsSlice...) secrets = append(secrets, secretsSlice...) diff --git a/pkg/input/flags.go b/pkg/input/flags.go index a9254b4..e9e05d8 100644 --- a/pkg/input/flags.go +++ b/pkg/input/flags.go @@ -97,7 +97,8 @@ type Input struct { StoreResp bool // MaxDepth specifies the maximum level the crawler will follow from the initial target URL MaxDepth int - // IgnoreExtensions specifies which extensions must be ignored while scanning (Default: png,jpg,jpeg,gif,webp,woff,woff2,tiff,tif) + // IgnoreExtensions specifies which extensions must be ignored while scanning + // (Default: png,jpg,jpeg,gif,webp,woff,woff2,tiff,tif) IgnoreExtensions StringSlice } @@ -150,13 +151,14 @@ func ScanFlag() Input { maxDepth := flag.Int("md", 0, "Maximum depth level the crawler will follow from the initial target URL.") var ignoreExtensions StringSlice + flag.Var(&ignoreExtensions, "ie", "Comma-separated list of extensions to ignore while scanning") flag.Parse() // Default Extensions to filter if ignoreExtensions == nil { - ignoreExtensions.Set(DefaultIgnoreExtensions) + _ = ignoreExtensions.Set(DefaultIgnoreExtensions) } result := Input{ diff --git a/pkg/input/stringslice.go b/pkg/input/stringslice.go index 163b2ba..0c74c41 100644 --- a/pkg/input/stringslice.go +++ b/pkg/input/stringslice.go @@ -7,7 +7,7 @@ import ( sliceUtils "github.com/edoardottt/cariddi/internal/slice" ) -// StringSlice is a custom flag type for []string +// StringSlice is a custom flag type for []string. type StringSlice []string func (s *StringSlice) String() string { diff --git a/pkg/output/html.go b/pkg/output/html.go index 2f6542f..0434ef9 100644 --- a/pkg/output/html.go +++ b/pkg/output/html.go @@ -130,8 +130,6 @@ func WriteSummaryCard(filename string, results, secrets, endpoints, extensions, os.Exit(1) } - defer file.Close() - content := fmt.Sprintf(`

Scan Summary

Scan timestamp: %s

@@ -148,7 +146,9 @@ func WriteSummaryCard(filename string, results, secrets, endpoints, extensions, _, err = file.WriteString(content) if err != nil { - log.Fatal(err) + file.Close() + log.Println(err) + os.Exit(1) } file.Close() diff --git a/pkg/output/output.go b/pkg/output/output.go index e116822..7dae595 100644 --- a/pkg/output/output.go +++ b/pkg/output/output.go @@ -91,9 +91,12 @@ func TxtOutput(flags input.Input, finalResults []string, finalSecret []scanner.S for _, elem := range finalEndpoints { for _, parameter := range elem.Parameters { var sb strings.Builder + sb.WriteString(parameter.Parameter) + if len(parameter.Attacks) > 0 { sb.WriteString(" -") + for _, attack := range parameter.Attacks { sb.WriteString(" ") sb.WriteString(attack)