erev0s / apkInspector

apkInspector is a tool designed to provide detailed insights into the zip structure of APK files, offering the capability to extract content and decode the AndroidManifest.xml file.
Apache License 2.0
45 stars 6 forks source link

AttributeError: 'NoneType' object has no attribute 'filename' when trying to processing an APK #34

Closed adnaneserrar closed 1 week ago

adnaneserrar commented 2 months ago

AttributeError: 'NoneType' object has no attribute 'filename' when trying to processing an APK

I'm encountering an AttributeError when trying to processe an APK with raw apk in bytes. The error message indicates that a NoneType object is being accessed, specifically when trying to get the filename attribute.

System Information

LOGS:

cls = <class 'apkInspector.headers.ZipEntry'> inc_apk = <_io.BytesIO object at 0x70f05ce873d0>, raw = True

@classmethod
def parse(cls, inc_apk, raw: bool = True):
    """
    Method to start processing an APK. The raw (bytes) APK may be passed or the path to it.

    :param inc_apk: the incoming apk, either path or bytes
    :type inc_apk: str or bytesIO
    :param raw: boolean flag to specify whether it is the raw apk in bytes or not
    :type raw: bool
    :return: returns the instance of the class
    :rtype: ZipEntry
    """
    if raw:
        apk_file = inc_apk
    else:
        with open(inc_apk, 'rb') as apk:
            apk_file = io.BytesIO(apk.read())
    eocd = EndOfCentralDirectoryRecord.parse(apk_file)
    central_directory = CentralDirectory.parse(apk_file, eocd)
    local_headers = {}
    for entry in central_directory.entries:
        local_header_entry = LocalHeaderRecord.parse(apk_file, central_directory.entries[entry])
      local_headers[local_header_entry.filename] = local_header_entry

E AttributeError: 'NoneType' object has no attribute 'filename'

../.venv/lib/python3.12/site-packages/apkInspector/headers.py:413: AttributeError

erev0s commented 2 months ago

@adnaneserrar could you please provide the apk to test it out?