Skip to content

Commit

Permalink
Fix AXML parsing error with manipulated
Browse files Browse the repository at this point in the history
It may fix some issue with packed or obfuscated AndroidManifest.xml
example, https://www.virustotal.com/gui/file/64275082cdec19c4e9d74efb9dfcaba133d1d2312e3670ad976750c9a77752cb
  • Loading branch information
ryu-s-r committed Dec 15, 2022
1 parent 832104d commit 03b841b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion androguard/core/axml/__init__.py
Expand Up @@ -154,6 +154,10 @@ def __init__(self, buff, header):
if (size % 4) != 0:
logger.warning("Size of strings is not aligned by four bytes.")

if self.stringCount * 4 + header.header_size != self.stringsOffset :
logger.warning("Offset of strings is not expected. Try fixing it")
buff.seek(8 + self.stringsOffset)

self.m_charbuff = buff.read(size)

if self.stylesOffset != 0 and self.styleCount != 0:
Expand Down Expand Up @@ -442,7 +446,8 @@ def __init__(self, raw_buff):
logger.error("This does not look like an AXML file. String chunk header size does not equal 28! header size = {}".format(header.header_size))
self._valid = False
return


self.buff.seek(axml_header.header_size + header.size)
self.sb = StringBlock(self.buff, header)

# Stores resource ID mappings, if any
Expand Down

0 comments on commit 03b841b

Please sign in to comment.