Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A step-by-step tutorial for Soot (a Java static analysis framework)

License

NotificationsYou must be signed in to change notification settings

noidsirius/SootTutorial

Repository files navigation

Build StatusGitpod ready-to-codeDocker Pull

This repository contains (will contain) several simple examples of static program analysis in Java usingSoot.

Who this tutorial is for?

Anybody who knows Java programming and wants to do some static analysis in practice but does not know anything about Soot and static analysis in theory.

If you have some prior knowledge about static program analysis I suggest you learn Soot fromhere.

Setup

In short, use Java 8 and run./gradlew build. For more information and Docker setup, follow thislink.

Chapters

1: Get your hands dirty

In this chapter, you will visit a very simple code example to be familiar with Soot essential data structures andJimple, Soot's principle intermediate representation.

  • ./gradlew run --args="HelloSoot": The Jimple representation of theprintFizzBuzz method alongside the branch statement.
  • ./gradlew run --args="HelloSoot draw": The visualization of theprintFizzBuzz control-flow graph.
TitleTutorialSoot CodeExample Input
Hello SootDocHelloSoot.javaFizzBuzz.java

Control Flow Graph

2: Know the basic APIs

In this chapter, you get familiar with some basic but useful methods in Soot to help read, analyze, and even update java code.

  • ./gradlew run --args="BasicAPI": Analyze the classCircle.
  • ./gradlew run --args="BasicAPI draw": Analyze the classCircle and draws the call graph.
TitleTutorialSoot CodeExample Input
Basic APIDocBasicAPI.javaCircle

Call Graph

3: Android Instrumentation

In this chapter, you learn how to insert code into Android apps (without having their source code) using Soot. To run the code, you need Android SDK (check thislink).

  • ./gradlew run --args="AndroidLogger": Insert logging method calls at the beginning of APK methods ofNumix Calculator.
  • ./gradlew run --args="AndroidClassInjector": Create a new class from scratch and inject it to theNumix Calculator.

The instrumented APK is located indemo/Android/Instrumented. You need to sign it in order to install on an Android device:

cd ./demo/Android# on Windows, replace 'sign.sh' by 'sign.ps1'./sign.sh Instrumented/calc.apk key"android"adb install -r -t Instrumented/calc.apk

To see the logs, runadb logcat | grep -e "<SOOT_TUTORIAL>"

TitleTutorialSoot CodeExample APK
Log method calls in an APKDocAndroidLogger.javaNumix Calculator (fromF-Droid)
Create and inject a class into an APKDocAndroidClassInjector.javaNumix Calculator (fromF-Droid)

Soot Packs + Dexpler

4: Call graphs and PointsTo Analysis in Android

This chapter gives you a brief overview o call graphs and PointsTo analysis in Android and you learn how to create calls graphs using FlowDroid. The source code of the example code ishere. To run the code, you need Android SDK (check thislink).

  • ./gradlew run --args="AndroidCallGraph <CG_Algorithm> (draw)": Create the call graph ofSootTutorial Demo App using<CG_Algorithm> algorithm and print information such as reachable methods or the number of edges.
    • <CG_Algorithm> can beSPARK orCHA
    • draw argument is optional, if provided a visualization of call graph will shown.
    • For example,./gradlew run --args="AndroidCallGraph SPARK draw" visualizes the call graph generated by SPARK algorithm.
  • ./gradlew run --args="AndroidPTA": Perform PointsTo and Alias Analysis onSootTutorial Demo App using FlowDroid.
TitleTutorialSoot CodeExample APK
Call graphs in AndroidDocAndroidCallgraph.javaSootTutorial Demo App (source code)
PointsTo Analysis in AndroidDocAndroidPointsToAnalysis.javaSootTutorial Demo App (source code)

The call graph of SootTutorial Demo app

5: SomeReal Static Analysis (:construction: WIP)

  • ./gradlew run --args="UsageFinder 'void println(java.lang.String)' 'java.io.PrintStream": Find usages of the method with the given subsignature in all methods ofUsageExample.java.
  • ./gradlew run --args="UsageFinder 'void println(java.lang.String)' 'java.io.PrintStream": Find usages of the method with the given subsignature of the given class signature in all methods ofUsageExample.java.
TitleTutorialSoot CodeExample Input
Find usages of a methodUsageFinder.javaUsageExample.java
Null Pointer AnalysisNullPointerAnalysisNullPointerExample.java

6: Interprocedural analysis (:construction: WIP)

TitleTutorialSoot CodeExample Input

About

A step-by-step tutorial for Soot (a Java static analysis framework)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp