Add option for -debug-log. (#74)

* Add options for -disable-logging and -logfile.

Both of these options have to do with the logging surrounding issues
such as #39. Where in that issue the server was returning data after
the connection was closed. Therefore, I added two options one for
completely disabling all of the internal logging functionality aka
sending it to /dev/null. Another for writing the logging information
to a file so it can be retrieved later if need be.

* Changed to automatically disable internal logging.

Per the changes requested by @joohoi, changed to a single
flag `-debug-log` which will place all of the internal logging
into the specified file. If the file fails to be opened or is
not specified it will disable the logging.

* Update readme with the changes for -debug-log.
This commit is contained in:
Cory 2019-10-20 10:38:11 -05:00 committed by Joona Hoikkala
parent 44723e2b06
commit 492253b67b
2 changed files with 21 additions and 0 deletions

View file

@ -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

16
main.go
View file

@ -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()