开发者

Scapy: no reply on raw ICMP packet

I've constructed a packet with scapy:

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

I run:

send(a)

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

But when I try:

b=sr1(a)

Then Scap开发者_如何学运维y can't get an answer (Wireshark shows me again that there is request and reply)

What can I do with it?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜