I created the fllowing code in order to send a packet to the address www.google.com, but I'm not getting any answer.
CODE
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
This code works on my machine (ie this is likely unique to your computer/network). This means one of any number of things could be wrong:
src
is wrong (you can check this with ifconfig
on linux and ipconfig
on windows). This is the response I got after changing the src
IP address:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.