I would like to only capture ICMPv6 Echo Request packets. I use the scapy sniff()-function that is using BPF-filters, same as tcpdump. The filter I use works with tcpdump and only captures ICMPv6 echo requests but when I use it in my python script it does not work at all and scapy captures all packets. Why is the filter not working in my script?
#!/usr/bin/env python
from scapy.all import *
a = sniff(filter="icmp6 && ip6[40] == 128", count=10)
a.summary()
The output:
Ether / IP / ICMP 192.168.1.74 > 192.168.1.84 echo-request 0 / Raw
Ether / IP / ICMP 192.168.1.84 > 192.168.1.74 echo-reply 0 / Raw
Ether / IPv6 / ICMPv6 Echo Request (id: 0x306 seq: 0x3bb)
Ether / IPv6 / ICMPv6 Echo Request (id: 0x306 seq: 0x3bb)
Ether / IPv6 / ICMPv6 Echo Reply (id: 0x306 seq: 0x3bb)
Ether / IPv6 / ICMPv6 Echo Reply (id: 0x306 seq: 0x3bb)
Ether / IP / TCP 192.168.1.84:ssh > 192.168.1.74:61336 PA / Raw
Ether / IP / TCP 192.168.1.74:61336 > 192.168.1.84:ssh A
Ether / IP / ICMP 192.168.1.74 > 192.168.1.84 echo-request 0 / Raw
Ether / IP / ICMP 192.168.1.84 > 192.168.1.74 echo-reply 0 / Raw