Scapy:没有回复原始ICMP数据包

时间:2011-03-22 09:18:30

标签: python packet scapy

我构建了一个包含scapy的数据包:

a=IP(dst='192.168.0.1',proto=1)/'\x08\x00\xf7\xff\x00\x00\x00\x00'

我跑:

send(a)

Wireshark向我显示192.168.0.1中存在ping请求和ping响应 没有警告,所有字段都是正确的

但是当我尝试时:

b=sr1(a)

然后Scapy无法得到答案(Wireshark再次向我显示有请求和回复)

我该怎么办?

1 个答案:

答案 0 :(得分:3)

问题是scapy不知道如何识别响应,因为你老老实实地建立了一个ICMP数据包。如果您使用ICMP()构建它,它将起作用...

>>> from scapy.all import ICMP, IP, sr1
>>> aa = IP(dst='192.168.0.1')/ICMP()
>>> sr1(aa)
Begin emission:
Finished to send 1 packets.
*
Received 1 packets, got 1 answers, remaining 0 packets
<IP  version=4L ihl=5L tos=0x0 len=28 id=21747 flags= frag=0L ttl=60 proto=icmp 
chksum=0x1a77 src=192.168.0.1 dst=4.121.2.25 options=[] |<ICMP  type=echo-reply 
code=0 chksum=0x0 id=0x0 seq=0x0 |<Padding  
load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>>
>>>
相关问题