How to get Call graph using Androguard API
See original GitHub issueHi,
i want to extract call graph of the entire application using only the API and i am using XREF in order to do it. In addition, i would distinguish external call from internal call. How can i do that?
I made a simple function that do the following:
# dalvik is DalvikVMFormat
for d in dalvik:
classes = d.get_classes()
for c in classes:
methods = c.get_methods()
for method in methods:
# x is Analysis object
method_class_analysis = x.get_method_analysis(method)
xref_to = method_class_analysis.get_xref_to()
#add method to graph
#and for each method in xref_to: add method to graph and add edge
In the variable xref_to I can find methods of type EncodedMethod and ExternalMethod (i can distinguish external call from internal code based on this type), but when I iterate over method (for method in methods) I don’t know if it is an external or internal one. This problem leads to an incorrect call graph.
Anyone can help?
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:49 (25 by maintainers)
Top Results From Across the Web
androguard cg - Create Call Graph from APK - Read the Docs
The default is to create a file called callgraph.gml in the current directory! classnames are found in the type "Lfoo/bar/bla;". Example: $ androguard...
Read more >Static call graph extraction from Android application - Esther
The easiest way to tackle this problem is to use Androguard. We will see how it is easy to statically extract the call...
Read more >Androguard Documentation - Read the Docs
If you want to create call graphs, use androguard cg, ... There are many more methods to explore, just take a look at...
Read more >Parallelization of Machine Learning Applied to Call Graphs of ...
Therefore, we need to parallelize these algorithms in order to make them viable. The first step of our automatic-tuning malware detection engine consists...
Read more >Analyzing Android Applications
"I have a game on the market called Sinister Planet which ... Baksmali (free), Androguard (free) ... You must search specific API in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just changed the code a little bit to get color for the methods:
This also shows something important: If you inherit a class and this class is for example an API class, all methods that are not overwritten are also external. As you can see in the graph, there are methods like
startService
orsetContentView
, which are external (blue) but have the classname of an internal class.Okay I see an imediate show stopper here: https://developer.android.com/studio/terms.html See especially point 3.4
So I would not put in the android jars into androguard… I think making this part optional with providing the path to the jars seems to be a good idea.
btw: In the prebuilds/sdk repo, there are also xml/txt files containing all the API description. And yes, the whole repo is huge (about 4,5GB)