Packet Manipulation With Scapy

Scapy is written in Python by Philippe Biondi. It is used for packet manipulation With Scapy in networks.  Scapy can forge or decode packets, send them on the wire, catch them, and match requests and replies. It can likewise deal with errands like scanning, tracerouting, probing, unit tests, attacks, and network discovery.

Scapy banner


Features of Scapy:

  • Packet Manipulation
  • Packet Capture
  • Match Requests and Replies
  • Scanning
  • Tracerouting
  • Probing
  • Attacks
  • Network Discovery
How to install Scapy?

Step 1: Clone the repository

  Scapy Clone the repository
cloning the repository from github

git clone

Step 2: Change the directory

Scapy Change the directory
Change the directory

cd scapy/

Step 3: Run the “run_scapy”

Scapy Run the “run_scapy”
run the installer file run_scapy


How to install Scapy with pip?

How to install Scapy with pip?
scapy installation by pip

pip install scapy


How to packet manipulation with Scapy?

Send Packet 

send(): Send packets at Layer 3
IP(): Define Source IP and Destination IP
ICMP(): Internet Control Message Protocol
src: Source IP
dst: Destination IP

send(IP(src=”Source IP”,dst=”Destination IP”)/ICMP()/”Text”)

Send Packet with scapy
Send Packet with scapy

send(IP(src=”″,dst=” “)/ICMP()/”Hello World”)

Check response in Wireshark:

packets show on wireshark
packets show on wireshark
haxdump of packet
haxdump of packet

Sniff Packet

Iface: Name of interface
prn: function to apply to each packet
lambda: we can now perform custom actions with each sniffed packet.
X: variable
x.summary: Print the summary of the output

sniff(iface=”Interface”, prn=lambda x:x.summary)

sniff(iface=”wlan0″, prn=lambda x:x.summary)

sniff packets
sniff packets with scapy


Sniff Packet output
output of Sniff Packet



Send multiple packet
TCP: Transmission Control Protocol
sport: Source port
dport: Destination port
count: number of packets

send(IP(src=”Source IP”,dst=”Destination IP”)/TCP(sport=Source port, dport=Destination port), count=number of packets)

send(IP(src=”″,dst=”″)/TCP(sport=80, dport=80), count=10)

sending multiple packets with scapy
sending multiple packets with scapy

Check response in Wireshark:

Check response in Wireshark
Check response in Wireshark of sending packets

Home: –

You May Also Like To Read

How to protect yourself from hackers 2021

Joint Cyber program UK | US and Australia Press Release

Nuclei Vulnerability Scanner tools | fast and customizable


About Author

Leave a Reply

Your email address will not be published. Required fields are marked *

Open chat
Can we help you?