From 1003bfcf2807d51bdb87fde98731a864eb854eaa Mon Sep 17 00:00:00 2001 From: p30496857 Date: Thu, 23 Nov 2023 13:51:23 +0800 Subject: [PATCH] ADD file via upload --- Checker2.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Checker2.java diff --git a/Checker2.java b/Checker2.java new file mode 100644 index 0000000..ee9914c --- /dev/null +++ b/Checker2.java @@ -0,0 +1,55 @@ +package com.nii.soot.CFGCamera2Analyser; + +import java.util.Collections; + +import soot.*; +import soot.jimple.InvokeExpr; +import soot.jimple.InvokeStmt; +import soot.options.Options; + +public class Checker2 { + +// 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\\pins.apk"; + + public static void main(String[] args) { + // 设置 Soot 的配置 + Options.v().set_src_prec(Options.src_prec_apk); + Options.v().set_android_jars("D:\\Android\\Android SDK\\platforms"); + Options.v().set_process_dir(Collections.singletonList("C:\\Users\\32082\\Desktop\\soot\\soot-android-static-analysis-master\\apk\\F-droid\\CameraAlign.apk")); + + + Options.v().set_allow_phantom_refs(true); + Options.v().set_prepend_classpath(true); +// Options.v().set_validate(true); + + // 初始化 Soot + Scene.v().loadNecessaryClasses(); + + // 遍历所有类 + for (SootClass sootClass : Scene.v().getApplicationClasses()) { + // 遍历类中的所有方法 + for (SootMethod method : sootClass.getMethods()) { + try { + Body body = method.retrieveActiveBody(); + + // 遍历方法中的所有语句 + for (Unit unit : body.getUnits()) { + if (unit instanceof InvokeStmt) { + InvokeExpr invokeExpr = ((InvokeStmt) unit).getInvokeExpr(); + if (invokeExpr.getMethod().getSignature().contains("camera2")) { + // 找到 camera2 的引用,处理结果 + System.out.println("Found camera2-related code in method: " + method); + + } + } + } + } catch (RuntimeException e) { +// System.out.println("无法分析方法: " + method); + } + } + } + + } + +}