python - Scapy installation fails on osx with dnet import error -
having problem installing scapy , it's required dependancies. have spent time googling solution 'solutions' seem impact older versions of python, or not work.
script:
#!/usr/bin/python import threading import queue import time scapy.all import * class workerthread(threading.thread) : def __init__(self, queue, tid) : threading.thread.__init__(self) self.queue = queue self.tid = tid print 'worker: %d' %self.tid def run(self) : total_ports = 0 while true : port = 0 seek : port = self.queue.get(timeout=1) except queue.empty : print 'worker %d exiting. %d ports scanned' %(self.tid, total_ports) homecoming #scanning begins ip = sys.argv[1] response = sr1(ip(dst=ip)/tcp(dport=port, flags='s'), verbose=false, timeout=.2) if response : if response[tcp].flags == 18 : print 'threadid: %d: got port no. %d status: open' %(self.tid, port) self.queue.task_done() total_ports += 1 queue = queue.queue() threads = [] in range(1, 10) : print 'creating workerthread : %d' %i worker = workerthread(queue, i) worker.setdaemon(true) worker.start() threads.append(worker) print 'workerthread %d created' %i j in range(1, 100) : queue.put(j) queue.join() item in threads : item.join() print 'scanning complete'
python version 2.7.5 , path python verified.
which python /usr/bin/python
when script executed getting next error:
./multi-threaded-scanner.py traceback (most recent phone call last): file "./multi-threaded-scanner.py", line 6, in <module> scapy.all import * file "/library/python/2.7/site-packages/scapy/all.py", line 16, in <module> arch import * file "/library/python/2.7/site-packages/scapy/arch/__init__.py", line 75, in <module> bsd import * file "/library/python/2.7/site-packages/scapy/arch/bsd.py", line 12, in <module> unix import * file "/library/python/2.7/site-packages/scapy/arch/unix.py", line 20, in <module> pcapdnet import * file "/library/python/2.7/site-packages/scapy/arch/pcapdnet.py", line 160, in <module> import dnet importerror: no module named dnet
i can utilize both scapy , python interactive interpreters , running import scapy
in python interpreter produces no errors. when script run pcapy
module missing, installed , issue switched dnet, cannot find solution for. a similar post, seems describe same issue workarounds have no effect. can shed more lite on issue?
commands used install pcapy , libdnet:
libdnet-1.11.tar.gz (01-19-2005)
` ~/downloads/libdnet-1.11 chmod a+x configure ~/downloads/libdnet-1.11 ./configure && make`
exits successfully
pcapy: latest stable release (0.10.8), updated august 26, 2010
~/downloads/pcapy-0.10.8 sudo python setup.py install password: running install running build running build_ext running build_scripts running install_lib running install_scripts changing mode of /usr/local/bin/96pings.pcap 777 changing mode of /usr/local/bin/pcapytests.py 777 running install_data running install_egg_info removing /library/python/2.7/site-packages/pcapy-0.10.8-py2.7.egg-info writing /library/python/2.7/site-packages/pcapy-0.10.8-py2.7.egg-info ~/downloads/pcapy-0.10.8
results compiling new flags
~/downloads/libdnet-1.12 sudo cflags='-arch i386 -arch x86_64' ./configure --prefix=/usr , archargs='-arch i386 -arch x86_64' create configure: warning: should utilize --build, --host, --target configure: warning: should utilize --build, --host, --target checking bsd-compatible install... /usr/bin/install -c checking whether build environment sane... yes /users/richardcurteis/downloads/libdnet-1.12/config/missing: unknown `--is-lightweight' alternative seek `/users/richardcurteis/downloads/libdnet-1.12/config/missing --help' more info configure: warning: 'missing' script old or missing checking thread-safe mkdir -p... config/install-sh -c -d checking gawk... no checking mawk... no checking nawk... no checking awk... awk checking whether create sets $(make)... yes checking whether create supports nested variables... yes checking whether enable maintainer-specific portions of makefiles... no checking build scheme type... invalid configuration `and': machine `and' not recognized configure: error: /bin/sh config/config.sub , failed ~/downloads/libdnet-1.12
edit - this reply below states mentioned issues fixed, , suggests much simpler installation method.
you have not completed installation of libdnet
, python wrapper, stated in scapy
's installation guide:
$ wget http://libdnet.googlecode.com/files/libdnet-1.12.tgz $ tar xfz libdnet-1.12.tgz $ ./configure $ create $ sudo create install $ cd python $ python2.5 setup.py install
if scheme 64 bit, utilize these compilation commands instead:
$ cflags='-arch i386 -arch x86_64' ./configure $ archargs='-arch i386 -arch x86_64' create
moreover, please verify you've installed right version, i.e. 1.12 rather 1.11.
if fails well, seek installing via macports
, utilize dnet.so
file, described here:
$ port selfupdate $ port upgrade outdated $ port install py27-libdnet $ port install libdnet $ cp /opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/dnet.so /library/python/2.7/site-packages
that link recommends changing code in /library/python/2.7/site-packages/scapy/arch/unix.py
(fix oserror: device not configured
).
change line 34 from:
f=os.popen("netstat -rn") # -f inet
to:
f=os.popen("netstat -rn | grep -v vboxnet") # -f inet
as follows:
def read_routes(): if scapy.arch.solaris: # f=os.popen("netstat -rvn") # -f inet f=os.popen("netstat -rn | grep -v vboxnet") # -f inet
if still error oserror: device not configured
, seek performing similar changes other branches of if
clause (specifically, else
branch), described in this answer.
python osx installation importerror scapy
No comments:
Post a Comment