appknox / pyaxmlparser

Python3 Parser for Android XML file and get Application Name without using Androguard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ResParserError: res1 must be zero!

Retr0-XX opened this issue · comments

The parsing of the files stop when res1 is zero on some apks, which causes the analysis to completely stop.
A patch was implemented for androguard to make the analysis of the particular chunk stop, and log a warning instead:
https://github.com/androguard/androguard/pull/1008/files

I would suggest the replacement of the two assert statements at line in 129 pyaxmlparser/arscutil.py with the following:

res_error = False
if self.res0 != 0:
    log.warning("res0 is not zero!")
    res_error = True
if self.res1 != 0:
    log.warning("res1 is not zero!")
    res_error = True

if not res_error:  # Skips processing attempt if there was an error
    self.entryCount = unpack("<I", buff.read(4))[0]

    self.typespec_entries = []
    for i in range(0, self.entryCount):
        self.typespec_entries.append(unpack("<I", buff.read(4))[0])

And replace the assert statement at line 587 with the following:

if self.res0 != 0:
    log.warning("res0 is not zero!")
else:
    self.data_type = unpack('<B', buff.read(1))[0]
    self.data = unpack('<I', buff.read(4))[0]