harshguptaiscf / androguard

Automatically exported from code.google.com/p/androguard
Apache License 2.0
0 stars 0 forks source link

Renaming methods with prototype in their name does not update the python exports #164

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Analyze an APK with AnalyzeAPK()
2. Rename a method with d.CLASS_Lmy_class.METHOD_myMethod.set_name()
3. Type d.CLASS_Lmy_class.METHOD_ and press the TAB key to autocomplete and see 
the name change in python exports

What is the expected output? What do you see instead?

It works for regular methods but it does not work when methods have prototype 
in their names. A typical example is when an APK has been obfuscated with 
ProGuard. For instance, several methods may have the same name "a()" (but with 
different prototypes). Here is an example with 3 methods "a()". The 
corresponding python exports are:

In [7]: d.CLASS_La_a_a_a_a_a_a_d.METHOD_
d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_BLjava_lang_String
d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_BLjava_lang_StringLjava_lang_String
d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_Ljava_lang_StringLjava_io_UnsupportedEncodingE
xceptionLjava_lang_IllegalStateException

Let's check its name internally, which is correct:

In [7]: d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_BLjava_lang_String.get_name()
Out[7]: 'a'

Let's rename the method:

In [8]: d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_BLjava_lang_String.set_name("aa")

Below, we would expect having a new method "d.CLASS_La_a_a_a_a_a_a_d.METHOD_aa" 
but we don't and the old method still exists.

In [9]: d.CLASS_La_a_a_a_a_a_a_d.METHOD_
d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_BLjava_lang_String
d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_BLjava_lang_StringLjava_lang_String
d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_Ljava_lang_StringLjava_io_UnsupportedEncodingE
xceptionLjava_lang_IllegalStateException

Moreover, we see the name was changed internally, so the problem is only 
related to python exports.

In [10]: d.CLASS_La_a_a_a_a_a_a_d.METHOD_a_BLjava_lang_String.get_name()
Out[10]: 'aa'

What version of the product are you using? On what operating system?

Androguard revision 11f0822829ad

Please provide any additional information below.

I have a working patch and will provide it as soon as it has been a little bit 
tested :)

Original issue reported on code.google.com by saidel...@gmail.com on 6 Aug 2014 at 12:34