[Soot-list] soot modify jimple to instrument android app

conlyxia conlyxia at 163.com
Mon Nov 30 09:06:15 EST 2015


Hello all,
I have used soot to instrument android app,but countered one problem,the instrumented app has no changes:


The following is my code:
</
try{
 sr.app.calculateSourcesSinksEntrypoints("/home/xcl/soot-jar/SourcesAndSinks.txt");
}catch(XmlPullParserException e){
System.out.println("void main XmlPullParserException: ");
e.printStackTrace();
}catch(IOException e){
System.out.println("void main IOException: ");
e.printStackTrace();
}
 soot.G.reset();
         //prefer Android APK files// -src-prec apk
         Options.v().set_src_prec(Options.src_prec_apk);
         Options.v().set_process_dir(Collections.singletonList(sr.apkPath));
         Options.v().set_android_jars("/home/xcl/soot-jar/android-platform");
        
         //output as APK, too//-f dex 
         Options.v().set_allow_phantom_refs(true);
         Options.v().set_output_dir("/home/xcl/ic3/apk/sootOutput");
         Options.v().set_output_format(Options.output_format_dex);


         Scene.v().loadNecessaryClasses();
         PackManager.v().runPacks();
         
         SootClass clazz=Scene.v().getSootClass("com.example.helloworld.Handle");
         SootMethod method=clazz.getMethod("void onCreate(android.os.Bundle)");
         
         Body b=method.getActiveBody();
         PatchingChain<Unit> units=b.getUnits();
         
         Local tmpRef = Jimple.v().newLocal("tmpRef", RefType.v("java.io.PrintStream"));
         b.getLocals().add(tmpRef);
         Stmt stmt=Jimple.v().newAssignStmt(
        tmpRef, Jimple.v().newStaticFieldRef( 
           Scene.v().getField("<java.lang.System: java.io.PrintStream out>").makeRef()));
   
         units.insertBefore(stmt, units.getFirst());     //add one Stmt
         System.out.println(b);
         PackManager.v().writeOutput();
/>
So,could you tell me what's wrong with my code? Looking forward to your reply.


Best Regards,
ConlyXia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20151130/909c976d/attachment-0001.html 


More information about the Soot-list mailing list