From c5712c98f40c5af2425a3dbdb779f2033a2df317 Mon Sep 17 00:00:00 2001 From: Sandeep Singh Date: Wed, 6 Apr 2022 16:49:36 +0530 Subject: [PATCH] Fixed the default behavior of srd flag (#1817) * fix: fixed automatic storing of debug response * small code refactor Co-authored-by: Mzack9999 --- v2/cmd/nuclei/main.go | 2 +- v2/internal/runner/defaults.go | 6 ++++++ v2/internal/runner/options.go | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 v2/internal/runner/defaults.go diff --git a/v2/cmd/nuclei/main.go b/v2/cmd/nuclei/main.go index 7893d6c80..204a473bd 100644 --- a/v2/cmd/nuclei/main.go +++ b/v2/cmd/nuclei/main.go @@ -189,7 +189,7 @@ on extensive configurability, massive extensibility and ease of use.`) flagSet.BoolVarP(&options.DebugRequests, "debug-req", "dreq", false, "show all sent requests"), flagSet.BoolVarP(&options.DebugResponse, "debug-resp", "dresp", false, "show all received responses"), flagSet.BoolVarP(&options.StoreResponse, "store-resp", "sresp", false, "store all request/response passed through nuclei to output directory"), - flagSet.StringVarP(&options.StoreResponseDir, "store-resp-dir", "srd", "output", "store all request/response passed through nuclei to custom directory"), + flagSet.StringVarP(&options.StoreResponseDir, "store-resp-dir", "srd", runner.DefaultDumpTrafficOutputFolder, "store all request/response passed through nuclei to custom directory"), flagSet.NormalizedOriginalStringSliceVarP(&options.Proxy, "proxy", "p", []string{}, "list of http/socks5 proxy to use (comma separated or file input)"), flagSet.BoolVarP(&options.ProxyInternal, "proxy-internal", "pi", false, "proxy all internal requests"), flagSet.StringVarP(&options.TraceLogFile, "trace-log", "tlog", "", "file to write sent requests trace log"), diff --git a/v2/internal/runner/defaults.go b/v2/internal/runner/defaults.go new file mode 100644 index 000000000..d51ab7c4c --- /dev/null +++ b/v2/internal/runner/defaults.go @@ -0,0 +1,6 @@ +package runner + +const ( + // Default directory used to save protocols traffic + DefaultDumpTrafficOutputFolder = "output" +) diff --git a/v2/internal/runner/options.go b/v2/internal/runner/options.go index 60a52166d..f6c1a5164 100644 --- a/v2/internal/runner/options.go +++ b/v2/internal/runner/options.go @@ -57,8 +57,8 @@ func ParseOptions(options *types.Options) { gologger.Info().Msgf("Current nuclei-templates version: %s (%s)\n", configuration.TemplateVersion, configuration.TemplatesDirectory) os.Exit(0) } - if options.StoreResponseDir != "" && !options.StoreResponse { - gologger.Debug().Msgf("Store response directory specified, enabling \"str\" flag automatically\n") + if options.StoreResponseDir != DefaultDumpTrafficOutputFolder && !options.StoreResponse { + gologger.Debug().Msgf("Store response directory specified, enabling \"store-resp\" flag automatically\n") options.StoreResponse = true } // Validate the options passed by the user and if any