Scapy ping ICMP
- In one window we run tcpdump listening to traffic from localhost to localhost
sudo tcpdump -nn src 127.0.0.1 and dst 127.0.0.1 -i lo
In another terminal we send a single ping:
ping -c 1 localhost
This is what tcpdump captured:
10:42:23.016599 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 11, seq 1, length 64 10:42:23.016608 IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 11, seq 1, length 64
Then we run our scapy script:
import scapy.all as scapy scapy.send(scapy.IP()/scapy.ICMP(id=1, seq=1))
sudo /opt/venv3/bin/python ping.py
- We must run it as user root but we need to use he python 3 that has scapy installed which is probably in some virtualenv.
10:43:48.081774 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 0, seq 0, length 8
- TODO why is there no response?