diff --git a/v2/cmd/nuclei/main.go b/v2/cmd/nuclei/main.go index 85bc7ae8..53a822c5 100644 --- a/v2/cmd/nuclei/main.go +++ b/v2/cmd/nuclei/main.go @@ -43,7 +43,8 @@ on extensive configurability, massive extensibility and ease of use.`) createGroup(flagSet, "input", "Target", flagSet.StringVarP(&options.Target, "target", "u", "", "target URL/host to scan"), - flagSet.StringVarP(&options.Targets, "list", "l", "", "path to file containing a list of target URLs/hosts to scan (one per line)"), + flagSet.StringSliceVarP(&options.Targets, "list", "l", []string{}, "list of target URL/hosts to scan"), + flagSet.StringVarP(&options.TargetsFile, "file", "f", "", "path to file containing a list of target URLs/hosts to scan (one per line)"), ) createGroup(flagSet, "templates", "Templates", diff --git a/v2/internal/runner/runner.go b/v2/internal/runner/runner.go index 017d3d86..2d9afd88 100644 --- a/v2/internal/runner/runner.go +++ b/v2/internal/runner/runner.go @@ -125,7 +125,7 @@ func New(options *types.Options) (*Runner, error) { os.Exit(0) } - if (len(options.Templates) == 0 || !options.NewTemplates || (options.Targets == "" && !options.Stdin && options.Target == "")) && options.UpdateTemplates { + if (len(options.Templates) == 0 || !options.NewTemplates || (len(options.Targets) == 0 && !options.Stdin && options.Target == "" && options.TargetsFile == "")) && options.UpdateTemplates { os.Exit(0) } hm, err := hybrid.New(hybrid.DefaultDiskOptions) @@ -144,6 +144,15 @@ func New(options *types.Options) (*Runner, error) { runner.hostMap.Set(options.Target, nil) } + // Handle multiple targets + if len(options.Targets) != 0 { + for _, target := range options.Targets { + runner.inputCount++ + // nolint:errcheck // ignoring error + runner.hostMap.Set(target, nil) + } + } + // Handle stdin if options.Stdin { scanner := bufio.NewScanner(os.Stdin) @@ -163,8 +172,8 @@ func New(options *types.Options) (*Runner, error) { } // Handle taget file - if options.Targets != "" { - input, inputErr := os.Open(options.Targets) + if options.TargetsFile != "" { + input, inputErr := os.Open(options.TargetsFile) if inputErr != nil { return nil, errors.Wrap(inputErr, "could not open targets file") } diff --git a/v2/internal/testutils/testutils.go b/v2/internal/testutils/testutils.go index e2008bad..5296a8f8 100644 --- a/v2/internal/testutils/testutils.go +++ b/v2/internal/testutils/testutils.go @@ -46,7 +46,8 @@ var DefaultOptions = &types.Options{ ProjectPath: "", Severity: []string{}, Target: "", - Targets: "", + Targets: []string{}, + TargetsFile: "", Output: "", ProxyURL: "", ProxySocksURL: "", diff --git a/v2/pkg/types/types.go b/v2/pkg/types/types.go index c80ed5b1..c87f66f7 100644 --- a/v2/pkg/types/types.go +++ b/v2/pkg/types/types.go @@ -35,7 +35,9 @@ type Options struct { // Target is a single URL/Domain to scan using a template Target string // Targets specifies the targets to scan using templates. - Targets string + Targets goflags.StringSlice + // TargetsFile specifies the targets in a file to scan using templates. + TargetsFile string // Output is the file to write found results to. Output string // ProxyURL is the URL for the proxy server