Question: I use the below scapy code to sniff and then spoof on the IP addresses 1.2.3.4 and 8.8.8.8 and it works perfectly fine. However, when

I use the below scapy code to sniff and then spoof on the IP addresses 1.2.3.4 and 8.8.8.8 and it works perfectly fine. However, when I ping the IP address 10.9.0.99, I get the Destionation Host Unreachable. What is the reason for that? Please give your answer clear and legible format. The Machine that I ping the addresses has the IP address 10.9.0.6. Thank you!

# code starts here

#!/usr/bin/env python3

from scapy.all import *

def spoof(pkt):

if ICMP in pkt and pkt[ICMP].type == 8:

print("Original Packet.........")

print("Source IP : ", pkt[IP].src)

print("Destination IP :", pkt[IP].dst)

ip = IP(src=pkt[IP].dst, dst=pkt[IP].src, ihl=pkt[IP].ihl)

icmp = ICMP(type=0, id=pkt[ICMP].id, seq=pkt[ICMP].seq)

data = pkt[Raw].load

newpkt = ip/icmp/data

print("Spoofed Packet.........")

print("Source IP : ", newpkt[IP].src)

print("Destination IP :", newpkt[IP].dst)

send(newpkt, verbose=0)

sniff(filter=icmp and src host 10.9.0.6, prn=spoof_pkt)

# code ends here

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!