31

The Android java code is compiled into Dalvik byte code, which is quite readable. I wonder, is it possible in theory and in practice to write a decompilation software for Dalvik byte code?

6 Answers 6

36

It's not only possible but has been done already, and not just once. Here's three I know about, and there may be more.

  1. Kivlad by Cody Brocious

    http://www.matasano.com/research/kivlad/

  2. DAD by Zost (Androguard project):

    http://code.google.com/p/androguard/wiki/Decompiler

  3. JEB by Nicolas Falliere (commercial)

    http://www.android-decompiler.com/

Then there are all the Java decompilers that can be used after using dex2jar or Dare on the Dalvik binary.

1
  • 2
    In theory all Java decompilers work as well as Dalvik class files can be transformed (back) into Java class files. In addition to the links above, you might want to look at Soot which recently added Dalvik support.
    – user209
    Commented Mar 20, 2013 at 17:20
7

I think it should be possible even with current Java decompilers, by patching their code. They have at least one big difference - while JVM is stack-based, Dalvik is register-based. This difference could be handled with not so much code. Second difference - bytecode format. So you need use code, which is able to disassemble Dalvik bytecode format.

5

Don't forget http://dexter.dexlabs.org/ - Dexter is a static android application analysis tool.

3

jadx has both CLI and GUI, and it's open source.

2

Another tool is Bytecode Viewer:

https://github.com/Konloch/bytecode-viewer

Bytecode Viewer is an Advanced Lightweight Java Bytecode Viewer, GUI Java Decompiler, GUI Bytecode Editor, GUI Smali, GUI Baksmali, GUI APK Editor, GUI Dex Editor, GUI APK Decompiler, GUI DEX Decompiler, GUI Procyon Java Decompiler, GUI Krakatau, GUI CFR Java Decompiler, GUI FernFlower Java Decompiler, GUI DEX2Jar, GUI Jar2DEX, GUI Jar-Jar, Hex Viewer, Code Searcher, Debugger and more. It's written completely in Java, and it's open sourced. It's currently being maintained and developed by Konloch.

1
  • An example of usage would be more than welcome ! :-)
    – perror
    Commented Feb 23, 2015 at 10:05
1

In addition to the software listed by Igor, there are also tools like apktool that can be used to decompile code : it transforms dalvik bytecode to smali, a language specific to the dalvik virtual machine (see instructions/opcodes here for example).

You can also edit resources in the application, and build the application back (but it will break the original signature as you will have to re-sign it with your own key)

1
  • 5
    Sorry but what you're describing is disassembly, not decompilation. Smali is just a way to represent Dalvik bytecode, it's not a high level language like Java.
    – Igor Skochinsky
    Commented Apr 10, 2013 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.