0

I have made a look into the socket module of Python and wanted to try out some things. But unfortunately I'm not even able to receive some data (always socket.timeout is raised on recvfrom()). Here is the current state:

import socket

connection = socket.socket(proto = socket.IPPROTO_ICMP, type = socket.SOCK_RAW)
connection.settimeout(1)
connection.sendto(b'', ('8.8.8.8', 80))
connection.recvfrom(1)
connection.close()

All my tries to receive just a simple reply from this server failed. Maybe somebody can tell me how to do this.

1 Answers1

0

An ICMP packet is hardly an empty bytestring. Like many well thought out packet types, it contains a header and some control messages. Here's a couple resources you can use to create your own ICMP packet using the struct module, as well as some documentation (there is plenty more available on the internets) about how the packet is constructed.

VooDooNOFX
  • 4,674
  • 2
  • 23
  • 22