Search code examples
pythonwindowssocketspacket-capturepacket-sniffers

Python socket sniffer - Only detects the sent packets


I've wrote a socket sniffer in windows. everything works fine, but the sniffer only detects the sent packets. This is the begining of the sniffer:

    import socket

    conn = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)

    conn.bind(("10.92.5.59", 0))

    # Include IP headers
    conn.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)

    # receive all packages
    conn.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)

What do I do wrong?


Solution

  • The answer is really simple. After some research I found out that the reason for this is the firewall.

    So I had to do some configuration in order to get this worked. Go to this link: http://www.thewindowsclub.com/block-open-port-windows-8-firewall

    and follow the instructions.