Sign inSign up

noidsirius/soot_tutorial

By noidsirius

•Updated over 5 years ago

Docker repo of Soot Tutorial (https://github.com/noidsirius/SootTutorial)

Image
0

652

noidsirius/soot_tutorial repository overview

⁠Soot Tutorial

Build Status Gitpod ready-to-code Docker Pull

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

⁠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 from here⁠.

⁠Why another tutorial for Soot?⁠

⁠Setup

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

⁠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 and Jimple, Soot's principle intermediate representation.

  • ./gradlew run --args="HelloSoot": The Jimple representation of the printFizzBuzz⁠ method alongside the branch statement.
  • ./gradlew run --args="HelloSoot draw": The visualization of the printFizzBuzz⁠ control-flow graph.
TitleTutorialSoot CodeExample Input
Hello SootDoc⁠HelloSoot.java⁠FizzBuzz.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 class Circle⁠.
  • ./gradlew run --args="BasicAPI draw": Analyze the class Circle⁠ and draws the call graph.
TitleTutorialSoot CodeExample Input
Basic APIDoc⁠BasicAPI.java⁠Circle⁠
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 this link⁠).

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

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

cd ./demo/Android
./sign.sh Instrumented/calc.apk key "android"
adb install -r -t Instrumented/calc.apk

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

TitleTutorialSoot CodeExample APK
Log method calls in an APKDoc⁠AndroidLogger.java⁠Numix Calculator⁠ (from F-Droid⁠)
Create and inject a class into an APKDoc⁠AndroidClassInjector.java⁠Numix Calculator⁠ (from F-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 is here⁠. To run the code, you need Android SDK (check this link⁠).

  • ./gradlew run --args="AndroidCallGraph <CG_Algorithm> (draw)": Create the call graph of SootTutorial Demo App⁠ using <CG_Algorithm> algorithm and print information such as reachable methods or the number of edges.
    • <CG_Algorithm> can be SPARK or CHA
    • 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 on SootTutorial Demo App⁠ using FlowDroid.
The call graph of SootTutorial Demo app
⁠5: Some Real 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 of UsageExample.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 of UsageExample.java⁠.
TitleTutorialSoot CodeExample Input
Find usages of a methodUsageFinder.java⁠UsageExample.java⁠
Null Pointer AnalysisNullPointerAnalysis⁠NullPointerExample.java⁠
⁠6: Interprocedural analysis (:construction: WIP)
TitleTutorialSoot CodeExample Input

Tag summary

Content type

Image

Digest

Size

1.2 GB

Last updated

over 5 years ago

docker pull noidsirius/soot_tutorial