Extracting all API calls from .smali files in android apk

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 22:19:57

问题


I want to extract all API calls from an Android application's apk. I have used apktool to get the smali code files from the apk. Manually I can spot some API calls, but I need an automated method. For example, I can see the getNetworkInfo call in this line of code:

    invoke-virtual {p0, v0}, Landroid/net/ConnectivityManager;->getNetworkInfo(I)Landroid/net/NetworkInfo;

I have no experience with smali code and very little with Android application analysis; I only spotted the above API call because I happened to know that "getNetworkInfo" is one. But of course, what I don't want to do is begin with a list of all possible API calls and search for each of them in the smali files one by one.

Is there another indication of an API call? Will invoke-virtual or invoke-direct will always mean an API call?


回答1:


invoke-virtual and invoke-direct just call a method of some object with and without virtual method resolution, respectively. This doesn't necessarily have to be an API call; you could use these instructions with any kind of object, including instances of classes you define in your own code.

In this case, you found a call to a method in the android.net.ConnectivityManager class. If you want to find more API calls, you could start by searching for invoke-* instructions that reference certain classes, which for example might include anything under android.*, java.*, javax.*, etc.



来源:https://stackoverflow.com/questions/38972250/extracting-all-api-calls-from-smali-files-in-android-apk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!