From 936c1f53955c1c2203a1828b5ee9521e7bac076e Mon Sep 17 00:00:00 2001 From: shadow1ng Date: Sat, 29 May 2021 15:55:05 +0800 Subject: [PATCH] update --- Plugins/ftp.go | 2 -- Plugins/icmp.go | 27 +++++++++++++++++++++------ Plugins/portscan.go | 4 ++-- common/flag.go | 2 ++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Plugins/ftp.go b/Plugins/ftp.go index 2438aa3..9118275 100644 --- a/Plugins/ftp.go +++ b/Plugins/ftp.go @@ -1,11 +1,9 @@ package Plugins import ( - "errors" "fmt" "github.com/jlaffaye/ftp" "github.com/shadow1ng/fscan/common" - "net" "strings" "time" ) diff --git a/Plugins/icmp.go b/Plugins/icmp.go index 2e4af44..674bcaf 100644 --- a/Plugins/icmp.go +++ b/Plugins/icmp.go @@ -55,7 +55,7 @@ func GetSys() SystemInfo { func IcmpCheck(hostslist []string) { TmpHosts := make(map[string]struct{}) - var chanHosts = make(chan string) + var chanHosts = make(chan string, len(hostslist)) conn, err := icmp.ListenPacket("ip4:icmp", "0.0.0.0") endflag := false if err != nil { @@ -76,7 +76,7 @@ func IcmpCheck(hostslist []string) { go func() { for ip := range chanHosts { - if _, ok := TmpHosts[ip]; !ok { + if _, ok := TmpHosts[ip]; !ok && IsContain(hostslist, ip) { TmpHosts[ip] = struct{}{} if common.Silent == false { fmt.Printf("(icmp) Target '%s' is alive\n", ip) @@ -90,10 +90,25 @@ func IcmpCheck(hostslist []string) { write(host, conn) } - if len(hostslist) > 255 { - time.Sleep(6 * time.Second) - } else { - time.Sleep(3 * time.Second) + //根据hosts数量修改icmp监听时间 + start := time.Now() + for { + if len(AliveHosts) == len(hostslist) { + break + } + since := time.Now().Sub(start) + var wait time.Duration + switch { + case len(hostslist) < 30: + wait = time.Second * 1 + case len(hostslist) <= 256: + wait = time.Second * 3 + default: + wait = time.Second * 5 + } + if since > wait { + break + } } endflag = true diff --git a/Plugins/portscan.go b/Plugins/portscan.go index 93ddbc4..982d858 100644 --- a/Plugins/portscan.go +++ b/Plugins/portscan.go @@ -34,8 +34,8 @@ func PortScan(hostslist []string, ports string, timeout int64) []string { probePorts = tmpPorts } workers := common.Threads - Addrs := make(chan Addr) - results := make(chan string) + Addrs := make(chan Addr, len(hostslist)*len(probePorts)) + results := make(chan string, len(hostslist)*len(probePorts)) var wg sync.WaitGroup //接收结果 diff --git a/common/flag.go b/common/flag.go index 40a1571..04ad1d7 100644 --- a/common/flag.go +++ b/common/flag.go @@ -27,6 +27,7 @@ func Flag(Info *HostInfo) { 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.IntVar(&Threads, "t", 600, "Thread nums") flag.StringVar(&HostFile, "hf", "", "host file, -hs ip.txt") flag.StringVar(&Userfile, "userf", "", "username file") @@ -47,5 +48,6 @@ func Flag(Info *HostInfo) { flag.StringVar(&Pocinfo.Cookie, "cookie", "", "set poc cookie") flag.Int64Var(&Pocinfo.Timeout, "wt", 5, "Set web timeout") flag.IntVar(&Pocinfo.Num, "num", 20, "poc rate") + flag.StringVar(&SC, "sc", "", "ms17 sc,as -sc x86add -sc x64add") flag.Parse() }