Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'module' object has no attribute 'AF_PACKET' #205

Open
miguelmota opened this issue Sep 26, 2017 · 9 comments
Open

AttributeError: 'module' object has no attribute 'AF_PACKET' #205

miguelmota opened this issue Sep 26, 2017 · 9 comments

Comments

@miguelmota
Copy link

miguelmota commented Sep 26, 2017

trying to run example

>>> p = IP(dst = 'www.somesite.ex') / TCP(dport = 80) / Raw(b'Some raw bytes')
>>> sr(p)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/scapy/sendrecv.py", line 336, in sr
    s = conf.L3socket(filter=filter, iface=iface, nofilter=nofilter)
  File "/Library/Python/2.7/site-packages/scapy/supersocket.py", line 69, in __init__
    self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
AttributeError: 'module' object has no attribute 'AF_PACKET'
$ uname -a
Darwin computer.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
@alexmarder
Copy link

Has there been any progress on this? Since updating to version 0.22 I've been getting this problem on macos. This was not a problem with version 0.21.

@bmedicke
Copy link

Same issue here with Python 3. I've downgraded to 0.21 for now:
pip3 install -I scapy-python3==0.21

@nevsan
Copy link

nevsan commented Nov 21, 2017

+1. Same problem.

Downgrading to 0.21 works for me. I hear BPF should be a viable alternative for OS X.

@phaethon
Copy link
Owner

@miguelmota Your trace includes python/2.7 directory. Scapy3k (scapy-python3 package) works only with python3. Can you confirm that you are using python3?

@phaethon
Copy link
Owner

I will get to a OS X machine later this week to investigate.
If somebody could take 0.21 code and commit by commit forward to find out the commit to blame, it would speed up fixing.

@phaethon
Copy link
Owner

phaethon commented Nov 23, 2017

There is some issue with the new CAN layer implementation. Released 0.23 temporary disabling the layer before it is fixed, and this issue should not appear for now unless you enable can layer on OS X manually.

@nevsan
Copy link

nevsan commented Nov 24, 2017

0.23 works for me.

@getkub
Copy link

getkub commented Apr 15, 2018

The issue is reoccuring on: Scapy Version 2.4.0.dev58
MacOSX

@ghost
Copy link

ghost commented Mar 29, 2021

Sorry for necro-posting, but this SO answer(mentioned by this answer) suggests that BSD-flavour distros use BPF, although the functionality is different. AF_PACKET is only available on UN*X distros, and may not be installed by default either. If this issue is not relevant anymore, please close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants