/
parameters.go
67 lines (56 loc) · 2.24 KB
/
parameters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package utils
import (
"bufio"
"os"
fileutil "github.com/projectdiscovery/utils/file"
"github.com/projectdiscovery/goflags"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/gologger/levels"
)
func ParseStdin() {
// Look into stdin to grab the IPv4s and Networks
if fileutil.HasStdin() {
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
IdentifyTarget(s.Text())
}
}
}
func LoadParameters() {
// Load parameters from a file
flagSet := goflags.NewFlagSet()
flagSet.Marshal = true
flagSet.SetDescription("HEDnsExtractor - A suite for hunting suspicious targets, expose domains and phishing discovery!")
flagSet.BoolVar(&OptionCmd.Onlydomains, "only-domains", false, "show only domains")
flagSet.BoolVar(&OptionCmd.Onlynetworks, "only-networks", false, "show only networks")
flagSet.StringVar(&OptionCmd.Workflow, "workflow", "", "Workflow config")
flagSet.StringVar(&OptionCmd.Target, "target", "", "IP Address or Network to query")
flagSet.BoolVar(&OptionCmd.Silent, "silent", false, "show silent output")
flagSet.BoolVar(&OptionCmd.Verbose, "verbose", false, "show verbose output")
flagSet.CreateGroup("configuration", "Configuration",
flagSet.StringVar(&OptionCmd.Config, "config", DefaultConfigLocation, "flag config file"),
)
flagSet.CreateGroup("config", "Virustotal",
flagSet.BoolVar(&OptionCmd.Vtscore, "vt", false, "show Virustotal score"),
flagSet.StringVar(&OptionCmd.VtApiKey, "vt-api-key", "", "Virustotal API Key"),
flagSet.StringVar(&OptionCmd.VtscoreValue, "vt-score", "0", "Minimum Virustotal score to show"),
)
if err := flagSet.Parse(); err != nil {
gologger.Fatal().Msgf("Could not parse flags: %s\n", err)
}
if OptionCmd.Verbose {
gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose)
} else if OptionCmd.Silent {
gologger.DefaultLogger.SetMaxLevel(levels.LevelSilent)
} else {
gologger.DefaultLogger.SetMaxLevel(levels.LevelInfo)
}
if OptionCmd.Vtscore && OptionCmd.VtApiKey == "" {
gologger.Fatal().Msgf("A Virustotal API Key is needed in config file: %s\n", DefaultConfigLocation)
}
// Look into target parameter to grab the IPv4s and Networks
if OptionCmd.Target != "" {
gologger.Verbose().Msgf("Identifying networks for %s", OptionCmd.Target)
IdentifyTarget(OptionCmd.Target)
}
}