androguard / androguard

Reverse engineering and pentesting for Android applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AndroGuard throws error/crashes while decompiling APK

PiyushThePal opened this issue · comments

image

FYI:- I'm using python3 on my MacBook M2 chip with all the required packages like pydot, graphviz.

Same issue.
Python 3.11 on my Intel MacBook Pro.

AndroGuard androguard decompile -i ../App.apk -o app-cfg -f raw
Dump information ../App.apk in app-cfg
Create directory app-cfg
Decompilation ... End
Dump Landroid/view/View; setPadding (I I I I)V ... Traceback (most recent call last):
  File "/usr/local/bin/androguard", line 8, in <module>
    sys.exit(entry_point())
             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/androguard/cli/cli.py", line 301, in decompile
    export_apps_to_format(fname, s, output, limit,
  File "/usr/local/lib/python3.11/site-packages/androguard/cli/main.py", line 163, in export_apps_to_format
    filename = clean_file_name(os.path.join(filename_class, method.get_short_string()))
                                                            ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MethodIdItem' object has no attribute 'get_short_string'

Same here in win11, python v3.12

this is related to #1010 and more specifically to this
and unfortunately there was no test case covering it so it could be flagged.

the get_methods(self) was returning an EncodedMethod but it is now returning MethodIdItem and it does not have the get_short_string
@ehrenb maybe you want to take a look?
Otherwise I will check it as soon as i can

this is related to #1010 and more specifically to this and unfortunately there was no test case covering it so it could be flagged.

the get_methods(self) was returning an EncodedMethod but it is now returning MethodIdItem and it does not have the get_short_string @ehrenb maybe you want to take a look? Otherwise I will check it as soon as i can

I was able to reproduce this. I'll take a look.

I have a fix here (https://github.com/ehrenb/androguard/tree/get-short-string). Using the new get_encoded_methods() instead fixed it. I also created a simple a unit test test for the decompile command. Will submit a PR up with these changes soon.