[Soot-list] Fwd: Find all calls to a given android API
Gian Luca Scoccia
loscoccia at gmail.com
Tue Nov 8 05:31:04 EST 2016
Hi, I'm new to Soot and I'm having some issues with it.
I'd like to use soot to find all method calls to a given Android API (
android.support.v4.app.ActivityCompat to be precise) and then trace them
back to the originating activity.
To my understanding, this can be done by building the call graph for the
application and I am able to do it with the code that follows.
Still, it seems that soot does not include the class
android.support.v4.app.ActivityCompat
when building the call graph neither in the library classes nor in the
application classes, probably since these classes are excluded to minimize
the execution time.
How can I tell soot to include these classes in the analysis? I tried with
set_no_bodies_for_excluded(false) and set_exclude(null) but no success.
Thanks in advance.
Gian Luca
My code:
File apk = new File("./inputs/org.telegram.messenger.apk");
File sAs = new File("./inputs/SourcesAndSinks.txt");
File androidJars = new File("/soot/android-jars");
File androidCallbacks = new File("./inputs/AndroidCallbacks.txt");
soot.G.reset();
SetupApplication setupApplication = new SetupApplication(androidJars.t
oString(), apk.toString());
setupApplication.calculateSourcesSinksEntrypoints(sAs.toString());
Options.v().set_android_jars(androidJars.toString());
Options.v().set_src_prec(Options.src_prec_apk);
Options.v().set_process_dir(Collections.singletonList(apk.toString()));
Options.v().set_whole_program(true);
Options.v().set_allow_phantom_refs(true);
Options.v().set_output_format(Options.output_format_none);
Options.v().setPhaseOption("cg.spark", "on");
Options.v().set_no_bodies_for_excluded(false);
Options.v().set_exclude(null);
Scene.v().loadNecessaryClasses();
SootMethod entryPoint =
setupApplication.getEntryPointCreator().createDummyMain();
Options.v().set_main_class(entryPoint.getSignature());
Scene.v().setEntryPoints(Collections.singletonList(entryPoint));
PackManager.v().runPacks();
CallGraph callGraph = Scene.v().getCallGraph();
java.util.List<SootMethod> ms = Scene.v().getSootClass("ActivityCompat").
getMethods();
for (SootClass a : Scene.v().getApplicationClasses() ){
System.out.println(a.getName());
}
for (SootClass a : Scene.v().getLibraryClasses() ){
System.out.println(a.getName());
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20161108/ea011140/attachment-0001.html
More information about the Soot-list
mailing list