Skip to content

Pypacker incompatible with windows (AttributeError: sockets.AF_PACKET) #52

Open
@SudoFlame

Description

@SudoFlame

Hi,

Unrelated note: First of all, I am sorry that I didn't put this issue in gitlab. However, Gitlab currently seems to have quite strong restrictions with allowed domain names for email. Apparently my email provider(s) aren't on this whitelist, lol.

When I create a psocket with Pypacker the following exception is thrown:

AttributeError: module 'socket' has no attribute 'AF_PACKET'
Apparently, there is no such thing as socket.AF_PACKET for windows and the pypacker.psocket seems to rely on this.

Pypacker works fine with Linux, however for my use case I am restricted to Windows. In the FAQ it is stated that it should run on Windows as well. Therefore I think this should be an issue.

I am trying to write an UDP Sniffer / UDP Forwarding Script with Pypacker. Is there a workaround for the usage of pypacker.psocket or socket.AF_PACKET?

This would be a stripped down example of what I am currently doing:

from pypacker import psocket
from pypacker.layer12 import ethernet
from pypacker.layer3 import ip
from pypacker.layer4 import udp

def sniff(interface_name, port):
    psock = psocket.SocketHndl(iface_name=interface_name)
    for raw_bytes in psock:
        pypkt = ethernet.Ethernet(raw_bytes)
        if pypkt[ethernet.Ethernet, ip.IP, udp.UDP] is not None:
            if pypkt[udp.UDP].sport == port:
                print("packet: %r" % pypkt)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions