IP spoofing
With Scapy, we can simply craft packets and send them. So, if we spoof the source address and send it, the network accepts and returns the response to the spoofed address. Now, we can create a script to ping a system with a spoofed IP.
How to do it...
Here are the steps to create a script for sending ping requests with spoofed IP:
- Create an
ip-spoof-ping.py
file and open it in your editor.
- Then, we have to import the required modules:
from scapy.all import *
- Now declare the variables for the script:
iface = "en0"fake_ip = '192.168.1.3'destination_ip = '192.168.1.5'
- Create a function to send ICMP packets:
def ping(source, destination, iface):pkt = IP(src=source,dst=destination)/ICMP()srloop(IP(src=source,dst=destination)/ICMP(), iface=iface)
This will create the following packet and start a send/receive loop:

- Start sending the spoofed packets:
try:print ("Starting Ping")ping(fake_ip,destination_ip,iface)except KeyboardInterrupt:print("Exiting.. ")sys.exit(0)
- Now, run the script with required...