aaronst / macholibre

Mach-O & Universal Binary Parser
Apache License 2.0
143 stars 32 forks source link

Possible error in parse dylib list? #23

Open zivkaspersky opened 5 years ago

zivkaspersky commented 5 years ago

Faield to parse macho, sha256: a42380933ae13b0ce023b38b576f5d2c48c1c82f19033781dfbf2f3e53e19711

Error:

Traceback (most recent call last):
 File "/app/static_analysis.py", line 112, in _parse_macho
 parsed_machos[sha] = parse_macho(file_path)
 File "/usr/local/lib/python3.7/site-packages/macholibre/__init__.py", line 45, in parse
 return parser.parse()
 File "/usr/local/lib/python3.7/site-packages/macholibre/parser.py", line 1680, in parse
 self.parse_file()
 File "/usr/local/lib/python3.7/site-packages/macholibre/parser.py", line 1671, in parse_file
 self.parse_macho(0, self.__output['size'])
 File "/usr/local/lib/python3.7/site-packages/macholibre/parser.py", line 1618, in parse_macho
 lc_dysymtab=lc_dysymtab, lc_dylibs=lc_dylibs)
 File "/usr/local/lib/python3.7/site-packages/macholibre/parser.py", line 1028, in parse_imports
 dylib = lc_dylibs[dylib - 1]['name']
IndexError: list index out of range

The value of the args are:

dylib = 14
lc_dylibs =  [{'cmd': 'LOAD_DYLIB', 'cmd_size': 56, 'name': '/usr/lib/libSystem.B.dylib', 'timestamp': '1970-01-01 02:00:02', 'current_version': '1252.50.4', 'compatability_version': '1.0.0'}]

UPDATE found another one, same error: sha256: 473a6a364e369ee9e9bbc4b38b2179d9984245cd83617c8b4021cbf6c3dbb32b

aaronst commented 5 years ago

I'm not sure what the issue is here. There's only one dylib included in the file, so trying to grab the 14th doesn't make sense. I'll have to research a little more to figure out what it's actually trying to do. For now, it will display the number and (OUT_OF_RANGE).