ReFirmLabs / binwalk

Firmware Analysis Tool
MIT License
11.23k stars 1.56k forks source link

NotADirectoryError /binwak/magic when using python module installed with setup.py #680

Closed Timonheu closed 1 month ago

Timonheu commented 3 months ago

I am running binwalk in a docker containerand am using the python module. It is installed from the github in the Dockerfile:

RUN wget --progress=dot:giga https://github.com/ReFirmLabs/binwalk/archive/master.zip &&\
  unzip master.zip
WORKDIR ${homedir}/binwalk-master
RUN python setup.py install

However, when running

out = binwalk.scan(
                str(location),
                extract=True,
                directory=str(working_directory),
                matryoshka=True,
                depth=5,
            )

In my script, I get the following error:

  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/__init__.py", line 10, in scan
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/module.py", line 782, in execute
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/module.py", line 708, in list
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/settings.py", line 52, in __init__
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/settings.py", line 78, in _magic_signature_files
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/settings.py", line 71, in list_files
NotADirectoryError: [Errno 20] Not a directory: '/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/magic'

I am unsure if this is a bug in my installation or not.

Timonheu commented 3 months ago

Further information: My container is running Debian 12, and python 3.10.12.

Timonheu commented 3 months ago

Minimal working example that gives the same error:

import binwalk

binwalk.scan()

/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/modules/extractor.py:969: SyntaxWarning: "is" with a literal. Did you mean "=="?
/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/modules/extractor.py:984: SyntaxWarning: "is" with a literal. Did you mean "=="?
/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/modules/extractor.py:969: SyntaxWarning: "is" with a literal. Did you mean "=="?
/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/modules/extractor.py:984: SyntaxWarning: "is" with a literal. Did you mean "=="?
Traceback (most recent call last):
  File "/home/path/to/minimal_working_example.py", line 3, in <module>
    binwalk.scan()
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/__init__.py", line 10, in scan
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/module.py", line 782, in execute
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/module.py", line 708, in list
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/settings.py", line 52, in __init__
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/settings.py", line 78, in _magic_signature_files
  File "/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/core/settings.py", line 71, in list_files
NotADirectoryError: [Errno 20] Not a directory: '/usr/local/lib/python3.10/site-packages/binwalk-2.3.3-py3.10.egg/binwalk/magic'