Sniffing

Scapy can also be used to easily capture packets:

>>> a = sniff(filter="icmp and host 172.217.3.164", count=5)
>>> a.show()
0000 Ether / IP / TCP 192.168.225.146:ssh > 192.168.225.1:50862 PA / Raw
0001 Ether / IP / ICMP 192.168.225.146 > 172.217.3.164 echo-request 0 / Raw
0002 Ether / IP / ICMP 172.217.3.164 > 192.168.225.146 echo-reply 0 / Raw
0003 Ether / IP / ICMP 192.168.225.146 > 172.217.3.164 echo-request 0 / Raw
0004 Ether / IP / ICMP 172.217.3.164 > 192.168.225.146 echo-reply 0 / Raw
>>>

We can look at the packets in some more detail, including the raw format:

>>> for i in a:
... print i.show()
...
<skip>
###[ Ethernet ]###
dst= <>
src= <>
type= 0x800
###[ IP ]###
version= 4L
ihl= 5L
tos= 0x0
len= 84
id= 15714
flags= DF
frag= 0L
ttl= 64
proto= icmp
chksum= 0xaa8e
src= 192.168.225.146
dst= 172.217.3.164
options
###[ ICMP ]###
type= echo-request
code= 0
chksum= 0xe1cf
id= 0xaa67
seq= 0x1
###[ Raw ]###
load= 'xd6xbfxb1Xx00x00x00x00x1axdcnx00x00x00x00x00x10x11x12x13x14x15x16x17x18x19x1ax1bx1cx1dx1ex1f !"#$%&'()*+,-./01234567'
None

Let's continue on and see how we can use Scapy for some of the common security testing.

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

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