From 610cf399bb1059332fe575c1cd61bb29f5f1380f Mon Sep 17 00:00:00 2001 From: WigzyDev Date: Sun, 10 Sep 2023 20:01:15 -0400 Subject: [PATCH] added the option to disable following redirects --- cmd/katana/main.go | 1 + pkg/engine/common/http.go | 3 +++ pkg/types/options.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/cmd/katana/main.go b/cmd/katana/main.go index 07191397..ede906d8 100644 --- a/cmd/katana/main.go +++ b/cmd/katana/main.go @@ -86,6 +86,7 @@ pipelines offering both headless and non-headless crawling.`) flagSet.StringVarP(&options.Strategy, "strategy", "s", "depth-first", "Visit strategy (depth-first, breadth-first)"), flagSet.BoolVarP(&options.IgnoreQueryParams, "ignore-query-params", "iqp", false, "Ignore crawling same path with different query-param values"), flagSet.BoolVarP(&options.TlsImpersonate, "tls-impersonate", "tlsi", false, "enable experimental client hello (ja3) tls randomization"), + flagSet.BoolVarP(&options.DisableRedirects, "disable-redirects", "dr", false, "disable following redirects (default false)"), ) flagSet.CreateGroup("debug", "Debug", diff --git a/pkg/engine/common/http.go b/pkg/engine/common/http.go index 90d8dd5a..87b25ddc 100644 --- a/pkg/engine/common/http.go +++ b/pkg/engine/common/http.go @@ -54,6 +54,9 @@ func BuildHttpClient(dialer *fastdialer.Dialer, options *types.Options, redirect Transport: transport, Timeout: time.Duration(options.Timeout) * time.Second, CheckRedirect: func(req *http.Request, via []*http.Request) error { + if options.DisableRedirects { + return http.ErrUseLastResponse + } if len(via) == 10 { return errorutil.New("stopped after 10 redirects") } diff --git a/pkg/types/options.go b/pkg/types/options.go index dd9711c9..a69bc8fe 100644 --- a/pkg/types/options.go +++ b/pkg/types/options.go @@ -141,6 +141,8 @@ type Options struct { Debug bool // TlsImpersonate enables experimental tls ClientHello randomization for standard crawler TlsImpersonate bool + //DisableRedirects disables the following of redirects + DisableRedirects bool } func (options *Options) ParseCustomHeaders() map[string]string {