Repository navigation
Simplify 2.0 is a rewrite of all three tools in Kotlin: the virtual machine (smalivm), the deobfuscator (simplify) and the debugger (sdbg). The command line works the same way, but the analysis, its limits and the smalivm API are new, so results differ from 1.x.
Highlights
- Android 16 framework. smalivm executes the framework Smali captured from the API 36 (Android 16) boot classpath. The API 25 corpus from 1.x is no longer packaged.
- Every path, with unknown inputs. smalivm explores every path of a method and keeps every possible register and class value. A branch on an unknown value takes both arms.
- Rewrites need a complete analysis. Simplify rewrites a method only when its analysis finished. A method that hits a limit is reported as skipped and left unchanged, instead of being rewritten from partial evidence.
- Host calls are authorized and checked. A framework method runs on the host JVM only when the reflection policy (
safe_classes.cfg,safe_methods.cfg,unsafe_methods.cfg) allows it. Its effect on guest state is measured by comparing the objects it can reach before and after the call; a call whose effect is unknown is kept. - Reflection.
Method.invokeof an application method runs as a guest call with ART's reflection rules, and unreflection turns it into a direct call when the target has no effect.Class.forNamewith no effect becomesconst-class. - Strings. Constant propagation turns a computed
Stringintoconst-stringunless the method compares or locks on that object. - Dead code. Dead code removal deletes allocations nothing observes, with their constructors and calls, and calls that have no effect.
- Memory. A method whose analysis would fill the JVM heap is skipped with
MEMORY_LIMITinstead of ending the run withOutOfMemoryError. Give the JVM more heap with-Xmxto analyze it. - Documented semantics.
docs/DALVIK-SEMANTICS.mdstates where each execution rule comes from (Dalvik spec, ART source, device measurement or engine choice). Many rules are checked against ART by device fixtures.
The bundled example app shows the result: its encrypted strings, reflection and string building reduce to System.out.println("magic answer = 42"), in under a minute.
Breaking changes
- Building and running need JDK 21 or later.
- The smalivm API is new (
VmServices,ExecutionSession,ExecutionGraph,TrustedGraphView). Code that embeds smalivm 1.x must be rewritten;demoappshows how to embed 2.0. - An APK or archive with more than one DEX file (
classes2.dex) is rejected. - The exit status is 1 when the input is rejected, a method fails to execute, or an optimizer edit is rejected.
--ignore-errorsskips failed methods and exits 0. Skipped methods do not change the exit status.
Downloads
simplify-2.0.0.jar: the deobfuscator.java -jar simplify-2.0.0.jar --helpsdbg-2.0.0.jar: the Smali debugger.smalivm-2.0.0.jar: smalivm with its runtime dependencies, for embedding.
APK output replaces classes.dex and must be signed again before installation.
Known issues
- In the example app,
MainActivity.<init>andonCreateare skipped: exploring the framework'sActivity.onCreatereaches the method limit, orMEMORY_LIMITon a small heap. invoke-polymorphic,invoke-custom,const-method-handleandconst-method-typeare not supported. A path through them ends the analysis as partial, so the method is skipped.Constructor.newInstanceof an application constructor is not run as a guest call.- For contributors: the pinned ART image that
tools/art-runneruses to record device fixtures can no longer be rebuilt, because Alpineedge/testingno longer publishes it.