Introduction To Scapy Network Packet Generator


Scapy is a tool for network protocol, package generation and manupilation and showing them in a visual way with graphics and 3D images. There are tools equvalent like hping3 but scapy is very flexible against it. Scapy can manupalte 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. Official site resides here and documentation can be accessed from here. 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.

We check for scapy version and info. To use this article it must be at least version 2.1 and above. Version 2.2 is good with fedora 21_x64

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 privilages. So we run it with sudo. At info we get a message saying we have not gnuplot but we will not use it.

LEARN MORE  Vim Syntax Highlighting How To Turn On , Off

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

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

We can assign the new packet to a variable

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.

LEARN MORE  How To Set Permission For Folders and Subfolders in Linux

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 tubble made of answered and unanswered packets. We get answer from as it shown below.

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)