Scapy, a Python packet crafting tool, has become my new BFF. Yet, until Scapy arrived, crafting something as sophisticated as a TCP session was possible. This tutorial shows how to send a icmp ping packet with Python and Scapy. The tool which is named as L3 troubleshooting tool sends a ping packet to the destination and prints the response. The 1st step is to create a python file using the command vi l3tshoot.py following which the following code is entered. Line wise code explanation is provided below. Imports the logging module 2. Horus heresy book. ![]() Calls the appropriate function in the logging module. Imports scapy 4. Takes the IP address for which the status has to be checked and stores it in the variable dstip 5. Creates an ICMP header 6. Associates the ICMP type value as 8 7. Associates the ICMP code value as 0 8. Creates an IP header. Associates the destination IP address in the IP header with the value taken from the user. Sends the packet on the network with a timeout set. If statement for checking if the packet has been received. ![]() Prints the layer 3 status is upon receipt of packet 13. Else statement 14. Prints the layer 3 status is down. The code is executed from the Ubuntu command line using the following command sudo python l3tshoot.py This is a sample content from the book – Buy the ebook from Amazon.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |