diff --git a/v2/cmd/nuclei/main.go b/v2/cmd/nuclei/main.go index 197e4dd9d..220024cad 100644 --- a/v2/cmd/nuclei/main.go +++ b/v2/cmd/nuclei/main.go @@ -76,7 +76,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&options.Target, "target", "", "Target is a single target to scan using template") rootCmd.PersistentFlags().StringSliceVarP(&options.Templates, "templates", "t", []string{}, "Template input dir/file/files to run on host. Can be used multiple times. Supports globbing.") rootCmd.PersistentFlags().StringSliceVar(&options.ExcludedTemplates, "exclude", []string{}, "Template input dir/file/files to exclude. Can be used multiple times. Supports globbing.") - rootCmd.PersistentFlags().StringVar(&options.Severity, "severity", "", "Filter templates based on their severity and only run the matching ones. Comma-separated values can be used to specify multiple severities.") + rootCmd.PersistentFlags().StringSliceVar(&options.Severity, "severity", []string{}, "Filter templates based on their severity and only run the matching ones. Comma-separated values can be used to specify multiple severities.") rootCmd.PersistentFlags().StringVarP(&options.Targets, "list", "l", "", "List of URLs to run templates on") rootCmd.PersistentFlags().StringVarP(&options.Output, "output", "o", "", "File to write output to (optional)") rootCmd.PersistentFlags().StringVar(&options.ProxyURL, "proxy-url", "", "URL of the proxy server") @@ -90,6 +90,8 @@ func init() { rootCmd.PersistentFlags().BoolVar(&options.RandomAgent, "random-agent", false, "Use randomly selected HTTP User-Agent header value") rootCmd.PersistentFlags().StringSliceVarP(&options.CustomHeaders, "header", "H", []string{}, "Custom Header.") rootCmd.PersistentFlags().BoolVar(&options.Debug, "debug", false, "Allow debugging of request/responses") + rootCmd.PersistentFlags().BoolVar(&options.DebugRequests, "debug-req", false, "Allow debugging of request") + rootCmd.PersistentFlags().BoolVar(&options.DebugResponse, "debug-resp", false, "Allow debugging of response") rootCmd.PersistentFlags().BoolVar(&options.UpdateTemplates, "update-templates", false, "Update Templates updates the installed templates (optional)") rootCmd.PersistentFlags().StringVar(&options.TraceLogFile, "trace-log", "", "File to write sent requests trace log") rootCmd.PersistentFlags().StringVar(&options.TemplatesDirectory, "update-directory", templatesDirectory, "Directory to use for storing nuclei-templates") diff --git a/v2/pkg/protocols/dns/request.go b/v2/pkg/protocols/dns/request.go index 37a64b9ff..974d55ab8 100644 --- a/v2/pkg/protocols/dns/request.go +++ b/v2/pkg/protocols/dns/request.go @@ -31,7 +31,7 @@ func (r *Request) ExecuteWithResults(input string, metadata output.InternalEvent return errors.Wrap(err, "could not build request") } - if r.options.Options.Debug { + if r.options.Options.Debug || r.options.Options.DebugRequests { gologger.Info().Str("domain", domain).Msgf("[%s] Dumped DNS request for %s", r.options.TemplateID, domain) fmt.Fprintf(os.Stderr, "%s\n", compiledRequest.String()) } @@ -48,7 +48,7 @@ func (r *Request) ExecuteWithResults(input string, metadata output.InternalEvent r.options.Output.Request(r.options.TemplateID, domain, "dns", err) gologger.Verbose().Msgf("[%s] Sent DNS request to %s", r.options.TemplateID, domain) - if r.options.Options.Debug { + if r.options.Options.Debug || r.options.Options.DebugResponse { gologger.Debug().Msgf("[%s] Dumped DNS response for %s", r.options.TemplateID, domain) fmt.Fprintf(os.Stderr, "%s\n", resp.String()) } diff --git a/v2/pkg/protocols/file/request.go b/v2/pkg/protocols/file/request.go index 6f4e467e6..b3461b976 100644 --- a/v2/pkg/protocols/file/request.go +++ b/v2/pkg/protocols/file/request.go @@ -41,7 +41,7 @@ func (r *Request) ExecuteWithResults(input string, metadata output.InternalEvent } dataStr := tostring.UnsafeToString(buffer) - if r.options.Options.Debug { + if r.options.Options.Debug || r.options.Options.DebugRequests { gologger.Info().Msgf("[%s] Dumped file request for %s", r.options.TemplateID, data) fmt.Fprintf(os.Stderr, "%s\n", dataStr) } diff --git a/v2/pkg/protocols/http/request.go b/v2/pkg/protocols/http/request.go index 19955de40..e1118792d 100644 --- a/v2/pkg/protocols/http/request.go +++ b/v2/pkg/protocols/http/request.go @@ -223,13 +223,13 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, dynam dumpedRequest []byte fromcache bool ) - if r.options.Options.Debug || r.options.ProjectFile != nil { + if r.options.Options.Debug || r.options.ProjectFile != nil || r.options.Options.DebugRequests { dumpedRequest, err = dump(request, reqURL) if err != nil { return err } } - if r.options.Options.Debug { + if r.options.Options.Debug || r.options.Options.DebugRequests { gologger.Info().Msgf("[%s] Dumped HTTP request for %s\n\n", r.options.TemplateID, reqURL) fmt.Fprintf(os.Stderr, "%s", string(dumpedRequest)) } @@ -279,7 +279,7 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, dynam duration := time.Since(timeStart) // Dump response - Step 1 - Decompression not yet handled var dumpedResponse []byte - if r.options.Options.Debug { + if r.options.Options.Debug || r.options.Options.DebugResponse { var dumpErr error dumpedResponse, dumpErr = httputil.DumpResponse(resp, true) if dumpErr != nil { @@ -305,7 +305,7 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, dynam } // Dump response - step 2 - replace gzip body with deflated one or with itself (NOP operation) - if r.options.Options.Debug { + if r.options.Options.Debug || r.options.Options.DebugResponse { dumpedResponse = bytes.ReplaceAll(dumpedResponse, dataOrig, data) gologger.Info().Msgf("[%s] Dumped HTTP response for %s\n\n", r.options.TemplateID, formedURL) fmt.Fprintf(os.Stderr, "%s\n", string(dumpedResponse)) diff --git a/v2/pkg/protocols/network/request.go b/v2/pkg/protocols/network/request.go index 7832cec7d..23c676d2c 100644 --- a/v2/pkg/protocols/network/request.go +++ b/v2/pkg/protocols/network/request.go @@ -97,7 +97,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, callback return errors.Wrap(err, "could not write request to server") } - if r.options.Options.Debug { + if r.options.Options.Debug || r.options.Options.DebugRequests { gologger.Info().Str("address", actualAddress).Msgf("[%s] Dumped Network request for %s", r.options.TemplateID, actualAddress) fmt.Fprintf(os.Stderr, "%s\n", reqBuilder.String()) @@ -114,7 +114,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, callback n, _ := conn.Read(buffer) resp := string(buffer[:n]) - if r.options.Options.Debug { + if r.options.Options.Debug || r.options.Options.DebugResponse { gologger.Debug().Msgf("[%s] Dumped Network response for %s", r.options.TemplateID, actualAddress) fmt.Fprintf(os.Stderr, "%s\n", resp) } diff --git a/v2/pkg/types/types.go b/v2/pkg/types/types.go index 57e122d52..a60df6af3 100644 --- a/v2/pkg/types/types.go +++ b/v2/pkg/types/types.go @@ -8,6 +8,10 @@ type Options struct { Metrics bool // Debug mode allows debugging request/responses for the engine Debug bool + // DebugRequests mode allows debugging request for the engine + DebugRequests bool + // DebugResponse mode allows debugging response for the engine + DebugResponse bool // Silent suppresses any extra text and only writes found URLs on screen. Silent bool // Version specifies if we should just show version and exit