Scapy:原始ICMP数据包无回复 [英] Scapy: no reply on raw ICMP packet

查看:906
本文介绍了Scapy:原始ICMP数据包无回复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用scapy构建了一个数据包:

I've constructed a packet with scapy:

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

我跑步:

send(a)

Wireshark告诉我,有一个ping请求和192.168.0.1发出的ping响应 没有警告,所有字段均正确

Wireshark shows me that there is a ping request and ping response from 192.168.0.1 No warnings, all fields are correct

但是当我尝试:

b=sr1(a)

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

Then Scapy can't get an answer (Wireshark shows me again that there is request and reply)

我该怎么办?

推荐答案

问题是scapy不知道如何识别响应,因为老实说,您很难构建ICMP数据包.如果您使用ICMP()进行构建,它将可以工作...

The problem is that scapy doesn't know how to recognize the response because you are honestly building an ICMP packet the hard way. If you build it with ICMP(), it will work...

>>> 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' |>>>
>>>

这篇关于Scapy:原始ICMP数据包无回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆