减少info结构体大小

This commit is contained in:
影舞者
2022-07-03 23:41:39 +08:00
parent 8e1db5995e
commit b9b5eb9ce4
24 changed files with 119 additions and 122 deletions
+22 -21
View File
@@ -12,19 +12,19 @@ import (
)
func Parse(Info *HostInfo) {
ParseUser(Info)
ParseUser()
ParsePass(Info)
ParseInput(Info)
ParseScantype(Info)
}
func ParseUser(Info *HostInfo) {
if Info.Username == "" && Userfile == "" {
func ParseUser() {
if Username == "" && Userfile == "" {
return
}
if Info.Username != "" {
Info.Usernames = strings.Split(Info.Username, ",")
var Usernames []string
if Username != "" {
Usernames = strings.Split(Username, ",")
}
if Userfile != "" {
@@ -32,37 +32,38 @@ func ParseUser(Info *HostInfo) {
if err == nil {
for _, user := range users {
if user != "" {
Info.Usernames = append(Info.Usernames, user)
Usernames = append(Usernames, user)
}
}
}
}
Info.Usernames = RemoveDuplicate(Info.Usernames)
Usernames = RemoveDuplicate(Usernames)
for name := range Userdict {
Userdict[name] = Info.Usernames
Userdict[name] = Usernames
}
}
func ParsePass(Info *HostInfo) {
if Info.Password != "" {
passs := strings.Split(Info.Password, ",")
var PwdList []string
if Password != "" {
passs := strings.Split(Password, ",")
for _, pass := range passs {
if pass != "" {
Info.Passwords = append(Info.Passwords, pass)
PwdList = append(PwdList, pass)
}
}
Passwords = Info.Passwords
Passwords = PwdList
}
if Passfile != "" {
passs, err := Readfile(Passfile)
if err == nil {
for _, pass := range passs {
if pass != "" {
Info.Passwords = append(Info.Passwords, pass)
PwdList = append(PwdList, pass)
}
}
Passwords = Info.Passwords
Passwords = PwdList
}
}
if UrlFile != "" {
@@ -149,7 +150,7 @@ func ParseInput(Info *HostInfo) {
if UserAdd != "" {
user := strings.Split(UserAdd, ",")
for a, _ := range Userdict {
for a := range Userdict {
Userdict[a] = append(Userdict[a], user...)
Userdict[a] = RemoveDuplicate(Userdict[a])
}
@@ -166,12 +167,12 @@ func ParseInput(Info *HostInfo) {
}
func ParseScantype(Info *HostInfo) {
_, ok := PORTList[Info.Scantype]
_, ok := PORTList[Scantype]
if !ok {
showmode()
}
if Info.Scantype != "all" && Info.Ports == DefaultPorts+","+Webport {
switch Info.Scantype {
if Scantype != "all" && Info.Ports == DefaultPorts+","+Webport {
switch Scantype {
case "rdp":
Info.Ports = "3389"
case "web":
@@ -187,10 +188,10 @@ func ParseScantype(Info *HostInfo) {
case "main":
Info.Ports = DefaultPorts
default:
port, _ := PORTList[Info.Scantype]
port, _ := PORTList[Scantype]
Info.Ports = strconv.Itoa(port)
}
fmt.Println("-m ", Info.Scantype, " start scan the port:", Info.Ports)
fmt.Println("-m ", Scantype, " start scan the port:", Info.Ports)
}
}
+14 -18
View File
@@ -45,28 +45,15 @@ var Webport = "80,81,82,83,84,85,86,87,88,89,90,91,92,98,99,443,800,801,808,880,
var DefaultPorts = "21,22,80,81,135,139,443,445,1433,1521,3306,5432,6379,7001,8000,8080,8089,9000,9200,11211,27017"
type HostInfo struct {
Host string
Ports string
Domain string
Url string
Path string
Timeout int64
Scantype string
Command string
SshKey string
Username string
Password string
Usernames []string
Passwords []string
Infostr []string
Hash string
Host string
Ports string
Url string
Infostr []string
}
type PocInfo struct {
Num int
Rate int
Timeout int64
Proxy string
PocName string
PocDir string
Target string
@@ -79,10 +66,19 @@ type PocInfo struct {
}
var (
Path string
Scantype string
Command string
SshKey string
Domain string
Username string
Password string
Proxy string
Timeout int64
WebTimeout int64
TmpOutputfile string
TmpSave bool
IsPing bool
IsWmi bool
Ping bool
Pocinfo PocInfo
IsWebCan bool
+10 -10
View File
@@ -25,14 +25,14 @@ func Flag(Info *HostInfo) {
flag.StringVar(&UserAdd, "usera", "", "add a user base DefaultUsers,-usera user")
flag.StringVar(&PassAdd, "pwda", "", "add a password base DefaultPasses,-pwda password")
flag.StringVar(&NoPorts, "pn", "", "the ports no scan,as: -pn 445")
flag.StringVar(&Info.Command, "c", "", "exec command (ssh)")
flag.StringVar(&Info.SshKey, "sshkey", "", "sshkey file (id_rsa)")
flag.StringVar(&Info.Domain, "domain", "", "smb domain")
flag.StringVar(&Info.Username, "user", "", "username")
flag.StringVar(&Info.Password, "pwd", "", "password")
flag.Int64Var(&Info.Timeout, "time", 3, "Set timeout")
flag.StringVar(&Info.Scantype, "m", "all", "Select scan type ,as: -m ssh")
flag.StringVar(&Info.Path, "path", "", "fcgi、smb romote file path")
flag.StringVar(&Command, "c", "", "exec command (ssh)")
flag.StringVar(&SshKey, "sshkey", "", "sshkey file (id_rsa)")
flag.StringVar(&Domain, "domain", "", "smb domain")
flag.StringVar(&Username, "user", "", "username")
flag.StringVar(&Password, "pwd", "", "password")
flag.Int64Var(&Timeout, "time", 3, "Set timeout")
flag.StringVar(&Scantype, "m", "all", "Select scan type ,as: -m ssh")
flag.StringVar(&Path, "path", "", "fcgi、smb romote file path")
flag.IntVar(&Threads, "t", 600, "Thread nums")
flag.IntVar(&LiveTop, "top", 10, "show live len top")
flag.StringVar(&HostFile, "hf", "", "host file, -hf ip.txt")
@@ -55,10 +55,10 @@ func Flag(Info *HostInfo) {
flag.StringVar(&URL, "u", "", "url")
flag.StringVar(&UrlFile, "uf", "", "urlfile")
flag.StringVar(&Pocinfo.PocName, "pocname", "", "use the pocs these contain pocname, -pocname weblogic")
flag.StringVar(&Pocinfo.Proxy, "proxy", "", "set poc proxy, -proxy http://127.0.0.1:8080")
flag.StringVar(&Proxy, "proxy", "", "set poc proxy, -proxy http://127.0.0.1:8080")
flag.StringVar(&Socks5Proxy, "socks5", "", "set socks5 proxy, will be used in tcp connection, timeout setting will not work")
flag.StringVar(&Pocinfo.Cookie, "cookie", "", "set poc cookie,-cookie rememberMe=login")
flag.Int64Var(&Pocinfo.Timeout, "wt", 5, "Set web timeout")
flag.Int64Var(&WebTimeout, "wt", 5, "Set web timeout")
flag.IntVar(&Pocinfo.Num, "num", 20, "poc rate")
flag.StringVar(&SC, "sc", "", "ms17 shellcode,as -sc add")
flag.Parse()