kamene icon indicating copy to clipboard operation
kamene copied to clipboard

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

Open miguelmota opened this issue 8 years ago • 9 comments

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

miguelmota avatar Sep 26 '17 22:09 miguelmota

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.

alexmarder avatar Nov 17 '17 03:11 alexmarder

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

bmedicke avatar Nov 17 '17 13:11 bmedicke

+1. Same problem.

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

nevsan avatar Nov 21 '17 22:11 nevsan

@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 avatar Nov 22 '17 12:11 phaethon

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 avatar Nov 22 '17 19:11 phaethon

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.

phaethon avatar Nov 23 '17 18:11 phaethon

0.23 works for me.

nevsan avatar Nov 24 '17 20:11 nevsan

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

getkub avatar Apr 15 '18 10:04 getkub

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.

Stardust8502 avatar Mar 29 '21 22:03 Stardust8502