diff --git a/v2/internal/runner/runner.go b/v2/internal/runner/runner.go index 3b6b5889d..4dd7b1ec0 100644 --- a/v2/internal/runner/runner.go +++ b/v2/internal/runner/runner.go @@ -14,6 +14,8 @@ import ( "github.com/projectdiscovery/nuclei/v2/pkg/catalogue" "github.com/projectdiscovery/nuclei/v2/pkg/output" "github.com/projectdiscovery/nuclei/v2/pkg/projectfile" + "github.com/projectdiscovery/nuclei/v2/pkg/protocols/dns/dnsclientpool" + "github.com/projectdiscovery/nuclei/v2/pkg/protocols/http/httpclientpool" "github.com/projectdiscovery/nuclei/v2/pkg/templates" "github.com/projectdiscovery/nuclei/v2/pkg/types" "github.com/remeh/sizedwaitgroup" @@ -126,13 +128,11 @@ func New(options *types.Options) (*Runner, error) { } // Create the output file if asked - if options.Output != "" { - output, errWriter := output.NewStandardWriter(!options.NoColor, options.NoMeta, options.JSON, options.Output, options.TraceLogFile) - if errWriter != nil { - gologger.Fatal().Msgf("Could not create output file '%s': %s\n", options.Output, errWriter) - } - runner.output = output + output, err := output.NewStandardWriter(!options.NoColor, options.NoMeta, options.JSON, options.Output, options.TraceLogFile) + if err != nil { + gologger.Fatal().Msgf("Could not create output file '%s': %s\n", options.Output, err) } + runner.output = output // Creates the progress tracking object var progressErr error @@ -177,6 +177,11 @@ func (r *Runner) Close() { // RunEnumeration sets up the input layer for giving input nuclei. // binary and runs the actual enumeration func (r *Runner) RunEnumeration() { + err := r.initializeProtocols() + if err != nil { + gologger.Fatal().Msgf("Could not initialize protocols: %s\n", err) + } + // resolves input templates definitions and any optional exclusion includedTemplates := r.catalogue.GetTemplatesPath(r.options.Templates) excludedTemplates := r.catalogue.GetTemplatesPath(r.options.ExcludedTemplates) @@ -261,3 +266,14 @@ func (r *Runner) RunEnumeration() { gologger.Info().Msgf("No results found. Happy hacking!") } } + +// initializeProtocols initializes all the protocols and their caches +func (r *Runner) initializeProtocols() error { + if err := dnsclientpool.Init(r.options); err != nil { + return err + } + if err := httpclientpool.Init(r.options); err != nil { + return err + } + return nil +} diff --git a/v2/pkg/templates/compile.go b/v2/pkg/templates/compile.go index 576608921..e00c91308 100644 --- a/v2/pkg/templates/compile.go +++ b/v2/pkg/templates/compile.go @@ -37,7 +37,7 @@ func Parse(file string, options *protocols.ExecuterOptions) (*Template, error) { return nil, fmt.Errorf("both http and dns requests for %s", template.ID) } // If no requests, and it is also not a workflow, return error. - if len(template.RequestsDNS)+len(template.RequestsDNS)+len(template.Workflow.Workflows) == 0 { + if len(template.RequestsDNS)+len(template.RequestsHTTP) == 0 && template.Workflow == nil { return nil, fmt.Errorf("no requests defined for %s", template.ID) }