Add option to follow redirects (#13)

This commit is contained in:
Sebastian Lawniczak 2019-04-03 11:54:32 +02:00 committed by Joona Hoikkala
parent 9934cfdfc3
commit 53361352aa
3 changed files with 26 additions and 19 deletions

View File

@ -70,6 +70,7 @@ func main() {
flag.StringVar(&opts.outputFormat, "of", "json", "Output file format. Available formats: json, csv, ecsv") flag.StringVar(&opts.outputFormat, "of", "json", "Output file format. Available formats: json, csv, ecsv")
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 > 90% of responses return 403 Forbidden") flag.BoolVar(&conf.StopOn403, "sf", false, "Stop when > 90% of responses return 403 Forbidden")
flag.BoolVar(&conf.FollowRedirects, "r", false, "Follow redirects")
flag.IntVar(&conf.Threads, "t", 40, "Number of concurrent threads.") flag.IntVar(&conf.Threads, "t", 40, "Number of concurrent threads.")
flag.BoolVar(&opts.showVersion, "V", false, "Show version information.") flag.BoolVar(&opts.showVersion, "V", false, "Show version information.")
flag.Parse() flag.Parse()

View File

@ -16,25 +16,26 @@ type optRange struct {
} }
type Config struct { type Config struct {
StaticHeaders map[string]string StaticHeaders map[string]string
FuzzHeaders map[string]string FuzzHeaders map[string]string
Method string Method string
Url string Url string
TLSSkipVerify bool TLSSkipVerify bool
Data string Data string
Quiet bool Quiet bool
Colors bool Colors bool
Wordlist string Wordlist string
OutputFile string OutputFile string
OutputFormat string OutputFormat string
StopOn403 bool StopOn403 bool
Delay optRange FollowRedirects bool
Filters []FilterProvider Delay optRange
Matchers []FilterProvider Filters []FilterProvider
Threads int Matchers []FilterProvider
Context context.Context Threads int
ProxyURL func(*http.Request) (*url.URL, error) Context context.Context
CommandLine string ProxyURL func(*http.Request) (*url.URL, error)
CommandLine string
} }
func NewConfig(ctx context.Context) Config { func NewConfig(ctx context.Context) Config {
@ -48,6 +49,7 @@ func NewConfig(ctx context.Context) Config {
conf.Data = "" conf.Data = ""
conf.Quiet = false conf.Quiet = false
conf.StopOn403 = false conf.StopOn403 = false
conf.FollowRedirects = false
conf.ProxyURL = http.ProxyFromEnvironment conf.ProxyURL = http.ProxyFromEnvironment
conf.Filters = make([]FilterProvider, 0) conf.Filters = make([]FilterProvider, 0)
conf.Delay = optRange{0, 0, false, false} conf.Delay = optRange{0, 0, false, false}

View File

@ -38,6 +38,10 @@ func NewSimpleRunner(conf *ffuf.Config) ffuf.RunnerProvider {
InsecureSkipVerify: conf.TLSSkipVerify, InsecureSkipVerify: conf.TLSSkipVerify,
}, },
}} }}
if conf.FollowRedirects {
simplerunner.client.CheckRedirect = nil
}
return &simplerunner return &simplerunner
} }