gee*_*oph 5 python sniffing scapy
我正在嗅探数据包,需要知道哪些数据包是 ICMPv6 Echo Request 数据包,哪些是 UDP 数据包。
我知道我能做到
P = sniff(filter='ip6 and host fe80::xx:xx:xx:xx',count=0)
IP in P #will return false (my packets are IPv6)
UDP in P #will return true (when the specific packet is indeed UDP)
Run Code Online (Sandbox Code Playgroud)
但我不知道如何检查 ICMPv6 数据包,更具体地说是 ICMPv6 Echo Request数据包......似乎我什至无法检查任何 IP 版本 6:
IPv6、IP6、ipv6、ip6、icmpv6、ICMPv6、icmp6、ICMP6 都返回一个
NameError: name 'x' is not defined
Run Code Online (Sandbox Code Playgroud)
有谁知道做这样的事情的方法?
如果您使用的是 Scapy v1.x,它不会处理 IPv6,正如它在文档中的不同地方所说的那样。例如,在下载和安装中:
Scapy v2.x。当前的开发版本增加了几个特性(例如 IPv6)。
如果您使用的是 2.x,它应该可以与IPv6. 例如,在我的电脑上(Scapy 2.1.0,Apple 预装 Python 2.7.2,OS X 10.8.5):
>>> P = sniff(filter='ip6', count=0)
… make sure to capture an IPv6 UDP packet …
>>> UDP in P
False
>>> IPv6 in P
False
>>> UDP in P[0]
True
>>> IPv6 in P[0]
True
>>> P[0][IPv6]
<IPv6 version=6L tc=0L fl=0L plen=98 nh=UDP …
>>> ICMPv6EchoRequest in P[0]
False
>>> ICMPv6EchoRequest
<class 'scapy.layers.inet6.ICMPv6EchoRequest'>
Run Code Online (Sandbox Code Playgroud)