new: experimental ipv6 ndp spoofer (closes #851)

This commit is contained in:
Simone Margaritelli 2021-04-03 22:55:03 +02:00
parent cbc1432358
commit 57436a811c
8 changed files with 256 additions and 13 deletions

View file

@ -12,21 +12,35 @@ func NewUDPProbe(from net.IP, from_hw net.HardwareAddr, to net.IP, port int) (er
EthernetType: layers.EthernetTypeIPv4,
}
ip4 := layers.IPv4{
Protocol: layers.IPProtocolUDP,
Version: 4,
TTL: 64,
SrcIP: from,
DstIP: to,
}
udp := layers.UDP{
SrcPort: layers.UDPPort(12345),
DstPort: layers.UDPPort(port),
}
udp.Payload = []byte{0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef}
udp.SetNetworkLayerForChecksum(&ip4)
if to.To4() == nil {
ip6 := layers.IPv6{
NextHeader: layers.IPProtocolUDP,
Version: 6,
SrcIP: from,
DstIP: to,
HopLimit: 64,
}
return Serialize(&eth, &ip4, &udp)
udp.SetNetworkLayerForChecksum(&ip6)
return Serialize(&eth, &ip6, &udp)
} else {
ip4 := layers.IPv4{
Protocol: layers.IPProtocolUDP,
Version: 4,
TTL: 64,
SrcIP: from,
DstIP: to,
}
udp.SetNetworkLayerForChecksum(&ip4)
return Serialize(&eth, &ip4, &udp)
}
}