Binwalk v1.0, Now With Python!

Binwalk 1.0 has just been released and has been completely re-written as a Python module. This means that not only does it feature smarter scanning and signature processing features that were much, much easier to implement in Python, but it is now fully scriptable.

Aside from a few new options (and the removal of a few depreciated ones), the command line usage is pretty much the same. My personal favorite options to pass to binwalk are ‘-re’, which besides being a reference to reverse engineering, will attempt to extract data from the target file and clean up after itself (very handy for when there are a lot of false positive LZMA files extracted!):

$ binwalk -re firmware.bin

Scripting with binwalk is pretty straight forward. To perform a simple scan (equivalent to running binwalk with no command line options):

import pprint
from binwalk import Binwalk

binwalk = Binwalk()

Check out the wiki for more command line usage and API examples.

Bookmark the permalink.

6 Responses to Binwalk v1.0, Now With Python!

  1. Matt says:

    Sorry, in the previous post I was using 0.5. I’ve not switched to 1.0. I compiled ‘file’ v5.12 and ‘python’ v2.7.3 from source. Also ‘pip install libmagic’, but get the following error:
    ~ # binwalk
    Traceback (most recent call last):
    File “/usr/local/bin/binwalk”, line 5, in
    import binwalk
    File “/usr/local/lib/python2.7/site-packages/binwalk/”, line 2, in
    import magic

    • Craig says:

      You need to install the python magic module that came with the ‘file’ source. There should be a directory in the ‘file’ source called python with a script in it.

  2. Steve says:

    You’re doing god’s work son, this is incredible.

  3. rob says:

    Hi, I have the following setup:

    Python 2.7
    Python Magic 5.17

    When I do an import magic, I get this error:

    >>> import magic
    Traceback (most recent call last):
    File “”, line 1, in
    File “”, line 19, in
    _libraries[‘magic’] = _init()
    File “”, line 16, in _init
    return ctypes.cdll.LoadLibrary(find_library(‘magic’))
    File “C:\python27\lib\ctypes\”, line 443, in LoadLibrary
    return self._dlltype(name)
    File “C:\python27\lib\ctypes\”, line 365, in __init__
    self._handle = _dlopen(self._name, mode)
    TypeError: expected string or Unicode object, NoneType found

    Any help would be appreciate thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *