Dex2jar is a free application that allows you to convert APK files to JAR files and view the source code. Converting the classes.dex file of an APK to classes.jar or vice versa is the core feature of Dex2jar. You can view the source code of an Android application by Java decompiler. Also, you can get ”.smali” files directly from the classes.dex file or vice versa, so it is possible to change the source code of an application directly working with this format. This article presents Introducing And Use Dex2jar On Kali Linux. To purchase your own Linux VPS, visit available packages on Eldernode to buy what you need.
Table of Contents
Introducing Dex2jar on Kali Linux
Dex2jar is an application that is using to work with android .dex and java .class files. It converts one binary format to another format and not to source. Dex2jar is under Apache2.0 License. In the continuation of this article, join us in learning how to use Dex2jar on Kali Linux.
Dex2jar Components
Ex2jar contains some components. Look at the below list:
dex-reader is designed to read the Dalvik Executable (.dex/.odex) format. It has a lightweight API similar to ASM.
dex-translator is designed to do the convert job. It reads the dex instruction to
dex-ir format, after some optimize, convert to ASM format.
dex-ir used by dex-translator is designed to represent the dex instruction
dex-tools tools to work with .class files. here are examples: Modify an apk, DeObfuscate a jar
d2j-smali [To be published] disassemble dex to smali files, and assemble dex from
smali files. different implementation to smali/baksmali, same syntax, but we support escape in type desc “Lcom/dex2jar\t\u1234;”
dex-writer [To be published] write dex same way as dex-reader.
How To Use Dex2jar On Kali Linux step by step
To view the file ”classes.dex” on the desktop, open the terminal and write ”d2j-dex2jar –d / file location”.
In this way, a JAR file will create, as you see below:
*
How to install Dex2jar On Kali Linux
Dex2Jar tool is one of Kali Linux’s reverse engineering. It is pre-installed on Kali Linux under reverse engineering tools. To install it on Kali Linux use the following command:
sudo apt-get install dex2jar
How to use Dex2jar
Here is the Dex2jar utilization.
sh d2j-dex2jar.sh -f ~/path/to/apk_to_decompile.apk
You will see an output like apk_to_decompile-dex2jar.jar
How to read dex file using dex2jar
Here is the solution.
DexFileReader r = new DexFileReader(...);
DexFileNode n = new DexFileNode();
DexFileWriter w = new DexFileWriter();
// reade dex to DexFileNode
r.accept(n);
... // modify DexFileNode here
// copy modified DexFileNode to DexWiter
n.accept(w);
byte[] data = w.toByteArray();
... // save data
How to convert jar to dex
The dx tool from android sdk can do the job
dx --dex --output=classes.dex abc.jar
And the [d2j-jar2dex] from dex2jar also can do the job
d2j-jar2dex.sh --output=classes.dex abc.jar
Conclusion
In this article, you reviewed Introducing And Use Dex2jar On Kali Linux. Note that you should increase the size of the JVM memory in the d2j_invoke script, otherwise, you may face the Error for the large size DEX file while converting DEX to JAR. Ask your friends on Eldernode Community if they have used this tool or not.