[Soot-list] Problem about instrumentation using FlowDroid 2.7.1

Diyu Wu diyu.wu at student.unsw.edu.au
Wed Sep 11 03:55:36 EDT 2019


Hi everyone

My name is Diyu Wu and I am currently working on a project leveraging FlowDroid.
I try to leverage the callgraph built by FlowDroid 2.7.1 and perform some instrumentation on an Android apk file.

the genaral code snippet look like this.

public static void main(String[] args){
 SetupApplication app = new SetupApplication("/home/derekwu/Current/android.jar", apkfile);
 app.constructCallgraph();

 instrument();

 generateInstrumentedApk(apkfile)
 jarsigner();
 zipalign();
}

private static void generateInstrumentedApk(String apkfile){
 final DexPrinter dexPrinter = new DexPrinter();
 try{
  int threadNum = Runtime.getRuntime().availableProcessors();

  CountingThreadPoolExecutor executor = new CountingThreadPoolExecutor(threadNum, threadNum, 30, TimeUnit.SECONDS,
    new LinkedBlockingQueue<Runnable>());

  Iterator<SootClass> classIterator = Scene.v().getApplicationClasses().snapshotIterator();
  while(classIterator.hasNext()){
   final SootClass c = classIterator.next();
   executor.execute(new Runnable() {

    @Override
    public void run() {
     // TODO Auto-generated method stub
     dexPrinter.add(c);
    }
   });
  }
  ...
 }

 finally {
  dexPrinter.print();
 }

}

However, this program runs into two problems.

  1.  when I try to sign the generated apk file, there is a chance to generate the following excetion. But when I run the program again the exception will disappear.

Exception in thread "main" org.jf.util.ExceptionWithContext: Item not found.: [Landroid/text/InputFilter;

at org.jf.dexlib2.writer.pool.StringTypeBasePool.getItemIndex(StringTypeBasePool.java:57)
at org.jf.dexlib2.writer.pool.StringTypeBasePool.getItemIndex(StringTypeBasePool.java:43)
at org.jf.dexlib2.writer.DexWriter.writeTypeLists(DexWriter.java:539)
at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:259)
at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:246)
at soot.toDex.MultiDexBuilder.writeTo(MultiDexBuilder.java:82)
at soot.toDex.DexPrinter.printApk(DexPrinter.java:269)
at soot.toDex.DexPrinter.print(DexPrinter.java:1512)
at clean.CleanProject.instrument(CleanProject.java:98)

at clean.CleanProject.main(CleanProject.java:48)

      2. for the successfully generated apk files, when I try to install them on a Android emulator(API 21 with 4G RAM), most of the apk files(file size over 1M based on my observation) coul        d not be installed with the INSTALL_FAILED_DEXOPT error. And the logcat shows the following information:

09-10 17:53:04.385 9848-9848/? E/dex2oat: Failed to open dex from file descriptor for zip file '/data/app/com.coste.syncorg-1/base.apk': Failure to verify dex file '/data/app/com.coste.syncorg-1/base.apk': Out-of-order string_ids: '<init>' then '<init>'
09-10 17:53:04.586 9848-9848/? I/dex2oat: dex2oat took 212.207ms (threads: 2)
09-10 17:53:04.588 1159-1159/? E/installd: DexInv: --- END '/data/app/com.coste.syncorg-1/base.apk' --- status=0x0100, process failed
09-10 17:53:04.588 1496-1525/system_process W/PackageManager: Package couldn't be installed in /data/app/com.coste.syncorg-1
    com.android.server.pm.PackageManagerException: scanPackageLI
        at com.android.server.pm.PackageManagerService.scanPackageDirtyLI(PackageManagerService.java:5912)
        at com.android.server.pm.PackageManagerService.scanPackageLI(PackageManagerService.java:5246)
        at com.android.server.pm.PackageManagerService.installNewPackageLI(PackageManagerService.java:10077)
        at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:10585)
        at com.android.server.pm.PackageManagerService.access$2300(PackageManagerService.java:233)
        at com.android.server.pm.PackageManagerService$6.run(PackageManagerService.java:8531)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.os.HandlerThread.run(HandlerThread.java:61)
        at com.android.server.ServiceThread.run(ServiceThread.java:46)

May I ask how can I fix this issue and correctly instrument the apk files?

I look forward to your kind reply.



Kind Regards

Diyu Wu





Kind Regards

Diyu Wu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20190911/b9d6640c/attachment-0001.html>


More information about the Soot-list mailing list