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

Look into "magic" library issues on other Unixes #1

Open
sroberts opened this issue Oct 5, 2012 · 1 comment
Open

Look into "magic" library issues on other Unixes #1

sroberts opened this issue Oct 5, 2012 · 1 comment
Assignees

Comments

@sroberts
Copy link
Owner

sroberts commented Oct 5, 2012

Trying out latest malwarehouse.py on a couple of systems. It appears
that the magic library used in malwarehouse is different than that of
other systems I have. The version on my FreeBSD and OS X don't
implement the magic.Magic class. OpenBSD does.

I notice MHL ran up against this in pescanner.py too. This is how he
handled it there:

-----

def get_filetype(data):
"""There are two versions of python-magic floating around, and
annoyingly, the interface
changed between versions, so we try one method and if it fails,
then we try the other.
NOTE: you may need to alter the magic_file for your system to
point to the magic file."""
if sys.modules.has_key('magic'):
try:
ms = magic.open(magic.MAGIC_NONE)
ms.load()
return ms.buffer(data)
except:
try:
return magic.from_buffer(data)
except magic.MagicException:
magic_custom =
magic.Magic(magic_file='C:\windows\system32\magic')
return magic_custom.from_buffer(data)
return ''

-----

@ghost ghost assigned sroberts Oct 5, 2012
@neriberto
Copy link

hi @sroberts take a look in what I did here https://github.com/neriberto/pyfile/blob/master/pyfile/__init__.py#L97 I hope that it help you,...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants