mirror of https://github.com/daffainfo/nuclei.git
Added single target support with target flag
parent
3a24879aeb
commit
5a2eef1437
|
@ -13,6 +13,7 @@ import (
|
|||
type Options struct {
|
||||
Debug bool // Debug mode allows debugging request/responses for the engine
|
||||
Templates string // Signature specifies the template/templates to use
|
||||
Target string // Target is a single URL/Domain to scan usng a template
|
||||
Targets string // Targets specifies the targets to scan using templates.
|
||||
Threads int // Thread controls the number of concurrent requests to make.
|
||||
Timeout int // Timeout is the seconds to wait for a response from the server.
|
||||
|
@ -35,6 +36,7 @@ type Options struct {
|
|||
func ParseOptions() *Options {
|
||||
options := &Options{}
|
||||
|
||||
flag.StringVar(&options.Target, "target", "", "Target is a single target to scan using template")
|
||||
flag.StringVar(&options.Templates, "t", "", "Template input file/files to run on host")
|
||||
flag.StringVar(&options.Targets, "l", "", "List of URLs to run templates on")
|
||||
flag.StringVar(&options.Output, "o", "", "File to write output to (optional)")
|
||||
|
|
|
@ -39,7 +39,7 @@ func New(options *Options) (*Runner, error) {
|
|||
if err := runner.updateTemplates(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if (options.Templates == "" || options.Targets == "" && !options.Stdin) && options.UpdateTemplates {
|
||||
if (options.Templates == "" || (options.Targets == "" && !options.Stdin && options.Target == "")) && options.UpdateTemplates {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,16 @@ func New(options *Options) (*Runner, error) {
|
|||
runner.tempFile = tempInput.Name()
|
||||
tempInput.Close()
|
||||
}
|
||||
// If we have single target, write it to a new file
|
||||
if options.Target != "" {
|
||||
tempInput, err := ioutil.TempFile("", "stdin-input-*")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tempInput.WriteString(options.Target)
|
||||
runner.tempFile = tempInput.Name()
|
||||
tempInput.Close()
|
||||
}
|
||||
|
||||
// Create the output file if asked
|
||||
if options.Output != "" {
|
||||
|
@ -205,7 +215,7 @@ func (r *Runner) processTemplateRequest(template *templates.Template, request in
|
|||
// Handle a list of hosts as argument
|
||||
if r.options.Targets != "" {
|
||||
file, err = os.Open(r.options.Targets)
|
||||
} else if r.options.Stdin {
|
||||
} else if r.options.Stdin || r.options.Target != "" {
|
||||
file, err = os.Open(r.tempFile)
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -19,7 +19,7 @@ func (options *Options) validateOptions() error {
|
|||
return errors.New("no template/templates provided")
|
||||
}
|
||||
|
||||
if options.Targets == "" && !options.Stdin && !options.UpdateTemplates {
|
||||
if options.Targets == "" && !options.Stdin && options.Target == "" && !options.UpdateTemplates {
|
||||
return errors.New("no target input provided")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue