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
adst
b ICMP
p ab
sendp
Sent 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 lsa or lsIP to see all the attribute namesvalues We can also use ashow
and IPshow 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.
lsa
version : BitField bits
ihl : BitField bits None None
tos : XByteField
len : ShortField None None
id : ShortField
flags : FlagsField bits
frag : BitField bits
ttl : ByteField
proto : ByteEnumField
chksum : XShortField None None
src : SourceIPField None
dst : DestIPField 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
