aaronst / macholibre

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

ExpatError in parse_entitlement #14

Closed rammy22 closed 6 years ago

rammy22 commented 7 years ago
Could not parse file: /sample/c45f9b91abaa453a59898cebbb6f8bdd2e5942418dda4191b5e2f2ef11450148
ERROR:root:Traceback (most recent call last):
  File "/.virtualenvs/tmp-6c7055859c255549/lib/python2.7/site-packages/macholibre/__init__.py", line 67, in main
    parse(args.input[0], f=args.output)
  File "/.virtualenvs/tmp-6c7055859c255549/lib/python2.7/site-packages/macholibre/__init__.py", line 41, in parse
    p.parse_file()
  File "/.virtualenvs/tmp-6c7055859c255549/lib/python2.7/site-packages/macholibre/parser.py", line 814, in parse_file
    endi=identity[1], size=self.get_file_size()))
  File "/.virtualenvs/tmp-6c7055859c255549/lib/python2.7/site-packages/macholibre/parser.py", line 757, in parse_macho
    self.parse_sig(macho)
  File "/.virtualenvs/tmp-6c7055859c255549/lib/python2.7/site-packages/macholibre/parser.py", line 676, in parse_sig
    self.parse_entitlement(signature, offset)
  File "/.virtualenvs/tmp-6c7055859c255549/lib/python2.7/site-packages/macholibre/parser.py", line 448, in parse_entitlement
    plist = plistlib.readPlistFromString(self.f.read(size))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 103, in readPlistFromString
    return readPlist(StringIO(data))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 78, in readPlist
    rootObject = p.parse(pathOrFile)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 406, in parse
    parser.ParseFile(fileobj)
ExpatError: XML or text declaration not at start of entity: line 1, column 2
aaronst commented 6 years ago

This is now fixed. There is something wonky with the code signature in this mach-o. I added extra checks to handle them.