Androguard - huge APK analysis resulting in error `MemoryError`

551 Views Asked by At

I've been trying to use Androguard to analyze an APK file. My code is quite simple:

from androguard import misc
from androguard import session

APK_TO_ANALYZE_PATH = r"file.apk"

a, d, dx = misc.AnalyzeAPK(APK_TO_ANALYZE_PATH)
print(" [*] Success")

The APK file is quite huge, around 150MB compressed. However, my machine has 16GB of Ram, and a pagefile defined to maximum 14GB, so all in all I have 30GB of memory.

When trying to analyze this huge APK, after several minutes I receive an error:

Traceback (most recent call last):
  File "C:\Projects\ApkFiles\apk_analyzer.py", line 48, in <module>
    main()
  File "C:\Projects\ApkFiles\apk_analyzer.py", line 39, in main
    a, d, dx = misc.AnalyzeAPK(APK_TO_ANALYZE_PATH)
  File "C:\Python37-32\lib\site-packages\androguard\misc.py", line 69, in AnalyzeAPK
    for dex in a.get_all_dex():
  File "C:\Python37-32\lib\site-packages\androguard\core\bytecodes\apk.py", line 808, in get_all_dex
    yield self.get_file(dex_name)
  File "C:\Python37-32\lib\site-packages\androguard\core\bytecodes\apk.py", line 771, in get_file
    return self.zip.read(filename)
  File "C:\Python37-32\lib\zipfile.py", line 1432, in read
    return fp.read()
  File "C:\Python37-32\lib\zipfile.py", line 885, in read
    buf += self._read1(self.MAX_N)
  File "C:\Python37-32\lib\zipfile.py", line 975, in _read1
    data = self._decompressor.decompress(data, n)
MemoryError

What is the problem?

1

There are 1 best solutions below

0
On BEST ANSWER

Using python x64 resolves the issue.