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:
parent
44723e2b06
commit
492253b67b
@ -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
|
Wordlist file path or - to read from standard input
|
||||||
-x string
|
-x string
|
||||||
HTTP Proxy URL
|
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`
|
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
|
||||||
- New CLI flag: -l, shows target location of redirect responses
|
- New CLI flag: -l, shows target location of redirect responses
|
||||||
- New CLI flac: -acc, custom auto-calibration strings
|
- New CLI flac: -acc, custom auto-calibration strings
|
||||||
|
- New CLI flag: -debug-log, writes the debug logging to the specified file.
|
||||||
|
|
||||||
- Changed
|
- Changed
|
||||||
- New CLI flag: -i, dummy flag that does nothing. for compatibility with copy as curl.
|
- 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.
|
- 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
|
- 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
|
- v0.10
|
||||||
|
|
||||||
|
|||||||
16
main.go
16
main.go
@ -4,6 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@ -34,6 +36,7 @@ type cliOptions struct {
|
|||||||
cookies multiStringFlag
|
cookies multiStringFlag
|
||||||
AutoCalibrationStrings multiStringFlag
|
AutoCalibrationStrings multiStringFlag
|
||||||
showVersion bool
|
showVersion bool
|
||||||
|
debugLog string
|
||||||
}
|
}
|
||||||
|
|
||||||
type multiStringFlag []string
|
type multiStringFlag []string
|
||||||
@ -94,11 +97,24 @@ func main() {
|
|||||||
flag.IntVar(&conf.Threads, "t", 40, "Number of concurrent threads.")
|
flag.IntVar(&conf.Threads, "t", 40, "Number of concurrent threads.")
|
||||||
flag.IntVar(&conf.Timeout, "timeout", 10, "HTTP request timeout in seconds.")
|
flag.IntVar(&conf.Timeout, "timeout", 10, "HTTP request timeout in seconds.")
|
||||||
flag.BoolVar(&opts.showVersion, "V", false, "Show version information.")
|
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()
|
flag.Parse()
|
||||||
if opts.showVersion {
|
if opts.showVersion {
|
||||||
fmt.Printf("ffuf version: %s\n", ffuf.VERSION)
|
fmt.Printf("ffuf version: %s\n", ffuf.VERSION)
|
||||||
os.Exit(0)
|
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 {
|
if err := prepareConfig(&opts, &conf); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Encountered error(s): %s\n", err)
|
fmt.Fprintf(os.Stderr, "Encountered error(s): %s\n", err)
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user