1

i am trying to get a call graph for apk files. i run the code below. but afterward when i check the sootOutput file, it's empty!! any ideas? P.S: it prints the size of the graph and has no error!

thank you in advance

import java.io.IOException;
import java.util.Collections;
import org.xmlpull.v1.XmlPullParserException;
import soot.PackManager;
import soot.Scene;
import soot.SootMethod;
import soot.jimple.infoflow.android.SetupApplication;
import soot.options.Options;

public class call {

    public call() {
        // TODO Auto-generated constructor stub
    }

    public static void main(String[] args) {

        // TODO Auto-generated method stub

        SetupApplication app = new SetupApplication("D:\\Users\\ML\\AppData\\Local\\Android\\sdk\\platforms","D:/b.apk");
        try {
            app.calculateSourcesSinksEntrypoints("C:\\Users\\ML\\workspace\\Graph\\1.txt");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        soot.G.reset();

        Options.v().set_src_prec(Options.src_prec_apk);
        Options.v().set_process_dir(Collections.singletonList("D:/b.apk"));
        Options.v().set_android_jars("D:\\Users\\ML\\AppData\\Local\\Android\\sdk\\platforms");
        Options.v().set_whole_program(true);
        Options.v().set_allow_phantom_refs(true);
        Options.v().set_output_format(Options.output_format_boutput_format_class);
        Options.v().setPhaseOption("cg.spark", "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()); 
    }

}
nicopico
  • 3,606
  • 1
  • 28
  • 30
soot User
  • 29
  • 3

1 Answers1

0

you are using Soot in a very non-standard way. In particular, you never actually call those methods of Soot that are required to write out the output. I would highly recommend calling Soot's own main method soot.Main.main, and just plugging in a bunch of Transformers.

Eric
  • 1,343
  • 1
  • 11
  • 19