Feature178 (#186)

* feature 178

* sync

* sync

* sync

* sync

Co-authored-by: bjhulst <bjhulst>
This commit is contained in:
bjhulst 2020-03-20 12:42:54 +02:00 committed by GitHub
parent ccdd377930
commit ef1aac3a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,8 @@
- New - New
- New CLI flag `-maxtime-job` to set max. execution time per job. - New CLI flag `-maxtime-job` to set max. execution time per job.
- Changed behaviour of `-maxtime`, can now be used for entire process. - Changed behaviour of `-maxtime`, can now be used for entire process.
- A new flag `-ignore-body` so ffuf does not fetch the response content. Default value=false.
- Changed - Changed
- Added tls renegotiation flag to fix #193 in http.Client - Added tls renegotiation flag to fix #193 in http.Client

12
main.go
View File

@ -39,6 +39,7 @@ type cliOptions struct {
requestProto string requestProto string
URL string URL string
outputFormat string outputFormat string
ignoreBody bool
wordlists multiStringFlag wordlists multiStringFlag
inputcommands multiStringFlag inputcommands multiStringFlag
headers multiStringFlag headers multiStringFlag
@ -102,6 +103,7 @@ func main() {
flag.StringVar(&conf.OutputFile, "o", "", "Write output to file") flag.StringVar(&conf.OutputFile, "o", "", "Write output to file")
flag.StringVar(&opts.outputFormat, "of", "json", "Output file format. Available formats: json, ejson, html, md, csv, ecsv") flag.StringVar(&opts.outputFormat, "of", "json", "Output file format. Available formats: json, ejson, html, md, csv, ecsv")
flag.StringVar(&conf.OutputDirectory, "od", "", "Directory path to store matched results to.") flag.StringVar(&conf.OutputDirectory, "od", "", "Directory path to store matched results to.")
flag.BoolVar(&conf.IgnoreBody, "ignore-body", false, "Do not fetch the response content.")
flag.BoolVar(&conf.Quiet, "s", false, "Do not print additional information (silent mode)") flag.BoolVar(&conf.Quiet, "s", false, "Do not print additional information (silent mode)")
flag.BoolVar(&conf.StopOn403, "sf", false, "Stop when > 95% of responses return 403 Forbidden") flag.BoolVar(&conf.StopOn403, "sf", false, "Stop when > 95% of responses return 403 Forbidden")
flag.BoolVar(&conf.StopOnErrors, "se", false, "Stop on spurious errors") flag.BoolVar(&conf.StopOnErrors, "se", false, "Stop on spurious errors")
@ -197,21 +199,25 @@ func prepareFilters(parseOpts *cliOptions, conf *ffuf.Config) error {
// If any other matcher is set, ignore -mc default value // If any other matcher is set, ignore -mc default value
matcherSet := false matcherSet := false
statusSet := false statusSet := false
warningIgnoreBody := false
flag.Visit(func(f *flag.Flag) { flag.Visit(func(f *flag.Flag) {
if f.Name == "mc" { if f.Name == "mc" {
statusSet = true statusSet = true
} }
if f.Name == "ms" { if f.Name == "ms" {
matcherSet = true matcherSet = true
warningIgnoreBody = true
} }
if f.Name == "ml" { if f.Name == "ml" {
matcherSet = true matcherSet = true
warningIgnoreBody = true
} }
if f.Name == "mr" { if f.Name == "mr" {
matcherSet = true matcherSet = true
} }
if f.Name == "mw" { if f.Name == "mw" {
matcherSet = true matcherSet = true
warningIgnoreBody = true
} }
}) })
if statusSet || !matcherSet { if statusSet || !matcherSet {
@ -226,6 +232,7 @@ func prepareFilters(parseOpts *cliOptions, conf *ffuf.Config) error {
} }
} }
if parseOpts.filterSize != "" { if parseOpts.filterSize != "" {
warningIgnoreBody = true
if err := filter.AddFilter(conf, "size", parseOpts.filterSize); err != nil { if err := filter.AddFilter(conf, "size", parseOpts.filterSize); err != nil {
errs.Add(err) errs.Add(err)
} }
@ -236,11 +243,13 @@ func prepareFilters(parseOpts *cliOptions, conf *ffuf.Config) error {
} }
} }
if parseOpts.filterWords != "" { if parseOpts.filterWords != "" {
warningIgnoreBody = true
if err := filter.AddFilter(conf, "word", parseOpts.filterWords); err != nil { if err := filter.AddFilter(conf, "word", parseOpts.filterWords); err != nil {
errs.Add(err) errs.Add(err)
} }
} }
if parseOpts.filterLines != "" { if parseOpts.filterLines != "" {
warningIgnoreBody = true
if err := filter.AddFilter(conf, "line", parseOpts.filterLines); err != nil { if err := filter.AddFilter(conf, "line", parseOpts.filterLines); err != nil {
errs.Add(err) errs.Add(err)
} }
@ -265,6 +274,9 @@ func prepareFilters(parseOpts *cliOptions, conf *ffuf.Config) error {
errs.Add(err) errs.Add(err)
} }
} }
if conf.IgnoreBody && warningIgnoreBody {
fmt.Printf("*** Warning: possible undesired combination of -ignore-body and the response options: fl,fs,fw,ml,ms and mw.\n")
}
return errs.ErrorOrNil() return errs.ErrorOrNil()
} }

View File

@ -20,6 +20,7 @@ type Config struct {
OutputDirectory string `json:"outputdirectory"` OutputDirectory string `json:"outputdirectory"`
OutputFile string `json:"outputfile"` OutputFile string `json:"outputfile"`
OutputFormat string `json:"outputformat"` OutputFormat string `json:"outputformat"`
IgnoreBody bool `json:"ignorebody"`
IgnoreWordlistComments bool `json:"ignore_wordlist_comments"` IgnoreWordlistComments bool `json:"ignore_wordlist_comments"`
StopOn403 bool `json:"stop_403"` StopOn403 bool `json:"stop_403"`
StopOnErrors bool `json:"stop_errors"` StopOnErrors bool `json:"stop_errors"`

View File

@ -127,7 +127,7 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
size, err := strconv.Atoi(httpresp.Header.Get("Content-Length")) size, err := strconv.Atoi(httpresp.Header.Get("Content-Length"))
if err == nil { if err == nil {
resp.ContentLength = int64(size) resp.ContentLength = int64(size)
if size > MAX_DOWNLOAD_SIZE { if (r.config.IgnoreBody) || (size > MAX_DOWNLOAD_SIZE) {
resp.Cancelled = true resp.Cancelled = true
return resp, nil return resp, nil
} }