mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
new: experimental ipv6 ndp spoofer (closes #851)
This commit is contained in:
parent
cbc1432358
commit
57436a811c
8 changed files with 256 additions and 13 deletions
38
packets/icmp6.go
Normal file
38
packets/icmp6.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package packets
|
||||
|
||||
import (
|
||||
"github.com/google/gopacket/layers"
|
||||
"net"
|
||||
)
|
||||
|
||||
func ICMP6RouterAdvertisement(srcHW net.HardwareAddr, srcIP net.IP, dstHW net.HardwareAddr, dstIP net.IP, routerIP net.IP) (error, []byte) {
|
||||
eth := layers.Ethernet{
|
||||
SrcMAC: srcHW,
|
||||
DstMAC: dstHW,
|
||||
EthernetType: layers.EthernetTypeIPv6,
|
||||
}
|
||||
ip6 := layers.IPv6{
|
||||
NextHeader: layers.IPProtocolICMPv6,
|
||||
TrafficClass: 224,
|
||||
Version: 6,
|
||||
HopLimit: 255,
|
||||
SrcIP: srcIP,
|
||||
DstIP: dstIP,
|
||||
}
|
||||
icmp6 := layers.ICMPv6{
|
||||
TypeCode: layers.ICMPv6TypeNeighborAdvertisement << 8,
|
||||
}
|
||||
adv := layers.ICMPv6NeighborAdvertisement{
|
||||
Flags: 0x20 | 0x40, // solicited && override
|
||||
TargetAddress: routerIP,
|
||||
Options: []layers.ICMPv6Option{
|
||||
{
|
||||
Type: layers.ICMPv6OptTargetAddress,
|
||||
Data: srcHW,
|
||||
},
|
||||
},
|
||||
}
|
||||
icmp6.SetNetworkLayerForChecksum(&ip6)
|
||||
|
||||
return Serialize(ð, &ip6, &icmp6, &adv)
|
||||
}
|
|
@ -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(ð, &ip4, &udp)
|
||||
udp.SetNetworkLayerForChecksum(&ip6)
|
||||
|
||||
return Serialize(ð, &ip6, &udp)
|
||||
} else {
|
||||
ip4 := layers.IPv4{
|
||||
Protocol: layers.IPProtocolUDP,
|
||||
Version: 4,
|
||||
TTL: 64,
|
||||
SrcIP: from,
|
||||
DstIP: to,
|
||||
}
|
||||
|
||||
udp.SetNetworkLayerForChecksum(&ip4)
|
||||
|
||||
return Serialize(ð, &ip4, &udp)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue