-
Notifications
You must be signed in to change notification settings - Fork 0
SootUtils
SootUtils
is a utility class designed to provide assistance in working with Soot classes, methods, and call graphs, specifically for Android application analysis. It offers a variety of methods and fields to facilitate tasks such as analyzing class hierarchy, method invocations, and control flow.
SootUtils
is a class that centralizes various tasks and analyses related to the Soot framework for Android applications.
-
getMethodRef(String className, String methodName)
: RetrievesSootMethodRef
. -
getAllSuperClasses(SootClass sootClass)
: Returns all superclasses. -
getAllInterfaces(SootClass sootClass)
: Returns all interfaces. -
getClassNames(Collection<SootClass> classes)
: Converts to class names.
-
getNumberOfStmt(SootMethod sm)
: Counts statements inSootMethod
. -
getNumberOfStmtInApp()
: Total statements in application. -
getNumberOfStmtInAppWithoutLibraries()
: Total statements excluding libraries. -
getNumberOfStmt(Collection<SootMethod> methods)
: Statements inSootMethod
s.
-
countEdgesInCallGraph(CallGraph cg)
: Counts edges in call graph. -
countEdgesWithNonLibraryTargets(CallGraph cg)
: Counts non-library targets. -
getCountOfNodes(CallGraph cg)
: Counts nodes in call graph. -
isInCallGraph(SootMethod method, CallGraph cg)
: Checks method in call graph. -
isCalledInCallGraph(SootMethod method, CallGraph cg)
: Checks method called in call graph.
-
getComponentType(SootClass sc)
: Identifies Android component type.
-
setupSoot(String platformPath, String apkPath, boolean wholeAnalysis)
: Configures Soot. -
setupSootWithOutput(String platformPath, String apkPath, String outputPath, boolean wholeAnalysis)
: Configures Soot with output.
Various methods to retrieve or exclude methods and classes according to criteria.
Use SootUtils
to efficiently perform static analysis on Android applications with the Soot framework. It simplifies handling of common tasks.
SootClass sootClass = Scene.v().getSootClass("com.example.MyClass");
Set<SootClass> superClasses = SootUtils.getAllSuperClasses(sootClass);
for (SootClass superClass : superClasses) {
System.out.println("Superclass: " + superClass.getName());
}
SootMethod method = Scene.v().getSootClass("com.example.MyClass").getMethodByName("myMethod");
int numberOfStatements = SootUtils.getNumberOfStmt(method);
System.out.println("Number of statements: " + numberOfStatements);
String platformPath = "/path/to/android/platforms";
String apkPath = "/path/to/app.apk";
boolean wholeAnalysis = true;
SootUtils.setupSoot(platformPath, apkPath, wholeAnalysis);
SootMethod method = Scene.v().getSootClass("com.example.MyClass").getMethodByName("targetMethod");
CallGraph cg = Scene.v().getCallGraph();
boolean isInCallGraph = SootUtils.isInCallGraph(method, cg);
System.out.println("Is method in call graph? " + isInCallGraph);
SootClass sootClass = Scene.v().getSootClass("com.example.MyActivity");
String componentType = SootUtils.getComponentType(sootClass);
System.out.println("Component Type: " + componentType);
These examples showcase the diverse functionalities provided by the SootUtils
class. It offers a simplified interface to work with Soot classes, methods, statements, and call graphs in the context of Android application analysis.
The SootUtils
class is essential for developers working with Soot to analyze Android applications. It offers a structured way to perform various analyses and simplifies many common tasks.