Skip to content

Instantly share code, notes, and snippets.

@LazarusX
Created June 18, 2015 07:01
Show Gist options
  • Save LazarusX/abef8d1d678ef51b20a1 to your computer and use it in GitHub Desktop.
Save LazarusX/abef8d1d678ef51b20a1 to your computer and use it in GitHub Desktop.
Code snippet of Analyzer.java
G.reset();
Options.v().set_allow_phantom_refs(true);
Options.v().set_output_format(Options.output_format_none);
Options.v().set_whole_program(true);
Options.v().set_process_dir(Collections.singletonList(this.app.getApkPath()));
Options.v().set_soot_classpath(this.app.getAndroidJarPath());
Options.v().set_android_jars(this.app.getAndroidPlatformPath());
Options.v().set_src_prec(Options.src_prec_apk);
soot.Main.v().autoSetOptions();
Options.v().setPhaseOption("cg.spark", "on");
Scene.v().loadNecessaryClasses();
SootMethod dummyMainMethod = this.app.getEntryPointCreator().createDummyMain();
Options.v().set_main_class(dummyMainMethod.getSignature());
Scene.v().setEntryPoints(Collections.singletonList(dummyMainMethod));
Iterator<MethodOrMethodContext> iterator = Scene.v().getReachableMethods().listener();
while (iterator.hasNext()) {
SootMethod sm = iterator.next().method();
if (sm.isConcrete()) {
for (Unit u : sm.retrieveActiveBody().getUnits()) {
// actual analysis code
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment