angr also supports symbolically executing Java code and Android apps! This also includes Android apps using a combination of compiled Java and native (C/C++) code.
Java support is experimental! Contribution from the community is highly encouraged! Pull requests are very welcomed!
We implemented Java support by lifting the compiled Java code, both Java and DEX bytecode, leveraging our Soot python wrapper: pysoot.
pysoot extracts a fully serializable interface from Android apps and Java code (unfortunately, as of now, it only works on Linux). For every class of the generated IR (for instance,
SootMethod), you can nicely print its instructions (in a format similar to
We then leverage the generated IR in a new angr engine able to run code in Soot IR: angr/engines/soot/engine.py. This engine is also able to automatically switch to executing native code if the Java code calls any native method using the JNI interface.
Together with the symbolic execution, we also implemented some basic static analysis, specifically a basic CFG reconstruction analysis. Moreover, we added support for string constraint solving, modifying claripy and using the CVC4 solver.
Enabling Java support requires few more steps than typical angr installation. Assuming you installed angr-dev, activate the virtualenv and run:
# CVC4 and pysoot should be already installed (if you used angr-dev to install angr)# install cvc4, needed for String solvingpip install cvc4-solver# install pysoot, needed to lift code from JARs and APKsgit clone firstname.lastname@example.org:angr/pysoot.gitcd pysootpip install -e .cd ..# install a specific version of pysmt (the one currently available on pip is buggy)pip uninstall pysmtgit clone https://github.com/pysmt/pysmt.gitcd pysmtgit checkout 6d792db47be5f8734db15848faca9bc6b770085epip install -e .cd ..
Analyzing Android apps (
.APK files, containing Java code compiled to the
DEX format) requires the Android SDK. Typically, it is installed in
XX is the Android SDK version used by the app you want to analyze (you may want to install all the platforms required by the Android apps you want to analyze).
There are multiple examples available: