Merge pull request #113 from projectdiscovery/iceman-misc

Added single target support with target flag
dev
Ice3man 2020-06-27 07:33:50 -07:00 committed by GitHub
commit c33e6973af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -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)")

View File

@ -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 {

View File

@ -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")
}