Answer the question
In order to leave comments, you need to log in
icmp response not coming?
I have a python code that accepts icmp pings and sends back a response. Pings come and the answer is not.
import socket
r = socket
s = socket.socket(r.AF_INET, r.SOCK_RAW, r.IPPROTO_ICMP)
#s.setsockopt(socket.SOL_IP, socket.IP_HDRINCL,0)
while True:
data,addr = s.recvfrom(4096)
d = data.split(b"\x08\x00")[1]
chk = bytes([d[0]]),bytes([d[1]])
id = bytes([d[2]]),bytes([d[3]])
seq = bytes([d[4]]),bytes([d[5]])
payload = b''
for x in d:
if x == d[0]:
continue
elif x == d[1]:
continue
elif x == d[2]:
continue
elif x == d[3]:
continue
elif x == d[4]:
continue
elif x == d[5]:
continue
else:
payload += bytes([x])
print("Checksum: ",chk)
print("Id: ",id)
print("Seq num: ",seq)
print("Payload: ",payload.decode("utf-8"))
rsp = b"\x00\x00\x00\x00"+id[0]+id[1]+seq[0]+seq[1]+payload
print(rsp)
s.sendto(rsp,addr)
Answer the question
In order to leave comments, you need to log in
the kernel does not let the packet through.
iptables -A OUTPUT -p icmp -m icmp --icmp-type 8 -j DROP
iptables -F
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question