Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Raw Sockets (Windows): Sniffing Ethernet Frames
    primarykey
    data
    text
    <p>I have seen several examples of creating sockets to sniffing for IP Packets, for example using: </p> <pre><code>s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP) </code></pre> <p>What I am trying to achieve, is <strong>sniffing for Ethernet Frames</strong> and analysing the data received in Windows. The packets I am interested in are <strong>PPPoE Frames not containing IP</strong>. </p> <p>In <strong>Linux</strong> (using python) I was able to achieve this using : </p> <pre><code>s = socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.htons(3)) s.setsockopt(socket.SOL_SOCKET, IN.SO_BINDTODEVICE, struct.pack("%ds"%(len("eth0")+1,),"eth0")) while condition: pkt = s.recvfrom(1500) addToQueue(filter(pkt)) </code></pre> <p>Now due to the differences betweeen linux sockets and WinSock2 API, I am having the following compatibility issues : </p> <ul> <li>There is no IN package for windows. That means the <strong>SO_BINDTODEVICE</strong> is not present. How do <strong>I sniff everything coming on eth0 interface?</strong></li> <li>What should I use for protocol option in socket() constructor as I dont want to limit it to IPPROTO_IP. </li> </ul> <p>Can anyone point me to the right direction ? I went through similar questions but none of them really solved my problem as they were all concerned with IP Packet sniffing</p> <p><em>Note: I know libraries like Scapy could be used for sniffing, but it loses packets if we are trying to do any elaborate filtering (or use the prn function) and does not suit what I am trying to do. Raw sockets fit my need perfectly.</em></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload