Golang ICMP协议探测存活主机
优点: 速度快,扫描C段仅1秒
缺点: 仅支持管理员或以上权限
Ladon 192.169.1.8/24 IcmpScan
package icmp
//Ladon Scanner for golang
//Author: k8gege
//K8Blog: http://k8gege.org
//Github: https://github.com/k8gege/LadonGo
import (
"time"
"net"
"os"
"fmt"
"log"
)
func Icmp(host string,Log *log.Logger) {
var size int
var timeout int64
var seq int16 = 1
const ECHO_REQUEST_HEAD_LEN = 8
size = 32
timeout = 1000
starttime := time.Now()
conn, err := net.DialTimeout("ip4:icmp", host, time.Duration(timeout*1000*1000))
if err != nil {
return
}
defer conn.Close()
id0, id1 := genidentifier(host)
var msg []byte = make([]byte