Previously successful Scapy installation for Python 3, sniff() now failing with AttributeError - macos

On Mac OS 10.13.1
Using Scapy for the first time to do a simple packet-sniffing project.
Was working perfectly fine over the weekend after following the installation instructions here for Mac OS:
https://phaethon.github.io/scapy/api/installation.html
Hardware problems required me to move my work to a different machine, running the exact same OS.
I figured "no problem" - setup a new Python 3 venv and reinstalled dependencies on the second laptop (libdnet via brew, libpcap and scapy3k via pip).
Now a simple test using sniff() in Scapy produces the following error:
Traceback (most recent call last):
File "", line 1, in
File "/Users/ersheff/Virtualenvs/Scapy/lib/python3.6/site->packages/scapy/sendrecv.py", line 576, in sniff
s = L2socket(type=ETH_P_ALL, *arg, **karg)
File "/Users/ersheff/Virtualenvs/Scapy/lib/python3.6/site->packages/scapy/arch/linux.py", line 469, in init
self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, >socket.htons(type))
AttributeError: module 'socket' has no attribute 'AF_PACKET'
I'm well aware that the AF_PACKET attribute is not available on Mac OS and is specific to Linux, and as you might expect, all of my searching about this problem leads to that answer. However, as mentioned, this method was working for me before on a different machine with the same OS.
Admittedly, I'm a novice, but reading that error makes it look to me like Scapy is erroneously referring to the linux.py file in the arch directory when it should be referring to the bsd.py or unix.py files (both of which are present).
Any ideas?
Thanks in advance.

This question is old. For the record, the official scapy version now supports Python 3. OSX has been fixed on their sides:
https://github.com/secdev/scapy
Have a nice week,

Related

Pyinotify error when building linux with yocto on mac osx

I'm trying to build a linux with yocto (morty) on my Mac OSX (El Capitan). The source step with source poky/oe-init-build-env buildsucceeded without errors, but when I execute bitbake core-image-baseI get the following error trace:
Traceback (most recent call last):
File "/Users/peterblicharski/Entwicklung/dnsPro/yocto/yoctowa/poky/bitbake/bin/bitbake", line 48, in <module>
cookerdata.CookerConfiguration()))
File "/Users/peterblicharski/Entwicklung/dnsPro/yocto/yoctowa/poky/bitbake/lib/bb/main.py", line 468, in bitbake_main
server = start_server(servermodule, configParams, configuration, featureset)
File "/Users/peterblicharski/Entwicklung/dnsPro/yocto/yoctowa/poky/bitbake/lib/bb/main.py", line 354, in start_server
cooker = bb.cooker.BBCooker(configuration, features)
File "/Users/peterblicharski/Entwicklung/dnsPro/yocto/yoctowa/poky/bitbake/lib/bb/cooker.py", line 178, in __init__
self.configwatcher = pyinotify.WatchManager()
File "/Users/peterblicharski/Entwicklung/dnsPro/yocto/yoctowa/poky/bitbake/lib/pyinotify.py", line 1759, in __init__
raise InotifyBindingNotFoundError()
pyinotify.InotifyBindingNotFoundError: Couldn't find any inotify binding
DEBUG: Removed the following variables from the environment: __CF_USER_TEXT_ENCODING, XPC_SERVICE_NAME, SECURITYSESSIONID, PS1, TERM_PROGRAM_VERSION, TMPDIR, _, TERM_PROGRAM, DISPLAY, LANG, SHLVL, GIT_PS1_SHOWDIRTYSTATE, Apple_PubSub_Socket_Render, __PYVENV_LAUNCHER__, OLDPWD, XPC_FLAGS, TERM_SESSION_ID, BUILDDIR
Mac is not a supported build host and currently does not work at all. Quoting Ross Burton from mailing list:
If you install all of the GNU tools using brew or similar and put them first
on $PATH then you can get bitbake started. Then you need to stub out the
linux-specific bits in bitbake. I've previously started on this work
already
(http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=ross/darwin).
The next step is figuring out how to configure OE to build and link natively
on OSX using LLVM instead of GCC.
However all of this is mostly academic because in Sierra (iirc) onwards
there is tighter security on processes, which means that pseudo won't work
even if you port it to macOS.
Your error would be part of "linux-specific bits in bitbake" and seems to be worked around in ross' branch. But as you can see it's not the last issue you'll face.
Based on the discussion there are probably ways to get pseudo running but after that you would get to fix all the native builds Yocto does: it's likely that many projects we use are not frequently built on Mac and will fail there.

Error trying to run PyGame with Python 2.7.12 [duplicate]

This question already has answers here:
Installing pygame with homebrew
(2 answers)
pygame installation issue in mac os
(5 answers)
Closed 2 years ago.
I would like to use PyGame with the latest version of Python 2, on my Mac (running OS X 10.9.5). My understanding is that to do this, I need to install a 32-bit version of Python.
I went to Python.org, followed the Mac links and downloaded and installed the 32-bit version of Python 2.7.12. Everything worked fine.
Then, I went to http://pygame.org/download.shtml , and found pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg and installed that. The installation seemed to work fine.
To test it, I opened IDLE, and tried this:
import pygame
rather than importing cleanly, I get the following traceback:
Traceback (most recent call last):
File "<pyshell#0>", line 0, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/__init__.py", line 95, in <module>
from pygame.base import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/pygame/__init__.py", line 103, in <module>
Color = color.Color #error on this line
NameError: name 'color' is not defined
I have developed Python with PyGame programs for years with an earlier version of Python - but I needed to update to the latest version of Python. But now, I cannot run any of my PyGame-based code because of this error. (I've tried these steps multiple times, always resulting in the same error.)
Can anyone help me figure out how to get PyGame installed correctly so I can continue development?
Ideally, is there a series of steps that works correctly WITHOUT having to enter any commands at a command line? I need to be able to instruct new programmers how to get this environment set up, and they have zero experience doing anything at the command line.

Getting an "invalid syntax" error from __init__.py

I'm following this example for using Flask-JWT:
https://pythonhosted.org/Flask-JWT/
And I get this error when I start uwsgi:
Traceback (most recent call last):
File "./wsgi.py", line 1, in
from main import app as application
File "./main.py", line 5, in
from auth import api_auth
File "./auth.py", line 3, in
from flask_jwt import JWT
File "/opt/mist_base/env/lib/python2.6/site-packages/flask_jwt/__init__.py", line 83
for claim in verify_claims
^
SyntaxError: invalid syntax
I've been only using Python v2.6.6 (for Centos 6.x per customer specification) for only a week so I'm still very green at it. As a result, earlier today I discovered I had multiple variations of JWT-something in my virtualenv so I removed all instances and only reinstalled Flask-JWT. I had thought the issue was library conflicts (and it may have been earlier), but I'm still getting this error and other people have used it with no issues. Am I doing something wrong or is this library simply not designed to be used with Python v2.6.x?
[UPDATE] I've gone ahead and compiled v2.7.12 from source in CentOS 6 and so far it works nicely for my needs. I found these directions:
http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
and was able to install in an alternate directory.
This library just doesn't work on Python 2.6. The source code relies on features like dict comprehensions that only exist in 2.7 and up.

install cloudera impala shell on mac os x and connect to impala cluster

We have impala server on prod and I need connect to it with impala shell from my local macbook w/ mac os x (10.8).
I downloaded Impala-cdh5.1.0-release.tar.gz, unarchived it, tried buildall.sh which failed: .../bin/impala-config.sh: line 123: nproc: command not found
Trying impala-shell directly also fails:
$ shell/impala-shell
ls: /Users/.../Impala-cdh5.1.0-release/shell/ext-py/*.egg: No such file or directory
Traceback (most recent call last):
File "/Users/.../Impala-cdh5.1.0-release/shell/impala_shell.py", line 20, in <module>
import prettytable
ImportError: No module named prettytable
I have jdk installed and JAVA_HOME is set.
Cloudera manager seems doesn't support mac os, does it?
Based on your limited error message:
.../bin/impala-config.sh: line 123: nproc: command not found
I'd say that no, this package from cloudera doesnt support OSX. nproc is a linux command, and anything that references it isn't going to work on OSX.
If you could provide more information - such as where you downloaded it, or what it is, for those of us who aren't cloudera customers, we might be able to devise workarounds.
Or, contact cloudera support and complain about the lack of OSX support?
Your second error message looks like python, not java - and you provide no context around it....

cx_freeze builds Mac program that runs from command line but dies when clicked

I have a Python 2.7/PyQt4 program that I am attempting to freeze with cx_freeze. The program also uses requests, serial, xml.etree.ElementTree, and collections. Using the unmodified setup.py generated by cxfreeze-quickstart-2.7, I can successfully build as both a console program (python setup.py build) and an .app (python setup.py bdist_mac) in Yosemite using Python from macports. If I run the program directly either from the app bundle or the dist:
$ build/MacDISE-1.0.app/Contents/MacOS/macdise
$ dist/macdise
It runs exactly as expected. If I open from the command line:
$ open -a /Users/jeffemandel/macdise/build/MacDISE-1.0.app
I get the dreaded
LSOpenURLsWithRole() failed for the application /Users/jeffemandel/macdise/build/MacDISE-1.0.app with error -10810.
I worked through a number of potential issues raised by Dan McCombs (distutils.util.get_platform, sys.arg), but these don’t seem to be the problem. Through brute force trial and error, I found that if I put all of my code in a separate module, simply importing that module (without actually invoking it) causes the 10810 error, so I figured it was finding a library when run from the command line, but not from the app. I put the dist directory on a thumb drive and ran it on another Mac that doesn't have Python, Qt4, etc installed, and got this:
packages/cx_Freeze/initscripts/Console.py", line 27, in <module> File "macdise.py", line 4, in <module>
File "ExtensionLoader_PyQt4_QtGui.py", line 11, in <module>
ImportError: dlopen(/Volumes/NO NAME/dist/PyQt4.QtGui.so, 2): Library not loaded: /opt/local/Library/Frameworks/QtGui.framework/Versions/4/QtGui
Referenced from: /Volumes/NO NAME/dist/PyQt4.QtGui.so
Reason: image not found
When I look in dist, there is a file QtGui that is the same size as the one in /opt. So it seems the failure is dlopen(PyQt4.QtGui.so) returning a hard-coded path to the QtGui library. I'm guessing the solution is simple, but I haven't stumbled across it yet.
Update: I looked at the libraries in build/Contents/MacOS/PyQt4.*.so with otool, and these all have #executable_path (as opposed to hard-coded paths in dist). My stupid. So I repeated the process of moving the program, only using the MacOS folder rather than the dist folder, and executing macdise from the command line on my wife's MBP. The problem turned out to be in the way I was looking for the included_files. I changed this to:
if getattr(sys, 'frozen', False):
uiName = os.path.join(os.path.dirname(sys.executable), "tabDISE.ui" )
else:
uiName = "tabDISE.ui"
and it runs. What would have saved me a day would be a way to automagically dump the error message generated when executing from the command line to the console log. If someone knows how to do this, it would be a big help.

Resources