diff --git a/args.go b/args.go index 90cca52..e09d060 100644 --- a/args.go +++ b/args.go @@ -54,6 +54,7 @@ type config struct { paths string hosts string output string + regexignore string noHeaders bool requester requester @@ -115,6 +116,12 @@ func processArgs() config { flag.BoolVar(&verbose, "verbose", false, "") flag.BoolVar(&verbose, "v", false, "") + regexignore := "" + flag.StringVar(®exignore, "regexignore", "", "") + flag.StringVar(®exignore, "x", "", "") + + + flag.Parse() // paths might be in a file, or it might be a single value @@ -156,6 +163,7 @@ func processArgs() config { hosts: hosts, output: output, noHeaders: noHeaders, + regexignore: regexignore, } } @@ -176,7 +184,8 @@ func init() { h += " -s, --savestatus Save only responses with specific status code\n" h += " -t, --timeout Set the HTTP timeout (default: 10000)\n" h += " -v, --verbose Verbose mode\n" - h += " -X, --method HTTP method (default: GET)\n\n" + h += " -X, --method HTTP method (default: GET)\n" + h += " -x, --regexignore Ignore results where the body matches a regex pattern\n\n" h += "Defaults:\n" h += " pathsFile: ./paths\n" diff --git a/main.go b/main.go index f2a73a2..7b097a7 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "path/filepath" "sync" "time" + "regexp" ) const ( @@ -93,6 +94,14 @@ func main() { continue } + if c.regexignore != "" { + matched, _ := regexp.MatchString(c.regexignore,res.String()) + + if matched { + continue + } + } + path, err := res.save(c.output, c.noHeaders) if err != nil { fmt.Fprintf(os.Stderr, "failed to save file: %s\n", err)