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

TypeError: a bytes-like object is required, not 'NoneType' #206

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

TypeError: a bytes-like object is required, not 'NoneType' #206

miguelmota opened this issue Sep 26, 2017 · 4 comments

Comments

@miguelmota
Copy link

miguelmota commented Sep 26, 2017

trying to run example

from scapy.all import *
p = IP(dst = 'www.somesite.ex') / TCP(dport = 80) / Raw(b'Some raw bytes')
sr1(p)
$ python example.py
Traceback (most recent call last):
  File "example.py", line 1, in <module>
    from scapy.all import *
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scapy/all.py", line 25, in <module>
    from .route import *
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scapy/route.py", line 163, in <module>
    conf.route=Route()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scapy/route.py", line 22, in __init__
    self.resync()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scapy/route.py", line 31, in resync
    self.routes = read_routes()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scapy/arch/unix.py", line 82, in read_routes
    ifaddr = scapy.arch.get_if_addr(netif)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scapy/arch/__init__.py", line 52, in get_if_addr
    return socket.inet_ntoa(get_if_raw_addr(iff))
TypeError: a bytes-like object is required, not 'NoneType'
$ 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
@dspruell
Copy link

dspruell commented Oct 9, 2017

May be experiencing same issue.

Darwin laptop.local 14.5.0 Darwin Kernel Version 14.5.0: Sun Jun  4 21:40:08 PDT 2017; root:xnu-2782.70.3~1/RELEASE_X86_64 x86_64

Python 3.6.3
scapy-python3    0.21

Exception:

[...]
  File "/Users/DarrenSpruell/venv.d/project/lib/python3.6/site-packages/pkg_resources/__init__.py", line[10/175]
n resolve                                                                                                              
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Users/DarrenSpruell/devel/external/project/my_project/__init__.py", line 15, in <module>
    from . import api                                                                                                  
  File "/Users/DarrenSpruell/devel/external/project/my_project/api.py", line 11, in <module>
    from . import app, packetgen                           
  File "/Users/DarrenSpruell/devel/external/project/my_project/packetgen.py", line 7, in <module>               from scapy.all import IP, TCP, UDP, send, conf
  File "/Users/DarrenSpruell/venv.d/project/lib/python3.6/site-packages/scapy/all.py", line 25, in <module>     
    from .route import *     
  File "/Users/DarrenSpruell/venv.d/project/lib/python3.6/site-packages/scapy/route.py", line 163, in <module>
    conf.route=Route()
  File "/Users/DarrenSpruell/venv.d/project/lib/python3.6/site-packages/scapy/route.py", line 22, in __init__
    self.resync()
  File "/Users/DarrenSpruell/venv.d/project/lib/python3.6/site-packages/scapy/route.py", line 31, in resync
    self.routes = read_routes()
  File "/Users/DarrenSpruell/venv.d/project/lib/python3.6/site-packages/scapy/arch/unix.py", line 82, in read_ro
utes
    ifaddr = scapy.arch.get_if_addr(netif)
  File "/Users/DarrenSpruell/venv.d/project/lib/python3.6/site-packages/scapy/arch/__init__.py", line 52, in get
_if_addr
    return socket.inet_ntoa(get_if_raw_addr(iff))
TypeError: a bytes-like object is required, not 'NoneType'

@dspruell
Copy link

dspruell commented Oct 9, 2017

Actually, just noticed like mentioned in #22 that my outcome is different when the netifaces module is not installed. The above exception occurred when netifaces was installed in the virtualenv. When netifaces is removed from the virtualenv (and removed from setuptools dependencies of my package) the application initializes without issue. There is however the initial warning when the module is missing, which was the original reason I had netifaces installed and listed as a requirement:

WARNING: Could not load module netifaces: No module named 'netifaces'

dspruell pushed a commit to nids-io/ampt-generator that referenced this issue Oct 9, 2017
…es scapy3k encounters exceptions.

  File "/Users/DarrenSpruell/devel/external/ampt-generator/ampt_generator/__init__.py", line 15, in <module>
    from . import api
  File "/Users/DarrenSpruell/devel/external/ampt-generator/ampt_generator/api.py", line 11, in <module>
    from . import app, packetgen
  File "/Users/DarrenSpruell/devel/external/ampt-generator/ampt_generator/packetgen.py", line 7, in <module>               from scapy.all import IP, TCP, UDP, send, conf
  File "/Users/DarrenSpruell/venv.d/ampt-generator/lib/python3.6/site-packages/scapy/all.py", line 25, in <module>
    from .route import *                                                                                                 File "/Users/DarrenSpruell/venv.d/ampt-generator/lib/python3.6/site-packages/scapy/route.py", line 163, in <module>
    conf.route=Route()
  File "/Users/DarrenSpruell/venv.d/ampt-generator/lib/python3.6/site-packages/scapy/route.py", line 22, in __init__       self.resync()
  File "/Users/DarrenSpruell/venv.d/ampt-generator/lib/python3.6/site-packages/scapy/route.py", line 31, in resync
    self.routes = read_routes()
  File "/Users/DarrenSpruell/venv.d/ampt-generator/lib/python3.6/site-packages/scapy/arch/unix.py", line 82, in read_ro
utes
    ifaddr = scapy.arch.get_if_addr(netif)
  File "/Users/DarrenSpruell/venv.d/ampt-generator/lib/python3.6/site-packages/scapy/arch/__init__.py", line 52, in get
_if_addr
    return socket.inet_ntoa(get_if_raw_addr(iff))
TypeError: a bytes-like object is required, not 'NoneType'

Reference phaethon/kamene#206 for information on documented failure case.
@johnsaigle
Copy link

johnsaigle commented Mar 15, 2018

I am experiencing this issue also. There is a WARNING when netifaces is not installed, but when it is installed, I get the NoneType error

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

@hslatman
Copy link

I'm experiencing the same issue on Mac OS X 17.7.0 with netifaces available in the virtualenv. The loop through interfaces in arch/unix.py works, but the vboxnet interface triggers the error. In my netstat -rn output the interface is called vboxnet, in netifaces.interfaces(), they are called vboxnetX (with a number), so there's a slight mismatch. Setting conf.use_netifaces = False does not seem to fix that.

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

4 participants