1

I am trying to run Scapy on my Macbook pro with OS Yosemite.

I installed it with the following command

brew install scapy

Everything looks ok but when I run

scapy

I get this errors

Traceback (most recent call last):
File "/usr/local/bin/scapy", line 25, in <module>
interact()
File "/Library/Python/2.7/site-packages/scapy/main.py", line 278, in
interact
scapy_builtins = __import__("all",globals(),locals(),".").__dict__
File "/Library/Python/2.7/site-packages/scapy/all.py", line 25, in   <module>
from route import *
File "/Library/Python/2.7/site-packages/scapy/route.py", line 162, in <module>
conf.route=Route()
File "/Library/Python/2.7/site-packages/scapy/route.py", line 22, in __init__
self.resync()
File "/Library/Python/2.7/site-packages/scapy/route.py", line 31, in resync
self.routes = read_routes()
File "/Library/Python/2.7/site-packages/scapy/arch/unix.py", line 86, in read_routes
ifaddr = scapy.arch.get_if_addr(netif)
File "/Library/Python/2.7/site-packages/scapy/arch/__init__.py", line 36, in get_if_addr
return socket.inet_ntoa(get_if_raw_addr(iff))
File "/Library/Python/2.7/site-packages/scapy/arch/pcapdnet.py", line 201, in get_if_raw_addr
return i.get(ifname)["addr"].data
File "dnet.pyx", line 990, in dnet.intf.get
OSError: Device not configured`

How can I fix it?

EDIT: if I run

sudo scapy 

I get this:

Traceback (most recent call last):
File "/usr/local/bin/scapy", line 25, in <module>
interact()
File "/Library/Python/2.7/site-packages/scapy/main.py", line 278, in interact
scapy_builtins = __import__("all",globals(),locals(),".").__dict__
File "/Library/Python/2.7/site-packages/scapy/all.py", line 25, in <module>
from route import *
File "/Library/Python/2.7/site-packages/scapy/route.py", line 162, in <module>
conf.route=Route()
File "/Library/Python/2.7/site-packages/scapy/route.py", line 22, in __init__
self.resync()
File "/Library/Python/2.7/site-packages/scapy/route.py", line 31, in resync
self.routes = read_routes()
File "/Library/Python/2.7/site-packages/scapy/arch/unix.py", line 86, in read_routes
ifaddr = scapy.arch.get_if_addr(netif)
File "/Library/Python/2.7/site-packages/scapy/arch/__init__.py", line 36, in get_if_addr
return socket.inet_ntoa(get_if_raw_addr(iff))
File "/Library/Python/2.7/site-packages/scapy/arch/pcapdnet.py", line 201, in get_if_raw_addr
return i.get(ifname)["addr"].data
KeyError: 'addr'
rebrid
  • 430
  • 8
  • 27

2 Answers2

0

I had the exact same issue with the 'addr' key error and worked it out (your first error will be permissions - so yes, you will need to sudo).

By editing the underlying Python code to get some debug info, I could see the interface being checked had no IP address set on it BUT the OS had an (old/manual) static route which made use of this unconfigured interface.

When dnet was loading/importing it was iterating through the routes and then checking the interfaces to get the IP (which it couldn't as I was no longer using it and therefore it had no IP).

Removed the static route and it worked fine.

J Harms
  • 1
  • 1
0

Your problem is a known bug. Until they fix the problem you could try this:

In the file scapy/arch/unix.py add the elif scapy.arch.DARWIN: part:

def read_routes():
    if scapy.arch.SOLARIS:
        f=os.popen("netstat -rvn") # -f inet
    elif scapy.arch.FREEBSD:
        f=os.popen("netstat -rnW") # -W to handle long interface names
    elif scapy.arch.DARWIN:
        f = os.popen("netstat -rn | grep -v vboxnet")  # Fix OSX problem            
    else:
        f=os.popen("netstat -rn") # -f inet
    ok = 0
    mtu_present = False

If you have troubles to find the scapy location you can run

python -v
>>> import scapy
import scapy # directory /Library/Python/2.7/site-packages/scapy

Reference

Martin Forte
  • 774
  • 13
  • 17