Do not try to run code requiring lief

pull/111/head
Raphaël Vinot 2017-08-25 17:41:58 +02:00
parent 9ff3739753
commit a5531990ae
1 changed files with 21 additions and 20 deletions

View File

@ -45,24 +45,25 @@ def make_macho_objects(lief_parsed, misp_file):
def make_binary_objects(filepath): def make_binary_objects(filepath):
misp_file = FileObject(filepath) misp_file = FileObject(filepath)
try: if HAS_LIEF:
lief_parsed = lief.parse(filepath) try:
if isinstance(lief_parsed, lief.PE.Binary): lief_parsed = lief.parse(filepath)
return make_pe_objects(lief_parsed, misp_file) if isinstance(lief_parsed, lief.PE.Binary):
elif isinstance(lief_parsed, lief.ELF.Binary): return make_pe_objects(lief_parsed, misp_file)
return make_elf_objects(lief_parsed, misp_file) elif isinstance(lief_parsed, lief.ELF.Binary):
elif isinstance(lief_parsed, lief.MachO.Binary): return make_elf_objects(lief_parsed, misp_file)
return make_macho_objects(lief_parsed, misp_file) elif isinstance(lief_parsed, lief.MachO.Binary):
except lief.bad_format as e: return make_macho_objects(lief_parsed, misp_file)
# print('\tBad format: ', e) except lief.bad_format as e:
pass # print('\tBad format: ', e)
except lief.bad_file as e: pass
# print('\tBad file: ', e) except lief.bad_file as e:
pass # print('\tBad file: ', e)
except lief.parser_error as e: pass
# print('\tParser error: ', e) except lief.parser_error as e:
pass # print('\tParser error: ', e)
except FileTypeNotImplemented as e: # noqa pass
# print(e) except FileTypeNotImplemented as e: # noqa
pass # print(e)
pass
return misp_file, None, None return misp_file, None, None