[英]Issues with scapy, sr1
我创建了以下代码,以便将数据包发送到地址 www.google.com,但我没有得到任何答案。
代码
from scapy.all import IP, ICMP, sr1
ip_layer = IP(src='192.168.224.131', dst='www.google.com')
#rint(ip_layer.show())
icmp_req = ICMP()
#print(icmp_req.show())
packet = ip_layer / icmp_req
#print(packet.show())
received_packet = sr1(packet, timeout=2)
if received_packet:
print(received_packet.show())
OUTPUT
Begin emission:
.Finished sending 1 packets.
Received 1 packets, got 0 answers, remaining 1 packets
此代码适用于我的机器(即,这可能是您的计算机/网络所独有的)。 这意味着任何数量的事情之一都可能是错误的:
src
中使用的 IP 地址是错误的(您可以使用 linux 上的ifconfig
和 windows 上的ipconfig
进行检查)。 这是我更改src
IP 地址后得到的响应:
bash-5.0$ python temp.py
Begin emission:
....Finished sending 1 packets.
.*
Received 6 packets, got 1 answers, remaining 0 packets
###[ IP ]###
version = 4
ihl = 5
tos = 0x0
len = 28
id = 0
flags =
frag = 0
ttl = 50
proto = icmp
chksum = 0xfe6
src = 172.217.9.132
dst = 192.168.1.246
\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'
None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.