This commit is contained in:
shadow1ng 2021-05-29 15:55:05 +08:00
parent 9d385eb26a
commit 936c1f5395
4 changed files with 25 additions and 10 deletions

View File

@ -1,11 +1,9 @@
package Plugins package Plugins
import ( import (
"errors"
"fmt" "fmt"
"github.com/jlaffaye/ftp" "github.com/jlaffaye/ftp"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"net"
"strings" "strings"
"time" "time"
) )

View File

@ -55,7 +55,7 @@ func GetSys() SystemInfo {
func IcmpCheck(hostslist []string) { func IcmpCheck(hostslist []string) {
TmpHosts := make(map[string]struct{}) 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") conn, err := icmp.ListenPacket("ip4:icmp", "0.0.0.0")
endflag := false endflag := false
if err != nil { if err != nil {
@ -76,7 +76,7 @@ func IcmpCheck(hostslist []string) {
go func() { go func() {
for ip := range chanHosts { for ip := range chanHosts {
if _, ok := TmpHosts[ip]; !ok { if _, ok := TmpHosts[ip]; !ok && IsContain(hostslist, ip) {
TmpHosts[ip] = struct{}{} TmpHosts[ip] = struct{}{}
if common.Silent == false { if common.Silent == false {
fmt.Printf("(icmp) Target '%s' is alive\n", ip) fmt.Printf("(icmp) Target '%s' is alive\n", ip)
@ -90,10 +90,25 @@ func IcmpCheck(hostslist []string) {
write(host, conn) write(host, conn)
} }
if len(hostslist) > 255 { //根据hosts数量修改icmp监听时间
time.Sleep(6 * time.Second) start := time.Now()
} else { for {
time.Sleep(3 * time.Second) 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 endflag = true

View File

@ -34,8 +34,8 @@ func PortScan(hostslist []string, ports string, timeout int64) []string {
probePorts = tmpPorts probePorts = tmpPorts
} }
workers := common.Threads workers := common.Threads
Addrs := make(chan Addr) Addrs := make(chan Addr, len(hostslist)*len(probePorts))
results := make(chan string) results := make(chan string, len(hostslist)*len(probePorts))
var wg sync.WaitGroup var wg sync.WaitGroup
//接收结果 //接收结果

View File

@ -27,6 +27,7 @@ func Flag(Info *HostInfo) {
flag.StringVar(&Info.Password, "pwd", "", "password") flag.StringVar(&Info.Password, "pwd", "", "password")
flag.Int64Var(&Info.Timeout, "time", 3, "Set timeout") flag.Int64Var(&Info.Timeout, "time", 3, "Set timeout")
flag.StringVar(&Info.Scantype, "m", "all", "Select scan type ,as: -m ssh") 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.IntVar(&Threads, "t", 600, "Thread nums")
flag.StringVar(&HostFile, "hf", "", "host file, -hs ip.txt") flag.StringVar(&HostFile, "hf", "", "host file, -hs ip.txt")
flag.StringVar(&Userfile, "userf", "", "username file") flag.StringVar(&Userfile, "userf", "", "username file")
@ -47,5 +48,6 @@ func Flag(Info *HostInfo) {
flag.StringVar(&Pocinfo.Cookie, "cookie", "", "set poc cookie") flag.StringVar(&Pocinfo.Cookie, "cookie", "", "set poc cookie")
flag.Int64Var(&Pocinfo.Timeout, "wt", 5, "Set web timeout") flag.Int64Var(&Pocinfo.Timeout, "wt", 5, "Set web timeout")
flag.IntVar(&Pocinfo.Num, "num", 20, "poc rate") flag.IntVar(&Pocinfo.Num, "num", 20, "poc rate")
flag.StringVar(&SC, "sc", "", "ms17 sc,as -sc x86add -sc x64add")
flag.Parse() flag.Parse()
} }