Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Jan 9, 2024
1 parent 3196367 commit b07c493
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PySoot
The `master` branch supports Python 3, the `py2k` branch supports Python2.

# Installation
`pip install -e .`
`pip install .`

# How to use
```Python 3
Expand All @@ -19,35 +19,18 @@ print(classes[list(classes.keys())[0]]) # print the IR of one of the translated

Many other examples are in `tests/test_pysoot.py`

`lifter.soot_wrapper` gives direct access to some Soot functionality.
As of now, I added functions from `Hierarchy.java`, but it is easy (and "almost" automatic) to add others.

# Requirements
* Java. Currently tested using OpenJDK 8 (`sudo apt-get install openjdk-8-jdk`).

Other components used by `pysoot` are:
* `Jython`. Already included in this repo, it is not neccesary to install it. The embedded version "simulates" a virtualenv with `pysoot` installed.
* `jpype`, used for accessing Java from Python.
* `soot-trunk.jar`. This is a slightly modified version of the pre-compiled Soot JAR. At some point, I will upload its source code and the compilation script somewhere.
`pysoot` should also work with a normal version of `soot-trunk.jar`.

# Internals
#### Components
`pysoot` works by running Soot (compiled in the embedded `soot-trunk.jar`) using Jython (embedded) and the code in `soot_manager.py`

`jython_wrapper.py` and `jython_runner.py` establish an IPC bi-directional channel which allows a Python process to call methods of an instance of a class in Jython (data is serialized/deserialized using `pickle`).
`jython_wrapper.py` runs in Python, while `jython_runner.py` runs in Jython.
In the future we could release this IPC-layer as a separate component.

`lifter.py` uses this IPC channel to ask Jython to create and serialize the IR.

Classes in `pysoot.sootir` are used both by the Jython code and the Python one.

#### Data-Flow Overview
Python --> `lifter.py` --> `jython_wrapper.py` --> Jython --> `jython_runner.py` --> `soot_manager.py` --> Soot --> Soot IR

Jython --> Soot IR --> `classes in pysoot.sootir` --> `jython_runner.py, pickle` --> Python --> `jython_wrapper.py, unpickle` --> `classes in pysoot.sootir` --> `lifter.py`

<br/>
`pysoot` works by running Soot (compiled in the embedded `soot-trunk.jar`) using jpype, in `soot_manager.py`.

![Pysoot Architecture](pysoot_arch.png "Pysoot Architecture")
`lifter.py` uses `soot_manager.py` to translate the JAR/APK file to a Soot-like Python IR.

Classes in `pysoot.sootir` provide the exposed IR.
Binary file removed pysoot_arch.png
Binary file not shown.

0 comments on commit b07c493

Please sign in to comment.