Skip to content

Commit

Permalink
增加-silent 静默扫描模式
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow1ng committed May 14, 2021
1 parent ef6a196 commit b6133c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
9 changes: 7 additions & 2 deletions Plugins/icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package Plugins
import (
"bytes"
"fmt"
"github.com/shadow1ng/fscan/common"
"golang.org/x/net/icmp"
"log"
"net"
Expand Down Expand Up @@ -77,7 +78,9 @@ func IcmpCheck(hostslist []string) {
for ip := range chanHosts {
if _, ok := TmpHosts[ip]; !ok {
TmpHosts[ip] = struct{}{}
fmt.Printf("(icmp) Target '%s' is alive\n", ip)
if common.Silent == false {
fmt.Printf("(icmp) Target '%s' is alive\n", ip)
}
AliveHosts = append(AliveHosts, ip)
}
}
Expand Down Expand Up @@ -141,7 +144,9 @@ func PingCMDcheck(hostslist []string, bsenv string) {
defer wg.Done()
if ExecCommandPing(host, bsenv) {
mutex.Lock()
fmt.Printf("(Ping) Target '%s' is alive\n", host)
if common.Silent == false {
fmt.Printf("(Ping) Target '%s' is alive\n", host)
}
AliveHosts = append(AliveHosts, host)
mutex.Unlock()
}
Expand Down
2 changes: 1 addition & 1 deletion common/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Flag(Info *HostInfo) {
flag.BoolVar(&Ping, "ping", false, "using ping replace icmp")
flag.StringVar(&TmpOutputfile, "o", "result.txt", "Outputfile")
flag.BoolVar(&TmpSave, "no", false, "not to save output log")
flag.Int64Var(&WaitTime, "debug", 120, "every time to LogErr")
flag.Int64Var(&WaitTime, "debug", 60, "every time to LogErr")
flag.BoolVar(&Silent, "silent", false, "silent scan")
flag.StringVar(&URL, "u", "", "url")
flag.StringVar(&UrlFile, "uf", "", "urlfile")
Expand Down
14 changes: 6 additions & 8 deletions common/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func LogSuccess(result string) {

func SaveLog() {
for result := range Results {
if Silent == false {
if Silent == false || strings.Contains(result, "[+]") || strings.Contains(result, "[*]") {
fmt.Println(result)
}
if IsSave {
Expand All @@ -55,13 +55,11 @@ func WriteFile(result string, filename string) {
}

func LogError(errinfo interface{}) {
if Silent == false {
if WaitTime == 0 {
fmt.Println(fmt.Sprintf("已完成 %v/%v %v", End, Num, errinfo))
} else if (time.Now().Unix()-LogSucTime) > WaitTime && (time.Now().Unix()-LogErrTime) > WaitTime {
fmt.Println(fmt.Sprintf("已完成 %v/%v %v", End, Num, errinfo))
LogErrTime = time.Now().Unix()
}
if WaitTime == 0 {
fmt.Println(fmt.Sprintf("已完成 %v/%v %v", End, Num, errinfo))
} else if (time.Now().Unix()-LogSucTime) > WaitTime && (time.Now().Unix()-LogErrTime) > WaitTime {
fmt.Println(fmt.Sprintf("已完成 %v/%v %v", End, Num, errinfo))
LogErrTime = time.Now().Unix()
}
}

Expand Down

0 comments on commit b6133c4

Please sign in to comment.