Simple Packet Send and Response

Learn how to send packets in Scapy and analyze the responses.

Sending packets with sr()

So far, we’ve been working with static packet captures, including reading and modifying their contents. However, if we want to build port scanners, honeypots, or servers, we need to be able to send and receive traffic over the network.

Luckily, Scapy has several different functions for doing this. We’ll start out by sending a single packet and looking for matching responses.

In the code block below, we’re using Scapy’s sr() function to send and receive packets. In this case, we’re sending a TCP SYN packet to the DNS port (port 53) of one of Google’s DNS servers (8.8.4.4).

Get hands-on with 1200+ tech skills courses.