优点:支持任意权限,不像ICMP需管理员权限
缺点:速度慢,扫描一个C段大约10秒左右
用法: Ladon 192.168.1.1/24 PingScan
使用LadonGo
go get github.com/k8gege/LadonGo
package main
import (
"fmt"
"flag"
"os"
"github.com/k8gege/LadonGo/ping"
)
//go run pingtest.go -host k8gege.org
var (
host string
)
func init() {
flag.StringVar(&host, "host", "", "IP/Host/Domain")
}
func main() {
flag.Parse()
if host == "" {
println("Please " + os.Args[0] + " -h")
os.Exit(0)
}
res,err := ping.CmdPing(host)
//res,err := CmdPing("k8gege.org")
if err==nil && res==true {
fmt.Println(host+" IsOnline")
}
}