How to track a local variable by Androguard

1.2k Views Asked by At

I want to track all the Intent objects, but I cannot find the API.

I want to know where a component start another in an application.Also, I want to know how does it happen, like if the Intent is a explicit Intent or if it has a Data.

For example, a activity can be launched by a method called startActivity(Intent i), I want to know the detail information of the "i".So I need to locate it.

Can someone give me some help?

Thanks very much!

1

There are 1 best solutions below

0
On
#!/usr/bin/env python

import sys,string
from androguard.core.bytecodes.dvm import DalvikVMFormat
from androguard.core.bytecodes.apk import APK
from androguard.core.analysis.analysis import uVMAnalysis
from androguard.core.analysis.ganalysis import GVMAnalysis

def join_names(items):
    arr = []
    for item in items:
        arr.append(item[0].class_name+"->"+item[0].name)
    return string.join(arr, ", ")

if len(sys.argv) > 2:
    filename = sys.argv[1]
    method_name = sys.argv[2]
    d = DalvikVMFormat(APK(filename, False).get_dex())
    d.create_python_export()
    dx = uVMAnalysis(d)
    gx = GVMAnalysis(dx, None)
    d.set_vmanalysis(dx)
    d.set_gvmanalysis(gx)
    d.create_xref()
    for m in d.get_methods():
        if m.name == method_name:
            print (m.class_name + "->" + m.name + " ----------------- XREFfrom: [" + join_names(m.XREFfrom.items) + "] XREFto: [" + join_names(m.XREFto.items) + "]")

Run it like so:

android@honeynet:~/tools/androguard$ ./xref.py your_apk.apk startActivity