It requires python-magic, which is not working on Windows without an auxiliary package named python-magic-bin, embedding some native code in a DLL. This package seems to be un-maintained from years, but, well, anyway, it still works with recent Python version 🤷♂️
A quick fix could be to ""cast"" the Path object to a string when calling magic.from_file.
Maybe another option could be to replace the usage of python-magic by LIEF and the various utilities functions lief.is_elf(), lief.is_pe(), lief.is_macho() ?
Hola o/
tl;dr;
python-binexport
does not work on Windows.It requires
python-magic
, which is not working on Windows without an auxiliary package namedpython-magic-bin
, embedding some native code in a DLL. This package seems to be un-maintained from years, but, well, anyway, it still works with recent Python version 🤷♂️But when adding this auxiliary package, there is another bug, in the way magic is used (see https://github.com/quarkslab/python-binexport/blob/main/bin/binexporter#L42) :
The argument passed to
magic.from_file
is a Path object, not a string. On Linux, when calling the native code from https://github.com/ahupp/python-magic/blob/master/magic/__init__.py#L321-L322, thecoerce_function
will return a string from the Path object, But on Windows, the original Path object will be returned ... so the call to the native code will receive an object instead of the expected string (see https://github.com/ahupp/python-magic/blob/master/magic/__init__.py#L317) , which results in anctypes.ArgumentError: argument 2: TypeError: wrong type
A quick fix could be to ""cast"" the Path object to a string when calling
magic.from_file
.Maybe another option could be to replace the usage of
python-magic
by LIEF and the various utilities functionslief.is_elf(), lief.is_pe(), lief.is_macho()
?