56 lines
1.8 KiB
Java
56 lines
1.8 KiB
Java
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|