package com.nii.soot.CFGCamera2Analyser; import java.util.Collections; import soot.PackManager; import soot.Scene; import soot.Transform; import soot.options.Options; public class Camera2MethodAnalyzer { private static boolean SOOT_INITIALIZED = false; private final static String androidJAR = "D:\\Android\\Android SDK\\platforms"; private final static String appApk = "C:\\Users\\32082\\Desktop\\soot\\soot-android-static-analysis-master\\apk\\F-droid\\AnaCam.apk"; public static void initialiseSoot() { if (SOOT_INITIALIZED) return; Options.v().set_allow_phantom_refs(true); Options.v().set_prepend_classpath(true); Options.v().set_validate(true); // Options.v().set_verbose(true); // 启用详细日志记录 Options.v().set_output_format(Options.output_format_jimple); Options.v().set_output_format(Options.output_format_dex); Options.v().set_process_multiple_dex(true); Options.v().set_whole_program(true); Options.v().set_process_dir(Collections.singletonList(appApk)); Options.v().set_force_android_jar(androidJAR); Options.v().set_src_prec(Options.src_prec_apk); Options.v().set_soot_classpath(androidJAR); // 禁用注解处理 // Options.v().set_ignore_resolving_levels(true); // Options.v().set_ignore_classpath_errors(true); // Options.v().set_ignore_resolution_errors(true); Scene.v().loadNecessaryClasses(); SOOT_INITIALIZED = true; } public static void main(String[] args) { initialiseSoot(); PackManager.v().getPack("jtp").add(new Transform("jtp.MyAnalysisCamera2", new MyAnalysisCamera2())); // PackManager.v().getPack("jtp").add(new Transform("jtp.MyAnalysisCamera", new MyAnalysisCamera())); // PackManager.v().getPack("jtp").add(new Transform("jtp.MyAnalysisCameraX", new MyAnalysisCameraX())); PackManager.v().runPacks(); } }