From 792d5599128300ac582c626e4a77ce61cfed2e23 Mon Sep 17 00:00:00 2001 From: nseratt Date: Mon, 18 Nov 2019 16:19:45 -0500 Subject: [PATCH 1/2] added arg for regexignore to exclude results where the html body matches a provided regex pattern example usage: --regexignore "(Page not found|error)" --- args.go | 11 ++++++++++- main.go | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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 <status> Save only responses with specific status code\n" h += " -t, --timeout <millis> Set the HTTP timeout (default: 10000)\n" h += " -v, --verbose Verbose mode\n" - h += " -X, --method <method> HTTP method (default: GET)\n\n" + h += " -X, --method <method> HTTP method (default: GET)\n" + h += " -x, --regexignore <string> 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..3e14e52 100644 --- a/main.go +++ b/main.go @@ -93,6 +93,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) From 7a2bd8a02d61f543b9bae8e5d9c5e6e712e2d6d8 Mon Sep 17 00:00:00 2001 From: nseratt <nseratt@gmail.com> Date: Mon, 18 Nov 2019 16:30:01 -0500 Subject: [PATCH 2/2] Update main.go --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 3e14e52..7b097a7 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "path/filepath" "sync" "time" + "regexp" ) const (