问题
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 Scapy can't get an answer (Wireshark shows me again that there is request and reply)
What can I do with it?
回答1:
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' |>>>
>>>
来源:https://stackoverflow.com/questions/5389000/scapy-no-reply-on-raw-icmp-packet