Question: As a packet spoofing tool, Scapy allows us to set the fields of IP packets to arbitrary values. The objective of this task is to

As a packet spoofing tool, Scapy allows us to set the fields of IP packets to arbitrary values. The objective
of this task is to spoof IP packets with an arbitrary source IP address. We will spoof ICMP echo request
packets, and send them to another VM on the same network. We will use Wireshark to observe whether our
request will be accepted by the receiver. If it is accepted, an echo reply packet will be sent to the spoofed IP
address. The following code shows an example of how to spoof an ICMP packets.
>>> from scapy.all import *
>>> a = IP()
>>> a.dst =10.0.2.3
>>> b = ICMP()
>>> p = a/b
>>> send(p)
.
Sent 1 packets.
In the code above, Line creates an IP object from the IP class; a class attribute is defined for each IP
header field. We can use ls(a) or ls(IP) to see all the attribute names/values. We can also use a.show()
and IP.show() to do the same. Line shows how to set the destination IP address field. If a field is not set,
a default value will be used.
>>> ls(a)
version : BitField (4 bits)=4(4)
ihl : BitField (4 bits)= None (None)
tos : XByteField =0(0)
len : ShortField = None (None)
id : ShortField =1(1)
flags : FlagsField (3 bits)=()
frag : BitField (13 bits)=0(0)
ttl : ByteField =64(64)
proto : ByteEnumField =0(0)
chksum : XShortField = None (None)
src : SourceIPField =127.0.0.1(None)
dst : DestIPField =127.0.0.1(None)
options : PacketListField =[]([])
Line creates an ICMP object. The default type is echo request. In Line , we stack a and b together
to form a new object. The / operator is overloaded by the IP class, so it no longer represents division;
instead, it means adding b as the payload field of a and modifying the fields of a accordingly. As a result,
we get a new object that represent an ICMP packet. We can now send out this packet using send() in
Line . Please make any necessary change to the sample code, and then demonstrate that you can spoof an
ICMP echo request packet with an arbitrary source IP address.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!