Skip to content

ResParserError: reserved must be zero! #5

@bparmentier

Description

@bparmentier

I encountered the following error when analyzing the WhatsApp 2.23.12.75 APK. I don't think I'm allowed to publicly share the APK file here so here is the direct link as can be found on https://www.whatsapp.com/android.

The error happens both with androguard 4.1.2 and the latest master branch (on commit f1d6a46)

$ androguard analyze WhatsApp.apk

[…]

In [3]: a.get_android_resources()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/venv/lib/python3.12/site-packages/androguard/core/apk/__init__.py:2210, in APK.get_android_resources(self)
   2209 try:
-> 2210     return self.arsc["resources.arsc"]
   2211 except KeyError:

KeyError: 'resources.arsc'

During handling of the above exception, another exception occurred:

ResParserError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 a.get_android_resources()

File ~/venv/lib/python3.12/site-packages/androguard/core/apk/__init__.py:2216, in APK.get_android_resources(self)
   2212 if "resources.arsc" not in self.zip.namelist():
   2213     # There is a rare case, that no resource file is supplied.
   2214     # Maybe it was added manually, thus we check here
   2215     return None
-> 2216 self.arsc["resources.arsc"] = ARSCParser(
   2217     self.zip.read("resources.arsc")
   2218 )
   2219 return self.arsc["resources.arsc"]

File ~/venv/lib/python3.12/site-packages/androguard/core/axml/__init__.py:1827, in ARSCParser.__init__(self, raw_buff)
   1823 start_of_chunk = self.buff.tell() - 8
   1824 expected_end_of_chunk = (
   1825     start_of_chunk + pkg_chunk_header.size
   1826 )
-> 1827 a_res_type = ARSCResType(self.buff, pc)
   1828 self.packages[package_name].append(a_res_type)
   1829 self.resource_configs[package_name][a_res_type].add(
   1830     a_res_type.config
   1831 )

File ~/venv/lib/python3.12/site-packages/androguard/core/axml/__init__.py:2964, in ARSCResType.__init__(self, buff, parent)
   2962 self.reserved = unpack('<H', buff.read(2))[0]
   2963 if self.reserved != 0:
-> 2964     raise ResParserError("reserved must be zero!")
   2965 self.entryCount = unpack('<I', buff.read(4))[0]
   2966 self.entriesStart = unpack('<I', buff.read(4))[0]

ResParserError: reserved must be zero!

It looks related to androguard/androguard#1014 but it's a bit low level for me so I'm not sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions