Introduction To Scapy Network Packet Generator

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/introduction-scapy-network-packet-generator/
PINTEREST
PINTEREST
INSTAGRAM

Scapy is a tool for network protocol, package generation and manipulation and showing them in a visual way with graphics and 3D images. There are tools equivalent like hping3 but scapy is very flexible against it. Scapy can manipulate all data of general protocols like IP, Ethernet, tcp, udp etc. If you have a network protocol scenerio you can implement it with scapy and python scripting. I advise to read it as a whole but I may be very long for simple usage. Here I will give you quick dirty usage of scapy.

Install Scapy

Ubuntu, Debian, Mint, Kali

Ubuntu, Debian, Mint, Kali
Ubuntu, Debian, Mint, Kali

Fedora, CentOS, RedHat

Start Scapy Interactive Shell

Now we can run scapy shell or use it in our python scripts. For simplicity we run shell. Be aware that Scapy will access network stack of OS and need root privileges. So we run it with sudo. At info we get a message saying we have not GnuPlot but we will not use it.

Start Scapy Interactive Shell
Start Scapy Interactive Shell

Create IP Packet

There a lot of network protocol class and objects in scapy lets look IP by setting some options. We changed default value IP to IP.

Create TCP Packet

Now add some tcp on ip. As you see network protocols delimited with / .

Set Application Layer Data

We can assign the new packet to a variable

LEARN MORE  Linux Avahi Daemon Tutorial With Examples

Print Packet

Reading packet is very easy with string and hexdump formats

We can send packets with L2 or L3 . Below we send then L3 by looking routing table. sendp is used to send L2.

Receive Packet

Sending packet is not enough for practical usage to send and receive packets sr and sr1 function should be used. sr1 function is used only for 1 packet reply. _ is used for last reply where it is a tupple made of answered and unanswered packets. We get answer from ismailbaydan.com as it shown below.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/introduction-scapy-network-packet-generator/
PINTEREST
PINTEREST
INSTAGRAM