I would like to send my packet to a UDP dst port number and send it through eth0 interface (if scapy handles my layer2 directly, then eth0 does not need to be given as an argument)
To send a package in scapy, we have two methods: send(): Sends layer-3 packets. sendp(): Sends layer-2 packets.
The udp command is used to send and receive UDP datagram messages over an IP network.
The send() function will send packets at layer 3. That is to say, it will handle routing and layer 2 for you. The sendp() function will work at layer 2. It's up to you to choose the right interface and the right link layer protocol.
Use nc command for sending and receiving UDP packets through network. Send some human readable sentences through nc command. Capture the UDP packet sent by nc command. Check network packet in Wireshark.
Using the scapy documentation, we see that sending an UDP packet is as simple as:
send(IP(dst="127.0.0.1")/UDP(dport=123)/Raw(load="abc"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With