Sending and receiving

Scapy provides us with three functions for sending and receiving packets. The first two functions require that it's constructed for the network layer packets only such as IP, ICMP, and ARP packets. You may use sr() for sending and receiving packets whether they are answered or unanswered responses. The other alternative function is sr1() and this will only return one packet in response to the packet sent. For layer 2 packets, you would use srp() which provides the same function for sending/receiving packets.

Let's go ahead and create one for a single return. At minimum, we provide that it's a layer 3 packet for ICMP with the destination address going to 192.168.6 and we're going to name this packet p. You should have and see something similar to what we provided in the following screenshot:

Cool! so, after we sent one and got back a response, how can we see that response? Well that's why we provided a name for this; to view it, all you have to provide is either typing the name as is with p or for a cleaner format p.show. However, for sr() which will provide both answers and unanswered packets, use ans, unans=_ to look for the most recent responses or or returned data followed by the various ways to view packet details such as using ans.summary() for a basic report. A cool feature that this tool is capable of is illustrating a PostScript/PDF figure with each section explained in the dissection. Another one to remember is ans.command() which returns the command that duplicated the packet in scapy which can then be modified and/or sent out. There are plenty of other commands that will perform other functions or views such as decoding, hex, and listing field values.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.113.9