switch back to file based input for `Targets` and switch `Target` to

receive a goflags.StringSlice (`[]string`) as an argument
dev
TheSecEng 2021-07-29 08:14:44 -07:00
parent 2594b282fe
commit 0295555c70
No known key found for this signature in database
GPG Key ID: 4D98046FE19FF417
5 changed files with 12 additions and 23 deletions

View File

@ -84,7 +84,7 @@ Usage:
Flags:
TARGET:
-u, -target string target URL/host to scan
-u, -target string target URLs/hosts to scan
-l, -list string path to file containing a list of target URLs/hosts to scan (one per line)
TEMPLATES:

View File

@ -42,9 +42,8 @@ func readConfig() {
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.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)"),
flagSet.StringSliceVarP(&options.Target, "target", "u", []string{}, "target URLs/hosts to scan"),
flagSet.StringVarP(&options.Targets, "list", "l", "", "path to file containing a list of target URLs/hosts to scan (one per line)"),
)
createGroup(flagSet, "templates", "Templates",

View File

@ -125,7 +125,7 @@ func New(options *types.Options) (*Runner, error) {
os.Exit(0)
}
if (len(options.Templates) == 0 || !options.NewTemplates || (len(options.Targets) == 0 && !options.Stdin && options.Target == "" && options.TargetsFile == "")) && options.UpdateTemplates {
if (len(options.Templates) == 0 || !options.NewTemplates || (len(options.Targets) == 0 && !options.Stdin && len(options.Target) == 0)) && options.UpdateTemplates {
os.Exit(0)
}
hm, err := hybrid.New(hybrid.DefaultDiskOptions)
@ -138,15 +138,8 @@ func New(options *types.Options) (*Runner, error) {
dupeCount := 0
// Handle single target
if options.Target != "" {
runner.inputCount++
// nolint:errcheck // ignoring error
runner.hostMap.Set(options.Target, nil)
}
// Handle multiple targets
if len(options.Targets) != 0 {
for _, target := range options.Targets {
if len(options.Target) != 0 {
for _, target := range options.Target {
runner.inputCount++
// nolint:errcheck // ignoring error
runner.hostMap.Set(target, nil)
@ -172,8 +165,8 @@ func New(options *types.Options) (*Runner, error) {
}
// Handle taget file
if options.TargetsFile != "" {
input, inputErr := os.Open(options.TargetsFile)
if options.Targets != "" {
input, inputErr := os.Open(options.Targets)
if inputErr != nil {
return nil, errors.Wrap(inputErr, "could not open targets file")
}

View File

@ -45,9 +45,8 @@ var DefaultOptions = &types.Options{
RateLimit: 150,
ProjectPath: "",
Severity: []string{},
Target: "",
Targets: []string{},
TargetsFile: "",
Target: []string{},
Targets: "",
Output: "",
ProxyURL: "",
ProxySocksURL: "",

View File

@ -33,11 +33,9 @@ type Options struct {
// InteractshURL is the URL for the interactsh server.
InteractshURL string
// Target is a single URL/Domain to scan using a template
Target string
Target goflags.StringSlice
// Targets specifies the targets to scan using templates.
Targets goflags.StringSlice
// TargetsFile specifies the targets in a file to scan using templates.
TargetsFile string
Targets string
// Output is the file to write found results to.
Output string
// ProxyURL is the URL for the proxy server