Create new Java file with Dummy Main method of APK (Help wanted)
As in Android, there is no main method there are multiple entry points (e.g. onCreate, onResume and so on). I just figure out I can create a synthetic Main method using createDummy method. I want to create a new Java file with the Dummy Main method of the desired APK so i can use it for further analysis.
Soot, on which FlowDroid is based, cannot write out Java source files as far as I know. However, you can write out Java class files. You can use FlowDroid`s SetupApplication class to create the dummy main method (just create a callgraph, that will create the dummy main method as entry point) and then use the Soot#s PackManager to write out the scene again, including the new dummy main method. Just make sure to configure the Soot output format appropriately, since you want class files and not an APK.
Soot, on which FlowDroid is based, cannot write out Java source files as far as I know. However, you can write out Java class files. You can use FlowDroid
sSetupApplication` class to create the dummy main method (just create a callgraph, that will create the dummy main method as entry point) and then use the Soot#sPackManagerto write out the scene again, including the new dummy main method. Just make sure to configure the Soot output format appropriately, since you want class files and not an APK.
Thank you very much I'll try this :)
Soot, on which FlowDroid is based, cannot write out Java source files as far as I know. However, you can write out Java class files. You can use FlowDroid
sSetupApplication` class to create the dummy main method (just create a callgraph, that will create the dummy main method as entry point) and then use the Soot#sPackManagerto write out the scene again, including the new dummy main method. Just make sure to configure the Soot output format appropriately, since you want class files and not an APK.
When I try to use Options.v().set_output_format(Options.output_format_class); and PackManager.v().writeOutput(); to get .class output, I get this error:
[Thread-81] ERROR heros.solver.CountingThreadPoolExecutor - Worker thread execution failed: Method too large: dummyMainClass.dummyMainMethod_androidx_fragment_app_Fragment (Landroid/content/Intent;Landroid/app/Activity;)Landroidx/fragment/app/Fragment; org.objectweb.asm.MethodTooLargeException: Method too large: dummyMainClass.dummyMainMethod_androidx_fragment_app_Fragment (Landroid/content/Intent;Landroid/app/Activity;)Landroidx/fragment/app/Fragment; at org.objectweb.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2087) at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:489) at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:228) at soot.PackManager.writeClass(PackManager.java:1124) at soot.PackManager.lambda$writeOutput$1(PackManager.java:705) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)
Any idea how to write out dummyMainClass without MethodTooLargeException?
That's indeed a strange problem. Can you check whether the dummy main method is correct (and just large), or whether the generator is faulty and just generates a lot of unnecessary statements? That would help us decide whether we need to split the method, or whether there's just a bug to fix.
@mahad058 and @Canonize : May I know if you could successfully get the dummy main methods + all the class files of the app by following what @StevenArzt mentioned earlier?