| skipped 1 lines |
2 | 2 | | |
3 | 3 | | import ( |
4 | 4 | | "io" |
| 5 | + | "os" |
| 6 | + | "strings" |
5 | 7 | | |
6 | 8 | | "github.com/edoardottt/csprecon/pkg/output" |
7 | 9 | | "github.com/projectdiscovery/goflags" |
| skipped 36 lines |
44 | 46 | | |
45 | 47 | | // Input |
46 | 48 | | flagSet.CreateGroup("input", "Input", |
47 | | - | flagSet.StringVar(&options.Input, "u", "", `Input domain`), |
48 | | - | flagSet.StringVar(&options.FileInput, "l", "", `File containing input domains`), |
| 49 | + | flagSet.StringVarP(&options.Input, "url", "u", "", `Input domain`), |
| 50 | + | flagSet.StringVarP(&options.FileInput, "list", "l", "", `File containing input domains`), |
49 | 51 | | ) |
50 | 52 | | |
51 | 53 | | flagSet.CreateGroup("configs", "Configurations", |
52 | | - | flagSet.StringSliceVar(&options.Domain, "d", nil, `Filter results belonging to these domains (comma separated)`, goflags.CommaSeparatedStringSliceOptions), |
53 | | - | flagSet.IntVar(&options.Concurrency, "c", DefaultConcurrency, `Concurrency level`), |
54 | | - | flagSet.IntVar(&options.Timeout, "t", DefaultTimeout, `Connection timeout in seconds`), |
| 54 | + | flagSet.StringSliceVarP(&options.Domain, "domain", "d", nil, `Filter results belonging to these domains (comma separated)`, goflags.CommaSeparatedStringSliceOptions), |
| 55 | + | flagSet.IntVarP(&options.Concurrency, "concurrency", "c", DefaultConcurrency, `Concurrency level`), |
| 56 | + | flagSet.IntVarP(&options.Timeout, "timeout", "t", DefaultTimeout, `Connection timeout in seconds`), |
55 | 57 | | ) |
56 | 58 | | |
57 | 59 | | // Output |
58 | 60 | | flagSet.CreateGroup("output", "Output", |
59 | | - | flagSet.StringVar(&options.FileOutput, "o", "", `File to write output results`), |
60 | | - | flagSet.BoolVar(&options.Verbose, "v", false, `Verbose output`), |
61 | | - | flagSet.BoolVar(&options.Silent, "s", false, `Print only results`), |
| 61 | + | flagSet.StringVarP(&options.FileOutput, "output", "o", "", `File to write output results`), |
| 62 | + | flagSet.BoolVarP(&options.Verbose, "verbose", "v", false, `Verbose output`), |
| 63 | + | flagSet.BoolVarP(&options.Silent, "silent", "s", false, `Silent output. Print only results`), |
62 | 64 | | ) |
63 | 65 | | |
64 | | - | if !options.Silent { |
| 66 | + | if help() || noArgs() { |
65 | 67 | | output.ShowBanner() |
66 | 68 | | } |
67 | 69 | | |
| skipped 9 lines |
77 | 79 | | gologger.Fatal().Msgf("%s\n", err) |
78 | 80 | | } |
79 | 81 | | |
| 82 | + | output.ShowBanner() |
| 83 | + | |
80 | 84 | | return options |
81 | 85 | | } |
82 | 86 | | |
| 87 | + | func help() bool { |
| 88 | + | // help usage asked by user. |
| 89 | + | for _, arg := range os.Args { |
| 90 | + | argStripped := strings.Trim(arg, "-") |
| 91 | + | if argStripped == "h" || argStripped == "help" { |
| 92 | + | return true |
| 93 | + | } |
| 94 | + | } |
| 95 | + | |
| 96 | + | return false |
| 97 | + | } |
| 98 | + | |
| 99 | + | func noArgs() bool { |
| 100 | + | // User passed no flag. |
| 101 | + | return len(os.Args) < 2 |
| 102 | + | } |
| 103 | + | |