diff --git a/README.md b/README.md index 23c28bf..04baf82 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,8 @@ To define the test case for ffuf, use the keyword `FUZZ` anywhere in the URL (`- Wordlist file path or - to read from standard input -x string HTTP Proxy URL + -debug-log string + Write the debug logging information to the specified file. ``` eg. `ffuf -u https://example.org/FUZZ -w /path/to/wordlist` @@ -186,10 +188,13 @@ The only dependency of ffuf is Go 1.11. No dependencies outside of Go standard l - New - New CLI flag: -l, shows target location of redirect responses - New CLI flac: -acc, custom auto-calibration strings + - New CLI flag: -debug-log, writes the debug logging to the specified file. + - Changed - New CLI flag: -i, dummy flag that does nothing. for compatibility with copy as curl. - New CLI flag: -b/--cookie, cookie data for compatibility with copy as curl. - Filtering and matching by status code, response size or word count now allow using ranges in addition to single values + - The internal logging information to be discarded, and can be written to a file with the new `-debug-log` flag. - v0.10 diff --git a/main.go b/main.go index 68c2962..9971fa4 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,8 @@ import ( "context" "flag" "fmt" + "io/ioutil" + "log" "net/http" "net/url" "os" @@ -34,6 +36,7 @@ type cliOptions struct { cookies multiStringFlag AutoCalibrationStrings multiStringFlag showVersion bool + debugLog string } type multiStringFlag []string @@ -94,11 +97,24 @@ func main() { flag.IntVar(&conf.Threads, "t", 40, "Number of concurrent threads.") flag.IntVar(&conf.Timeout, "timeout", 10, "HTTP request timeout in seconds.") flag.BoolVar(&opts.showVersion, "V", false, "Show version information.") + flag.StringVar(&opts.debugLog, "debug-log", "", "Write all of the internal logging to the specified file.") flag.Parse() if opts.showVersion { fmt.Printf("ffuf version: %s\n", ffuf.VERSION) os.Exit(0) } + if len(opts.debugLog) != 0 { + f, err := os.OpenFile(opts.debugLog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Fprintf(os.Stderr, "Disabling logging, encountered error(s): %s\n", err) + log.SetOutput(ioutil.Discard) + } else { + log.SetOutput(f) + defer f.Close() + } + } else { + log.SetOutput(ioutil.Discard) + } if err := prepareConfig(&opts, &conf); err != nil { fmt.Fprintf(os.Stderr, "Encountered error(s): %s\n", err) flag.Usage()