mirror of
https://github.com/sairson/Yasso.git
synced 2026-06-18 09:47:35 +08:00
Yasso更新大改动,更新扫描方式,去除不常用功能,增加指纹和协议识别,修补bug等
This commit is contained in:
28
pkg/netspy/icmp/icmp.go
Normal file
28
pkg/netspy/icmp/icmp.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package icmp
|
||||
|
||||
import (
|
||||
"github.com/go-ping/ping"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Check(ip string) bool {
|
||||
pinger, err := ping.NewPinger(ip)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
pinger.SetPrivileged(true)
|
||||
}
|
||||
pinger.Count = 1
|
||||
pinger.Timeout = 100 * time.Millisecond
|
||||
err = pinger.Run()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
stats := pinger.Statistics()
|
||||
if stats.PacketsRecv > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user