CalebFenton / simplify

Android virtual machine and deobfuscator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception in thread "main" java.lang.RuntimeException

apkunpacker opened this issue · comments

Command Used:

java -jar simplify.jar --max-call-depth 999 --max-address-visits 999 --max-method-visits 999 --ignore-error demo.apk

Sample :

demo.apk.zip
Rename to demo.apk from demo.apk.zip

Output :
/storage/emulated/0 $ cd debugging
/storage/emulated/0/debugging $ java -jar simplify.jar --max-call-depth 999 --max-address-visits 999 --max-method-visits 999 --ignore-error demo.apk
04:21:42.945 INFO Main - Options:
Input file: demo.apk
Output file: demo_simple.apk
Include filter: null
Exclude filter: null
Max execution time: 300
Max address visits: 999
Max call depth: 999
Max method visits: 999
Max optimization passes: 100
Output API level: 15
Include support library: false
04:21:46.292 INFO Main - Filtered 0 support library classes
../../../../data/data/ru.iiec.jvdroid/cache/simplify12274818260362964318/com/Native.smali[6446,4] null
Exception in thread "main" java.lang.RuntimeException: Error loading class definition: Lcom/Native;
at org.cf.smalivm.type.ClassManager.parseClass(ClassManager.java:187)
at org.cf.smalivm.type.ClassManager.parseClassIfNecessary(ClassManager.java:205)
at org.cf.smalivm.type.ClassManager.getVirtualType(ClassManager.java:137)
at org.cf.smalivm.type.ClassManager.getVirtualType(ClassManager.java:158)
at org.cf.smalivm.type.ClassManager.getVirtualClass(ClassManager.java:130)
at org.cf.simplify.Launcher.collectTargetClassNameToMethods(Launcher.java:167)
at org.cf.simplify.Launcher.run(Launcher.java:134)
at org.cf.simplify.Main.main(Main.java:14)
Caused by: java.lang.RuntimeException: Unable to walk: /data/user/0/ru.iiec.jvdroid/cache/simplify12274818260362964318/com/Native.smali
at org.cf.smalivm.dex.SmaliParser.parse(SmaliParser.java:83)
at org.cf.smalivm.type.ClassManager.parseClass(ClassManager.java:184)
... 7 more
/storage/emulated/0/debugging $

Context :
apk is highly obfuscted ( all classes ) .Apk run fine but can't use simplify on it , neither can do dex2jar on it . removing Lcom/Native.smali either didn't help , it produce new similer error of another class if removed native.smali . Tried all simplify command with different values but error stay same . so i am assuming dex is not properly parsed

I wasn't able to reproduce the error until I baksmali'ed the apk and ran against the actual smali. The problem is that dexlib2 isn't able to parse the smali file. You can test this by running baksmali and then trying to smali the output. You'll get a similar error:

$ baksmali dis issue_147.apk
$ smali ass -o dexy.dex out
out/com/Native.smali[4660,4] null
out/com/mycompany/myapp/MainActivity.smali[1409,4] null

You'll need to create an issue for dexlib2 and see if they can help you with it.