Obviously we can easily sniff a network with a socket like:
socket.socket(socket.PF_PACKET,socket.SOCK_RAW,socket.htons(0x0003)
socket.recv(65535)
I would like to identify the link layer
address type while importing only socket
and struct
, but link layer doesn't show up in the sockets, for obvious reasons. Do I need to write a shared library that addresses lower layer?
RFC 1122/1123 address link layer type and link layer address.
Update:
I know I can read it as a pcap and get the link layer information (i.e. dpkt
has a function called pcap.datalink()
which will return a link layer type, not the link layer address) but I am still uncertain how to go about reading it from a raw port (i.e. eth0), in python, for windows and/or linux.