Aug 5, 2010

Spoofing ICMP Echo Request with scapy

Scapy is a powerful packet generator. Here's a quick example how to spoof an ICMP Echo Request packet with Scapy.
# scapy
Welcome to Scapy (2.1.0)
>>> ip=IP()
>>> ip.src='192.168.0.255'
>>> ip.dst='192.168.0.1'
>>> ip.display
<bound method IP.display of <IP src=192.168.0.255 dst=192.168.0.1 |>>
>>> icmp=ICMP()
>>> icmp.type=8
>>> icmp.code=0
>>> icmp.display
<bound method ICMP.display of <ICMP  type=echo-request code=0 |>>
>>> send(ip/icmp)
.
Sent 1 packets.
>>>