2011-03-22 27 views
1

我已經構造的數據包,scapy對原材料ICMP分組的回覆:Scapy的:

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

我運行:

send(a) 

Wireshark的向我表明有來自ping請求和ping響應192.168.0.1 沒有警告,所有字段都是正確的

但是當我嘗試:

b=sr1(a) 

然後Scapy的無法得到答案(Wireshark的再次表明我有請求和應答)

我可以用它做什麼?

回答

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