[Soot-list] Why does rewriting an APK fail with no instrumentation?

Steven Arzt Steven.Arzt at cased.de
Thu Sep 10 10:57:21 EDT 2015


Hi Prateek,

 

When I try to download your APK file, I get an HTTP 404, file not found error. Can you please send me the APK file via e-mail?

 

Best regards,

  Steven

 

Von: soot-list-bounces at CS.McGill.CA [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von prateeksaxena at gmail.com
Gesendet: Samstag, 13. Juni 2015 04:06
An: soot-list at CS.McGill.CA
Betreff: [Soot-list] Why does rewriting an APK fail with no instrumentation?

 

Hi,

 

I am trying to instrument an APK using soot. As a simple test, I want to re-compile the APK with no / null instrumentation. I am using the VM released at http://sseblog.ec-spride.de/tutorials/

 

My instrumentation doesn’t modify any method bodies.

The code is:

 

public class MyBodyTransformer extends BodyTransformer{
        @Override
        protected void internalTransform(Body body, String arg0, Map arg1) {

 

        }
}

 

When I try the RV2013.apk example (sample provided in the tutorial VM), it works fine. But, when I use a different apk it fails (e.g. the apk <https://www.dropbox.com/s/qihaunn2qsvi034/foo.apk?dl=0>  here). The original APK works fine on the Android emulator.

 

 

In the console I see:

…

Transforming com.vladium.util.IntObjectMap... 

…

Exception in thread "main" java.lang.RuntimeException: (<com.vladium.util.IntObjectMap: java.lang.Object put(int,java.lang.Object)>) no defs for value: $r5!

…

 at soot.Body.validateUses(Body.java:365)
 at soot.Body.validate(Body.java:234)
 at soot.jimple.JimpleBody.validate(JimpleBody.java:71)
 at soot.PackManager.runBodyPacks(PackManager.java:903)
 at soot.PackManager.runBodyPacks(PackManager.java:585)
 at soot.PackManager.runBodyPacks(PackManager.java:487)
 at soot.PackManager.runPacksNormally(PackManager.java:464)
 at soot.PackManager.runPacks(PackManager.java:388)
 at instrumentation.Main.main(Main.java:12)

 

 

The options I provide are the same as the one that work for the sample APK:

 

public class Settings {
        private static boolean SOOT_INITIALIZED = false;
        private final static String TOAST_CLASS = "android.widget.Toast";
        private final static String androidJAR = "./lib/android.jar";
        private final static String apk = "./apk/foo.apk";
        
        public static void initialiseSoot(){
                if (SOOT_INITIALIZED)
                        return;
                G.reset();
                
                Options.v().set_allow_phantom_refs(true);
                Options.v().set_prepend_classpath(true);
                Options.v().set_validate(true)
                Options.v().set_output_format(Options.output_format_dex);
                Options.v().set_process_dir(Collections.singletonList(apk));
                Options.v().set_force_android_jar(androidJAR);
                Options.v().set_src_prec(Options.src_prec_apk);

                Options.v().set_soot_classpath(androidJAR);
               Scene.v().loadNecessaryClasses();
                Scene.v().forceResolve(TOAST_CLASS, SootClass.BODIES);

 

                SOOT_INITIALIZED = true;
  }

 

Could you please help?

 

Thanks,

 

-- Prateek.

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150910/a3e9d245/attachment-0001.html 


More information about the Soot-list mailing list