mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-24 20:21:52 +08:00
flags to struct
This commit is contained in:
+66
-65
@@ -11,24 +11,28 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Parse(Info *HostInfo) {
|
||||
ParseUser()
|
||||
ParsePass(Info)
|
||||
ParseInput(Info)
|
||||
ParseScantype(Info)
|
||||
func Parse(inputConfig *InConfig) {
|
||||
ParseUser(&inputConfig.Flags)
|
||||
ParsePass(&inputConfig.HostInfo, &inputConfig.Flags)
|
||||
ParseInput(&inputConfig.HostInfo, &inputConfig.Flags)
|
||||
ParseScantype(&inputConfig.HostInfo, &inputConfig.Flags)
|
||||
|
||||
Outputfile = inputConfig.LogConfig.Outputfile
|
||||
IsSave = !inputConfig.LogConfig.TmpSave
|
||||
Cookie = inputConfig.Cookie
|
||||
}
|
||||
|
||||
func ParseUser() {
|
||||
if Username == "" && Userfile == "" {
|
||||
func ParseUser(flags *Flags) {
|
||||
if flags.Username == "" && flags.Userfile == "" {
|
||||
return
|
||||
}
|
||||
var Usernames []string
|
||||
if Username != "" {
|
||||
Usernames = strings.Split(Username, ",")
|
||||
if flags.Username != "" {
|
||||
Usernames = strings.Split(flags.Username, ",")
|
||||
}
|
||||
|
||||
if Userfile != "" {
|
||||
users, err := Readfile(Userfile)
|
||||
if flags.Userfile != "" {
|
||||
users, err := Readfile(flags.Userfile)
|
||||
if err == nil {
|
||||
for _, user := range users {
|
||||
if user != "" {
|
||||
@@ -44,10 +48,10 @@ func ParseUser() {
|
||||
}
|
||||
}
|
||||
|
||||
func ParsePass(Info *HostInfo) {
|
||||
func ParsePass(Info *HostInfo, flags *Flags) {
|
||||
var PwdList []string
|
||||
if Password != "" {
|
||||
passs := strings.Split(Password, ",")
|
||||
if flags.Password != "" {
|
||||
passs := strings.Split(flags.Password, ",")
|
||||
for _, pass := range passs {
|
||||
if pass != "" {
|
||||
PwdList = append(PwdList, pass)
|
||||
@@ -55,8 +59,8 @@ func ParsePass(Info *HostInfo) {
|
||||
}
|
||||
Passwords = PwdList
|
||||
}
|
||||
if Passfile != "" {
|
||||
passs, err := Readfile(Passfile)
|
||||
if flags.Passfile != "" {
|
||||
passs, err := Readfile(flags.Passfile)
|
||||
if err == nil {
|
||||
for _, pass := range passs {
|
||||
if pass != "" {
|
||||
@@ -66,34 +70,35 @@ func ParsePass(Info *HostInfo) {
|
||||
Passwords = PwdList
|
||||
}
|
||||
}
|
||||
if URL != "" {
|
||||
urls := strings.Split(URL, ",")
|
||||
|
||||
if flags.URL != "" {
|
||||
urls := strings.Split(flags.URL, ",")
|
||||
TmpUrls := make(map[string]struct{})
|
||||
for _, url := range urls {
|
||||
if _, ok := TmpUrls[url]; !ok {
|
||||
TmpUrls[url] = struct{}{}
|
||||
if url != "" {
|
||||
Urls = append(Urls, url)
|
||||
flags.Urls = append(flags.Urls, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if UrlFile != "" {
|
||||
urls, err := Readfile(UrlFile)
|
||||
if flags.UrlFile != "" {
|
||||
urls, err := Readfile(flags.UrlFile)
|
||||
if err == nil {
|
||||
TmpUrls := make(map[string]struct{})
|
||||
for _, url := range urls {
|
||||
if _, ok := TmpUrls[url]; !ok {
|
||||
TmpUrls[url] = struct{}{}
|
||||
if url != "" {
|
||||
Urls = append(Urls, url)
|
||||
flags.Urls = append(flags.Urls, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if PortFile != "" {
|
||||
ports, err := Readfile(PortFile)
|
||||
if flags.PortFile != "" {
|
||||
ports, err := Readfile(flags.PortFile)
|
||||
if err == nil {
|
||||
newport := ""
|
||||
for _, port := range ports {
|
||||
@@ -125,88 +130,84 @@ func Readfile(filename string) ([]string, error) {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
func ParseInput(Info *HostInfo) {
|
||||
if Info.Host == "" && HostFile == "" && URL == "" && UrlFile == "" {
|
||||
func ParseInput(Info *HostInfo, flags *Flags) {
|
||||
if Info.Host == "" && flags.HostFile == "" && flags.URL == "" && flags.UrlFile == "" {
|
||||
fmt.Println("Host is none")
|
||||
flag.Usage()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if BruteThread <= 0 {
|
||||
BruteThread = 1
|
||||
}
|
||||
|
||||
if TmpSave == true {
|
||||
IsSave = false
|
||||
if flags.BruteThread <= 0 {
|
||||
flags.BruteThread = 1
|
||||
}
|
||||
|
||||
if Info.Ports == DefaultPorts {
|
||||
Info.Ports += "," + Webport
|
||||
}
|
||||
|
||||
if PortAdd != "" {
|
||||
if flags.PortAdd != "" {
|
||||
if strings.HasSuffix(Info.Ports, ",") {
|
||||
Info.Ports += PortAdd
|
||||
Info.Ports += flags.PortAdd
|
||||
} else {
|
||||
Info.Ports += "," + PortAdd
|
||||
Info.Ports += "," + flags.PortAdd
|
||||
}
|
||||
}
|
||||
|
||||
if UserAdd != "" {
|
||||
user := strings.Split(UserAdd, ",")
|
||||
if flags.UserAdd != "" {
|
||||
user := strings.Split(flags.UserAdd, ",")
|
||||
for a := range Userdict {
|
||||
Userdict[a] = append(Userdict[a], user...)
|
||||
Userdict[a] = RemoveDuplicate(Userdict[a])
|
||||
}
|
||||
}
|
||||
|
||||
if PassAdd != "" {
|
||||
pass := strings.Split(PassAdd, ",")
|
||||
if flags.PassAdd != "" {
|
||||
pass := strings.Split(flags.PassAdd, ",")
|
||||
Passwords = append(Passwords, pass...)
|
||||
Passwords = RemoveDuplicate(Passwords)
|
||||
}
|
||||
if Socks5Proxy != "" && !strings.HasPrefix(Socks5Proxy, "socks5://") {
|
||||
if !strings.Contains(Socks5Proxy, ":") {
|
||||
Socks5Proxy = "socks5://127.0.0.1" + Socks5Proxy
|
||||
if flags.Socks5Proxy != "" && !strings.HasPrefix(flags.Socks5Proxy, "socks5://") {
|
||||
if !strings.Contains(flags.Socks5Proxy, ":") {
|
||||
flags.Socks5Proxy = "socks5://127.0.0.1" + flags.Socks5Proxy
|
||||
} else {
|
||||
Socks5Proxy = "socks5://" + Socks5Proxy
|
||||
flags.Socks5Proxy = "socks5://" + flags.Socks5Proxy
|
||||
}
|
||||
}
|
||||
if Socks5Proxy != "" {
|
||||
fmt.Println("Socks5Proxy:", Socks5Proxy)
|
||||
_, err := url.Parse(Socks5Proxy)
|
||||
if flags.Socks5Proxy != "" {
|
||||
fmt.Println("Socks5Proxy:", flags.Socks5Proxy)
|
||||
_, err := url.Parse(flags.Socks5Proxy)
|
||||
if err != nil {
|
||||
fmt.Println("Socks5Proxy parse error:", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
NoPing = true
|
||||
flags.NoPing = true
|
||||
}
|
||||
if Proxy != "" {
|
||||
if Proxy == "1" {
|
||||
Proxy = "http://127.0.0.1:8080"
|
||||
} else if Proxy == "2" {
|
||||
Proxy = "socks5://127.0.0.1:1080"
|
||||
} else if !strings.Contains(Proxy, "://") {
|
||||
Proxy = "http://127.0.0.1:" + Proxy
|
||||
if flags.Proxy != "" {
|
||||
if flags.Proxy == "1" {
|
||||
flags.Proxy = "http://127.0.0.1:8080"
|
||||
} else if flags.Proxy == "2" {
|
||||
flags.Proxy = "socks5://127.0.0.1:1080"
|
||||
} else if !strings.Contains(flags.Proxy, "://") {
|
||||
flags.Proxy = "http://127.0.0.1:" + flags.Proxy
|
||||
}
|
||||
fmt.Println("Proxy:", Proxy)
|
||||
if !strings.HasPrefix(Proxy, "socks") && !strings.HasPrefix(Proxy, "http") {
|
||||
fmt.Println("Proxy:", flags.Proxy)
|
||||
if !strings.HasPrefix(flags.Proxy, "socks") && !strings.HasPrefix(flags.Proxy, "http") {
|
||||
fmt.Println("no support this proxy")
|
||||
os.Exit(0)
|
||||
}
|
||||
_, err := url.Parse(Proxy)
|
||||
_, err := url.Parse(flags.Proxy)
|
||||
if err != nil {
|
||||
fmt.Println("Proxy parse error:", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
if Hash != "" && len(Hash) != 32 {
|
||||
if flags.Hash != "" && len(flags.Hash) != 32 {
|
||||
fmt.Println("[-] Hash is error,len(hash) must be 32")
|
||||
os.Exit(0)
|
||||
} else {
|
||||
var err error
|
||||
HashBytes, err = hex.DecodeString(Hash)
|
||||
flags.HashBytes, err = hex.DecodeString(flags.Hash)
|
||||
if err != nil {
|
||||
fmt.Println("[-] Hash is error,hex decode error")
|
||||
os.Exit(0)
|
||||
@@ -214,13 +215,13 @@ func ParseInput(Info *HostInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
func ParseScantype(Info *HostInfo) {
|
||||
_, ok := PORTList[Scantype]
|
||||
func ParseScantype(Info *HostInfo, flags *Flags) {
|
||||
_, ok := PORTList[flags.Scantype]
|
||||
if !ok {
|
||||
showmode()
|
||||
}
|
||||
if Scantype != "all" && Info.Ports == DefaultPorts+","+Webport {
|
||||
switch Scantype {
|
||||
if flags.Scantype != "all" && Info.Ports == DefaultPorts+","+Webport {
|
||||
switch flags.Scantype {
|
||||
case "wmiexec":
|
||||
Info.Ports = "135"
|
||||
case "wmiinfo":
|
||||
@@ -244,10 +245,10 @@ func ParseScantype(Info *HostInfo) {
|
||||
case "main":
|
||||
Info.Ports = DefaultPorts
|
||||
default:
|
||||
port, _ := PORTList[Scantype]
|
||||
port, _ := PORTList[flags.Scantype]
|
||||
Info.Ports = strconv.Itoa(port)
|
||||
}
|
||||
fmt.Println("-m ", Scantype, " start scan the port:", Info.Ports)
|
||||
fmt.Println("-m ", flags.Scantype, " start scan the port:", Info.Ports)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-10
@@ -23,11 +23,11 @@ var ParseIPErr = errors.New(" host parsing error\n" +
|
||||
"192.168.1.1-192.168.255.255\n" +
|
||||
"192.168.1.1-255")
|
||||
|
||||
func ParseIP(host string, filename string, nohosts ...string) (hosts []string, err error) {
|
||||
func ParseIP(hostPort *[]string, host string, filename string, nohosts ...string) (hosts []string, err error) {
|
||||
hosts = ParseIPs(host)
|
||||
if filename != "" {
|
||||
var filehost []string
|
||||
filehost, _ = Readipfile(filename)
|
||||
filehost, _ = readipfile(hostPort, filename)
|
||||
hosts = append(hosts, filehost...)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func ParseIP(host string, filename string, nohosts ...string) (hosts []string, e
|
||||
}
|
||||
}
|
||||
hosts = RemoveDuplicate(hosts)
|
||||
if len(hosts) == 0 && len(HostPort) == 0 && host != "" && filename != "" {
|
||||
if len(hosts) == 0 && len(*hostPort) == 0 && host != "" && filename != "" {
|
||||
err = ParseIPErr
|
||||
}
|
||||
return
|
||||
@@ -115,7 +115,8 @@ func parseIP2(host string) (hosts []string) {
|
||||
}
|
||||
|
||||
// 解析ip段: 192.168.111.1-255
|
||||
// 192.168.111.1-192.168.112.255
|
||||
//
|
||||
// 192.168.111.1-192.168.112.255
|
||||
func parseIP1(ip string) []string {
|
||||
IPRange := strings.Split(ip, "-")
|
||||
testIP := net.ParseIP(IPRange[0])
|
||||
@@ -175,19 +176,22 @@ func IPRange(c *net.IPNet) string {
|
||||
}
|
||||
|
||||
// 按行读ip
|
||||
func Readipfile(filename string) ([]string, error) {
|
||||
func readipfile(hostPort *[]string, filename string) ([]string, error) {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
fmt.Printf("Open %s error, %v", filename, err)
|
||||
os.Exit(0)
|
||||
}
|
||||
defer file.Close()
|
||||
var content []string
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
||||
var content []string
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
if line != "" {
|
||||
var hosts []string
|
||||
text := strings.Split(line, ":")
|
||||
if len(text) == 2 {
|
||||
port := strings.Split(text[1], " ")[0]
|
||||
@@ -195,14 +199,14 @@ func Readipfile(filename string) ([]string, error) {
|
||||
if err != nil || (num < 1 || num > 65535) {
|
||||
continue
|
||||
}
|
||||
hosts := ParseIPs(text[0])
|
||||
hosts = ParseIPs(text[0])
|
||||
for _, host := range hosts {
|
||||
HostPort = append(HostPort, fmt.Sprintf("%s:%s", host, port))
|
||||
*hostPort = append(*hostPort, fmt.Sprintf("%s:%s", host, port))
|
||||
}
|
||||
} else {
|
||||
host := ParseIPs(line)
|
||||
content = append(content, host...)
|
||||
hosts = ParseIPs(line)
|
||||
}
|
||||
content = append(content, hosts...)
|
||||
}
|
||||
}
|
||||
return content, nil
|
||||
|
||||
+8
-13
@@ -41,16 +41,16 @@ var PORTList = map[string]int{
|
||||
"main": 0,
|
||||
}
|
||||
|
||||
var Outputfile = "result.txt"
|
||||
var IsSave = true
|
||||
var Webport = "80,81,82,83,84,85,86,87,88,89,90,91,92,98,99,443,800,801,808,880,888,889,1000,1010,1080,1081,1082,1099,1118,1888,2008,2020,2100,2375,2379,3000,3008,3128,3505,5555,6080,6648,6868,7000,7001,7002,7003,7004,7005,7007,7008,7070,7071,7074,7078,7080,7088,7200,7680,7687,7688,7777,7890,8000,8001,8002,8003,8004,8006,8008,8009,8010,8011,8012,8016,8018,8020,8028,8030,8038,8042,8044,8046,8048,8053,8060,8069,8070,8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096,8097,8098,8099,8100,8101,8108,8118,8161,8172,8180,8181,8200,8222,8244,8258,8280,8288,8300,8360,8443,8448,8484,8800,8834,8838,8848,8858,8868,8879,8880,8881,8888,8899,8983,8989,9000,9001,9002,9008,9010,9043,9060,9080,9081,9082,9083,9084,9085,9086,9087,9088,9089,9090,9091,9092,9093,9094,9095,9096,9097,9098,9099,9100,9200,9443,9448,9800,9981,9986,9988,9998,9999,10000,10001,10002,10004,10008,10010,10250,12018,12443,14000,16080,18000,18001,18002,18004,18008,18080,18082,18088,18090,18098,19001,20000,20720,21000,21501,21502,28018,20880"
|
||||
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
|
||||
Url string
|
||||
Infostr []string
|
||||
Host string
|
||||
Ports string
|
||||
Url string
|
||||
Infostr []string
|
||||
HostPort []string // locks like dead varibale, I cannot file initialization of this variable
|
||||
}
|
||||
|
||||
type PocInfo struct {
|
||||
@@ -59,12 +59,7 @@ type PocInfo struct {
|
||||
}
|
||||
|
||||
var (
|
||||
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
|
||||
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
|
||||
DnsLog bool
|
||||
PocNum int
|
||||
PocFull bool
|
||||
CeyeDomain string
|
||||
ApiKey string
|
||||
Cookie string
|
||||
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
|
||||
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
|
||||
Cookie string
|
||||
)
|
||||
|
||||
+74
-53
@@ -4,7 +4,8 @@ import (
|
||||
"flag"
|
||||
)
|
||||
|
||||
var (
|
||||
// todo make function
|
||||
type Flags struct {
|
||||
Path string
|
||||
Scantype string
|
||||
Command string
|
||||
@@ -13,9 +14,8 @@ var (
|
||||
Username string
|
||||
Password string
|
||||
Proxy string
|
||||
Timeout int64 = 3
|
||||
WebTimeout int64 = 5
|
||||
TmpSave bool
|
||||
Timeout int64
|
||||
WebTimeout int64
|
||||
NoPing bool
|
||||
Ping bool
|
||||
Pocinfo PocInfo
|
||||
@@ -43,56 +43,77 @@ var (
|
||||
Socks5Proxy string
|
||||
Hash string
|
||||
HashBytes []byte
|
||||
HostPort []string
|
||||
IsWmi bool
|
||||
)
|
||||
PocNum int
|
||||
PocFull bool
|
||||
DnsLog bool
|
||||
}
|
||||
|
||||
// todo make function
|
||||
type LogConfig struct {
|
||||
Silent bool
|
||||
Outputfile string
|
||||
TmpSave bool
|
||||
WaitTime int64
|
||||
}
|
||||
|
||||
type InConfig struct {
|
||||
HostInfo HostInfo
|
||||
Flags Flags
|
||||
LogConfig LogConfig
|
||||
Cookie string
|
||||
}
|
||||
|
||||
func Flag(inConfig *InConfig) {
|
||||
flag.StringVar(&inConfig.HostInfo.Host, "h", "", "IP address of the host you want to scan,for example: 192.168.11.11 | 192.168.11.11-255 | 192.168.11.11,192.168.11.12")
|
||||
flag.StringVar(&inConfig.HostInfo.Ports, "p", DefaultPorts, "Select a port,for example: 22 | 1-65535 | 22,80,3306")
|
||||
|
||||
flag.StringVar(&inConfig.Flags.NoHosts, "hn", "", "the hosts no scan,as: -hn 192.168.1.1/24")
|
||||
flag.StringVar(&inConfig.Flags.PortAdd, "pa", "", "add port base DefaultPorts,-pa 3389")
|
||||
flag.StringVar(&inConfig.Flags.UserAdd, "usera", "", "add a user base DefaultUsers,-usera user")
|
||||
flag.StringVar(&inConfig.Flags.PassAdd, "pwda", "", "add a password base DefaultPasses,-pwda password")
|
||||
flag.StringVar(&inConfig.Flags.NoPorts, "pn", "", "the ports no scan,as: -pn 445")
|
||||
flag.StringVar(&inConfig.Flags.Command, "c", "", "exec command (ssh|wmiexec)")
|
||||
flag.StringVar(&inConfig.Flags.SshKey, "sshkey", "", "sshkey file (id_rsa)")
|
||||
flag.StringVar(&inConfig.Flags.Domain, "domain", "", "smb domain")
|
||||
flag.StringVar(&inConfig.Flags.Username, "user", "", "username")
|
||||
flag.StringVar(&inConfig.Flags.Password, "pwd", "", "password")
|
||||
flag.Int64Var(&inConfig.Flags.Timeout, "time", 3, "Set timeout")
|
||||
flag.Int64Var(&inConfig.Flags.WebTimeout, "wt", 5, "Set web timeout")
|
||||
flag.StringVar(&inConfig.Flags.Scantype, "m", "all", "Select scan type ,as: -m ssh")
|
||||
flag.StringVar(&inConfig.Flags.Path, "path", "", "fcgi、smb romote file path")
|
||||
flag.IntVar(&inConfig.Flags.Threads, "t", 600, "Thread nums")
|
||||
flag.IntVar(&inConfig.Flags.LiveTop, "top", 10, "show live len top")
|
||||
flag.StringVar(&inConfig.Flags.HostFile, "hf", "", "host file, -hf ip.txt")
|
||||
flag.StringVar(&inConfig.Flags.Userfile, "userf", "", "username file")
|
||||
flag.StringVar(&inConfig.Flags.Passfile, "pwdf", "", "password file")
|
||||
flag.StringVar(&inConfig.Flags.PortFile, "portf", "", "Port File")
|
||||
flag.StringVar(&inConfig.Flags.PocPath, "pocpath", "", "poc file path")
|
||||
flag.StringVar(&inConfig.Flags.RedisFile, "rf", "", "redis file to write sshkey file (as: -rf id_rsa.pub) ")
|
||||
flag.StringVar(&inConfig.Flags.RedisShell, "rs", "", "redis shell to write cron file (as: -rs 192.168.1.1:6666) ")
|
||||
flag.BoolVar(&inConfig.Flags.IsWebCan, "nopoc", false, "not to scan web vul")
|
||||
flag.BoolVar(&inConfig.Flags.IsBrute, "nobr", false, "not to Brute password")
|
||||
flag.IntVar(&inConfig.Flags.BruteThread, "br", 1, "Brute threads")
|
||||
flag.BoolVar(&inConfig.Flags.NoPing, "np", false, "not to ping")
|
||||
flag.BoolVar(&inConfig.Flags.Ping, "ping", false, "using ping replace icmp")
|
||||
flag.StringVar(&inConfig.Flags.URL, "u", "", "url")
|
||||
flag.StringVar(&inConfig.Flags.UrlFile, "uf", "", "urlfile")
|
||||
flag.StringVar(&inConfig.Flags.Pocinfo.PocName, "pocname", "", "use the pocs these contain pocname, -pocname weblogic")
|
||||
flag.IntVar(&inConfig.Flags.PocNum, "num", 20, "poc rate")
|
||||
flag.StringVar(&inConfig.Flags.Proxy, "proxy", "", "set poc proxy, -proxy http://127.0.0.1:8080")
|
||||
flag.StringVar(&inConfig.Flags.Socks5Proxy, "socks5", "", "set socks5 proxy, will be used in tcp connection, timeout setting will not work")
|
||||
flag.StringVar(&inConfig.Flags.SC, "sc", "", "ms17 shellcode,as -sc add")
|
||||
flag.BoolVar(&inConfig.Flags.IsWmi, "wmi", false, "start wmi")
|
||||
flag.StringVar(&inConfig.Flags.Hash, "hash", "", "hash")
|
||||
flag.BoolVar(&inConfig.Flags.PocFull, "full", false, "poc full scan,as: shiro 100 key")
|
||||
flag.BoolVar(&inConfig.Flags.DnsLog, "dns", false, "using dnslog poc")
|
||||
|
||||
flag.StringVar(&inConfig.LogConfig.Outputfile, "o", "result.txt", "Outputfile")
|
||||
flag.BoolVar(&inConfig.LogConfig.TmpSave, "no", false, "not to save output log")
|
||||
flag.Int64Var(&inConfig.LogConfig.WaitTime, "debug", 60, "every time to LogErr")
|
||||
flag.BoolVar(&inConfig.LogConfig.Silent, "silent", false, "silent scan")
|
||||
|
||||
flag.StringVar(&inConfig.Cookie, "cookie", "", "set poc cookie,-cookie rememberMe=login")
|
||||
|
||||
func Flag(Info *HostInfo) {
|
||||
flag.StringVar(&Info.Host, "h", "", "IP address of the host you want to scan,for example: 192.168.11.11 | 192.168.11.11-255 | 192.168.11.11,192.168.11.12")
|
||||
flag.StringVar(&NoHosts, "hn", "", "the hosts no scan,as: -hn 192.168.1.1/24")
|
||||
flag.StringVar(&Info.Ports, "p", DefaultPorts, "Select a port,for example: 22 | 1-65535 | 22,80,3306")
|
||||
flag.StringVar(&PortAdd, "pa", "", "add port base DefaultPorts,-pa 3389")
|
||||
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(&Command, "c", "", "exec command (ssh|wmiexec)")
|
||||
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")
|
||||
flag.StringVar(&Userfile, "userf", "", "username file")
|
||||
flag.StringVar(&Passfile, "pwdf", "", "password file")
|
||||
flag.StringVar(&PortFile, "portf", "", "Port File")
|
||||
flag.StringVar(&PocPath, "pocpath", "", "poc file path")
|
||||
flag.StringVar(&RedisFile, "rf", "", "redis file to write sshkey file (as: -rf id_rsa.pub) ")
|
||||
flag.StringVar(&RedisShell, "rs", "", "redis shell to write cron file (as: -rs 192.168.1.1:6666) ")
|
||||
flag.BoolVar(&IsWebCan, "nopoc", false, "not to scan web vul")
|
||||
flag.BoolVar(&IsBrute, "nobr", false, "not to Brute password")
|
||||
flag.IntVar(&BruteThread, "br", 1, "Brute threads")
|
||||
flag.BoolVar(&NoPing, "np", false, "not to ping")
|
||||
flag.BoolVar(&Ping, "ping", false, "using ping replace icmp")
|
||||
flag.StringVar(&Outputfile, "o", "result.txt", "Outputfile")
|
||||
flag.BoolVar(&TmpSave, "no", false, "not to save output log")
|
||||
flag.Int64Var(&WaitTime, "debug", 60, "every time to LogErr")
|
||||
flag.BoolVar(&Silent, "silent", false, "silent scan")
|
||||
flag.BoolVar(&PocFull, "full", false, "poc full scan,as: shiro 100 key")
|
||||
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(&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(&Cookie, "cookie", "", "set poc cookie,-cookie rememberMe=login")
|
||||
flag.Int64Var(&WebTimeout, "wt", 5, "Set web timeout")
|
||||
flag.BoolVar(&DnsLog, "dns", false, "using dnslog poc")
|
||||
flag.IntVar(&PocNum, "num", 20, "poc rate")
|
||||
flag.StringVar(&SC, "sc", "", "ms17 shellcode,as -sc add")
|
||||
flag.BoolVar(&IsWmi, "wmi", false, "start wmi")
|
||||
flag.StringVar(&Hash, "hash", "", "hash")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ var LogErrTime int64
|
||||
var WaitTime int64
|
||||
var Silent bool
|
||||
var LogWG sync.WaitGroup
|
||||
var Outputfile string
|
||||
|
||||
func init() {
|
||||
LogSucTime = time.Now().Unix()
|
||||
@@ -57,9 +58,9 @@ func WriteFile(result string, filename string) {
|
||||
|
||||
func LogError(errinfo interface{}) {
|
||||
if WaitTime == 0 {
|
||||
fmt.Printf("已完成 %v/%v %v \n", End, Num, errinfo)
|
||||
fmt.Printf("completed %v/%v %v \n", End, Num, errinfo)
|
||||
} else if (time.Now().Unix()-LogSucTime) > WaitTime && (time.Now().Unix()-LogErrTime) > WaitTime {
|
||||
fmt.Printf("已完成 %v/%v %v \n", End, Num, errinfo)
|
||||
fmt.Printf("completed %v/%v %v \n", End, Num, errinfo)
|
||||
LogErrTime = time.Now().Unix()
|
||||
}
|
||||
}
|
||||
|
||||
+20
-16
@@ -2,43 +2,47 @@ package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"golang.org/x/net/proxy"
|
||||
"net"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
func WrapperTcpWithTimeout(network, address string, timeout time.Duration) (net.Conn, error) {
|
||||
d := &net.Dialer{Timeout: timeout}
|
||||
return WrapperTCP(network, address, d)
|
||||
type Socks5 struct {
|
||||
Address string
|
||||
}
|
||||
|
||||
func WrapperTCP(network, address string,forward * net.Dialer) (net.Conn, error) {
|
||||
func WrapperTcpWithTimeout(network, address string, socks5Proxy Socks5, timeout time.Duration) (net.Conn, error) {
|
||||
d := &net.Dialer{Timeout: timeout}
|
||||
return WrapperTCP(network, address, socks5Proxy, d)
|
||||
}
|
||||
|
||||
func WrapperTCP(network, address string, socks5Proxy Socks5, forward *net.Dialer) (net.Conn, error) {
|
||||
//get conn
|
||||
var conn net.Conn
|
||||
if Socks5Proxy == "" {
|
||||
if socks5Proxy.Address == "" {
|
||||
var err error
|
||||
conn,err = forward.Dial(network, address)
|
||||
conn, err = forward.Dial(network, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}else {
|
||||
dailer, err := Socks5Dailer(forward)
|
||||
if err != nil{
|
||||
} else {
|
||||
dailer, err := Socks5Dailer(forward, socks5Proxy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conn,err = dailer.Dial(network, address)
|
||||
conn, err = dailer.Dial(network, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return conn, nil
|
||||
|
||||
}
|
||||
|
||||
func Socks5Dailer(forward * net.Dialer) (proxy.Dialer, error) {
|
||||
u,err := url.Parse(Socks5Proxy)
|
||||
func Socks5Dailer(forward *net.Dialer, socks5Proxy Socks5) (proxy.Dialer, error) {
|
||||
u, err := url.Parse(socks5Proxy.Address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -51,10 +55,10 @@ func Socks5Dailer(forward * net.Dialer) (proxy.Dialer, error) {
|
||||
if u.User.String() != "" {
|
||||
auth = proxy.Auth{}
|
||||
auth.User = u.User.Username()
|
||||
password,_ := u.User.Password()
|
||||
password, _ := u.User.Password()
|
||||
auth.Password = password
|
||||
dailer, err = proxy.SOCKS5("tcp", address, &auth, forward)
|
||||
}else {
|
||||
} else {
|
||||
dailer, err = proxy.SOCKS5("tcp", address, nil, forward)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user