[Soot-list] Help regarding Call graph for multiple apk's

LOKESH JAIN lokeshjain92 at gmail.com
Fri Sep 12 10:48:36 EDT 2014


Hi Eric,
Thanks for taking out time to read the entire thread.

I am using soot plugin in eclipse.
Suppose if in the code if i manually specify the path of application and
run the soot. Now, when that code is terminated then i have to specify the
path of another application manually i.e instead of "abcd.apk" i have to
manually specify "efgh.apk" and run again.  It's working perfectly fine.

SetupApplication app = new
SetupApplication("/home/lokesh/Desktop/android-sdk-linux/platforms/android-19/android.jar","abcd.apk");
Options.v().set_process_dir(Collections.singletonList("abcd.apk"));

But, i have to analyse around 2000-3000 aplications, so therefore i want
that instead of specifying the path of each application manually, i have
automated it.

File dir = new File("/home/lokesh/Desktop/lokesh/sample_applications");
File[] files = dir.listFiles();

for (int i = 0; i < files.length; i++) {
        File f = files[i];
        String source_apk = f.getAbsolutePath();
        soot.G.reset();

SetupApplication app = new SetupApplication("/home/
lokesh/Desktop/android-sdk-linux/platforms/android-19/
android.jar",source_apk);

Options.v().set_process_dir(Collections.singletonList(source_apk));

Now it collects application one by one from a folder and get a call graph.
But now the call graph i am getting is something not upto the mark. I have
attached both the files in my first thread of this mail both good and bad
result that i am getting respectively from the above scenarios.

In this folder there are other apps besides RV2013.apk. In bad call graph
it's giving me me unnecessary branches and nodes.

I have used soot.G.reset() function also but still not getting the same
results.

I was thinking that may be one application is making the call graph on top
of other and it's not getting resetted properly. Though i also think that
soot.G.reset() should resolve this but yet it's not resolving.

Thanks & Regards
Lokesh Jain




On Fri, Sep 12, 2014 at 5:35 PM, Bodden, Eric <eric.bodden at sit.fraunhofer.de
> wrote:

> Lokesh, I have read the entire thread and I am stillnot sure what problem
> you are actually trying to solve. What's wrong with using a shell script to
> invoke Soot one app after the other? And if you don't but use G.reset(),
> then what exactly do you mean by "it's not working". You must be more
> explicit and eliminate all the guesswork for us if you are expecting help
> quickly.
>
> Best wishes,
> Eric
>
>
>
>
>
> On 11.09.2014, at 18:58, LOKESH JAIN <lokeshjain92 at gmail.com> wrote:
>
> > Hi all,
> >
> > Any suggestions please? I think there should be something for running
> soot for multiple apk's. Some transformer thing or something that allows it
> to build 1 call graph on top of another. i am just not able to figure out
> what that could be. I have seen SetupApplication implmentation also but
> still couldn't figure out. soo.G.reset() is not helping.
> >
> >
> > Regards
> > Lokesh Jain
> >
> > On Wed, Sep 10, 2014 at 6:55 PM, LOKESH JAIN <lokeshjain92 at gmail.com>
> wrote:
> > Hi Steven,
> >
> > I am doing that. I have pasted the code above, but it's just a snippet.
> Before SetupApplication i am doing soot.G.reset(). In source_apk i am
> taking the path of 1 apk at a time and i am doing soot.G.reset() and then
> SetupApplication. It's not working.
> >
> > public static void main(String[] args) {
> >
> > File dir = new File("/home/lokesh/Desktop/lokesh/sample_applications");
> > File[] files = dir.listFiles();
> >
> > for (int i = 0; i < files.length; i++) {
> >         File f = files[i];
> >         String source_apk = f.getAbsolutePath();
> >         soot.G.reset();
> >
> > SetupApplication app = new
> SetupApplication("/home/lokesh/Desktop/android-sdk-linux/platforms/android-19/android.jar",source_apk);
> >
> >
> > try {
> >
> >
> app.calculateSourcesSinksEntrypoints("/home/lokesh/Downloads/soot-infoflow-android-develop/SourcesAndSinks.txt");
> >
> >
> > }
> >
> > Regards
> > Lokesh Jain
> >
> > On Wed, Sep 10, 2014 at 5:34 PM, Steven Arzt <Steven.Arzt at cased.de>
> wrote:
> > Hi Lokesh,
> >
> > Your best bet is indeed to call soot.G reset() before every new
> analysis, i.e., whenever you analyze a new file in your loop.
> >
> >
> > Best regards,
> > Steven
> >
> > LOKESH JAIN <lokeshjain92 at gmail.com> wrote:
> >
> > Hello All,
> >
> > This is the code, in this i am calling dotgraph file for making graph.
> Let me know if i have to paste that code also. Actually that code i have
> takenm form dotgraph of soot only.
> >
> > import java.io.File;
> > import java.io.IOException;
> > import java.util.Collections;
> > import java.util.HashMap;
> > import java.util.Iterator;
> >
> > import org.apache.commons.io.FilenameUtils;
> > import org.xmlpull.v1.XmlPullParserException;
> >
> > import soot.MethodOrMethodContext;
> > import soot.PackManager;
> > import soot.Scene;
> > import soot.SootMethod;
> > import soot.jimple.infoflow.android.SetupApplication;
> > import soot.jimple.toolkits.callgraph.CallGraph;
> > import soot.jimple.toolkits.callgraph.Targets;
> > import soot.options.Options;
> > public class CFG {
> >         private static DotGraph dot = new DotGraph("callgraph");
> >         private static HashMap <String,Boolean> visited = new
> HashMap<String,Boolean>();
> >
> > public CFG() {
> >
> > }
> >
> > public static void main(String[] args) {
> >
> > File dir = new File("/home/lokesh/Desktop/lokesh/sample_applications");
> > File[] files = dir.listFiles();
> >
> > for (int i = 0; i < files.length; i++) {
> >         File f = files[i];
> >         String source_apk = f.getAbsolutePath();
> >         soot.G.reset();
> >
> > SetupApplication app = new
> SetupApplication("/home/lokesh/Desktop/android-sdk-linux/platforms/android-19/android.jar",source_apk);
> >
> >
> > try {
> >
> >
> app.calculateSourcesSinksEntrypoints("/home/lokesh/Downloads/soot-infoflow-android-develop/SourcesAndSinks.txt");
> >
> >
> > } catch (IOException e) {
> >
> > e.printStackTrace();
> >
> > } catch (XmlPullParserException e) {
> >
> > e.printStackTrace();
> >
> > }
> >
> >
> > Options.v().set_src_prec(Options.src_prec_apk);
> >
> > Options.v().set_process_dir(Collections.singletonList(source_apk));
> >
> Options.v().set_force_android_jar("/home/lokesh/Desktop/android-sdk-linux/platforms/android-19/android.jar");
> >
> > Options.v().set_whole_program(true);
> >
> > Options.v().set_allow_phantom_refs(true);
> >
> > Options.v().set_output_format(Options.output_format_none);
> >
> > Options.v().setPhaseOption("cg.spark verbose:true", "on");
> >
> > Scene.v().loadNecessaryClasses();
> >
> > SootMethod entryPoint = app.getEntryPointCreator().createDummyMain();
> >
> > Options.v().set_main_class(entryPoint.getSignature());
> >
> > Scene.v().setEntryPoints(Collections.singletonList(entryPoint));
> >
> > System.out.println("............"+entryPoint.getActiveBody());
> >
> > PackManager.v().runPacks();
> >
> > System.out.println(Scene.v().getCallGraph().size());
> > CallGraph cg = Scene.v().getCallGraph();
> > //System.out.println("+++++++++++++++++" + cg);
> > //System.out.println(".................."+entryPoint);
> > //String label = Scene.v().getCallGraph().listener().toString();
> > //dot.createSubGraph(label);
> > visit(cg, entryPoint);
> > String dest = f.getName();
> > String fileNameWithOutExt = FilenameUtils.removeExtension(dest);
> > String destination = "/home/lokesh/Desktop/lokesh/" + fileNameWithOutExt;
> > dot.plot(destination + dot.DOT_EXTENSION);
> >
> //soot.PhaseOptions.getBoolean(Scene.v().getCallGraph().listener(),"dump_cg");
> > //System.out.println(Scene.v().getCallGraph());
> >
> > }
> > }
> > private static void visit(CallGraph cg, SootMethod k)
> > {
> > String identifier = k.getName();
> >
> > visited.put(k.getSignature(),true);
> >
> > //System.out.println(dot.drawNode(identifier));
> > dot.drawNode(identifier);
> >
> >
> > //iterate over unvisited parents
> > Iterator<MethodOrMethodContext> ptargets = new Targets(cg.edgesInto(k));
> >
> >
> > if(ptargets != null){
> > while(ptargets.hasNext())
> > {
> > SootMethod p = (SootMethod) ptargets.next();
> >
> >
> > if(p == null)
> > System.out.println("p is null");
> >
> >
> > if(!visited.containsKey(p.getSignature()))
> > visit(cg,p);
> > }
> > }
> >
> >
> > //iterate over unvisited children
> > Iterator<MethodOrMethodContext> ctargets = new Targets(cg.edgesOutOf(k));
> >
> >
> > if(ctargets != null){
> > while(ctargets.hasNext())
> > {
> > SootMethod c = (SootMethod) ctargets.next();
> > if(c == null) System.out.println("c is null");
> > dot.drawEdge(identifier, c.getName());
> >
> >
> > if(!visited.containsKey(c.getSignature()))
> > visit(cg,c);
> > }
> > }
> > }
> > }
> >
> > Please reply fast as i am stuck here.
> >
> > Thanks & Regards
> > Lokesh Jain
> >
> > On Wed, Sep 10, 2014 at 4:23 PM, LOKESH JAIN <lokeshjain92 at gmail.com>
> wrote:
> > Hi Marc,
> >
> > Second option that you have mentioned, I haven't quite understood that.
> APK works on dalvik virtual machine. First class file is created and then
> it's converted to DVM. Then how to create a new JVM for each apk.
> >
> > Please suggest some easy and simple solution.
> > I will post the code snippet here. Please help me resolve my problem as
> i am not able figure out.
> >
> > Thanks & Regards
> > Lokesh Jain
> >
> > On Wed, Sep 10, 2014 at 3:28 AM, LOKESH JAIN <lokeshjain92 at gmail.com>
> wrote:
> > Hey Marc,
> >
> > I have tried soot.G.reset() before loading new apk but still getting the
> same graph. Any other suggestion?
> >
> > Thanks & Regards
> > Lokesh Jain
> >
> > On Mon, Sep 8, 2014 at 9:35 PM, LOKESH JAIN <lokeshjain92 at gmail.com>
> wrote:
> > Hi Stevan,
> >
> > No, I just want to create a call graph for each application seperately
> without manually giving the path for each application.
> >
> > Currently i had given the path for an application and getting the call
> graph, it's working fine then.
> > Now, I have written the script that automatically pick 1 application at
> a time and run soot on it(as i have more than 1000 apps). I don't specify
> the path manually for each application. It's now giving me some irrelevant
> call graph. I had attached both the graphs earlier in this thread.
> >
> > Regards
> > Lokesh Jain
> >
> > On Mon, Sep 8, 2014 at 5:36 PM, Steven Arzt <Steven.Arzt at cased.de>
> wrote:
> > Hi Lokesh,
> >
> > Are you looking for an inter-component callgraph to take intent-based
> communication into account? If so, you should look into the EPICC paper.
> Still, I am not sure that this actually scales to thousands of
> applications. What are you trying to achieve in total?
> >
> > Best regards,
> > Steven
> >
> > LOKESH JAIN <lokeshjain92 at gmail.com> wrote:
> >
> > Please reply fast. I am not able to figure out how to resolve it.
> >
> > Regards
> > Lokesh Jain
> >
> > On Sat, Sep 6, 2014 at 10:25 PM, LOKESH JAIN <lokeshjain92 at gmail.com>
> wrote:
> > Hello all,
> >
> > I want the call graph for more than one apk's files that are in a folder
> using soot. Please help me to generate the call graph for multiple
> applications as i have to generate the call graph for around 3000
> applications and it would be practically impossible to manually generate
> call graph for each application.
> >
> > I am getting the call graph for a single apk i.e every time i press the
> run button. But when I am running the code i.e looping over the all the
> apk's (reading apk one by one) in a folder. Then i am not getting the
> relevant call graph. I am getting something absurd.
> >
> > I am attaching both the call graph that i am getting while executing on
> a single application individually and the other I am getting while looping
> over multiple application at once.
> >
> > Any help would be appreciated.
> >
> > Regards
> > Lokesh Jain
> >
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at CS.McGill.CA
> > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>
> --
> Prof. Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
> Head of Secure Software Engineering  at Fraunhofer SIT, TU Darmstadt and
> EC SPRIDE
> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140912/22fd648e/attachment-0003.html 


More information about the Soot-list mailing list