package common import ( "flag" "fmt" "os" ) var ( cidr = flag.String("r", "", "") list = flag.String("l", "", "") threads = flag.Int("t", 25, "") sshmode = flag.Bool("ssh", false, "") ftpmode = flag.Bool("ftp", false, "") payload = flag.String("p", "", "") cmd = flag.String("c", "", "") silent = flag.Bool("s", false, "") Params *Config ) type Config struct { Cidr string // individual cidr to target Targets string // list of target cidrs Mode uint8 // 0:ssh 1:ftp Payload string // file to upload Command string // commands to run within ssh session after payload upload Threads int // concurrent workers Silent bool // no verbosity } func LoadConf() { flag.Usage = usage flag.Parse() if len(os.Args) == 1 { usage() os.Exit(1) } if !*sshmode && !*ftpmode { fatal("are you targeting ssh (-ssh) or ftp (-ftp)?") } if *payload != "" { if _, err := os.Stat(*payload); err != nil { fatal("payload '" + *payload + "' not found") } } targetcidr := "" if *list == "" && *cidr == "" { targetcidr = "0.0.0.0/0" } else if *cidr != "" { if !validcidr(*cidr) { fatal(fmt.Sprintf("invalid target cidr: %s", *cidr)) } targetcidr = *cidr } var mode uint8 = 0 if *ftpmode { mode = 1 } Params = &Config{ targetcidr, *list, mode, *payload, *cmd, *threads, *silent, } }