mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
yeah i should have done this before, i know
This commit is contained in:
commit
0091ffdbb3
33 changed files with 25678 additions and 0 deletions
32
packets/udp.go
Normal file
32
packets/udp.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package packets
|
||||
|
||||
import (
|
||||
"github.com/google/gopacket/layers"
|
||||
"net"
|
||||
)
|
||||
|
||||
func NewUDPProbe(from net.IP, from_hw net.HardwareAddr, to net.IP, port int) (error, []byte) {
|
||||
eth := layers.Ethernet{
|
||||
SrcMAC: from_hw,
|
||||
DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
|
||||
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)
|
||||
|
||||
return Serialize(ð, &ip4, &udp)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue