Decompile an Android APK file to a JAR file using dex2jar and JD-GUI

Dex2jar and JD-GUI are two different tools that are often used for reverse engineering Android apps. Dex2jar converts .dex files to .jar files, and JD-GUI is a Java decompiler that can decompile .jar files to the original Java source code.




Steps to install Dex2jar

Follow the below steps to install Dex2jar on your Windows or on your Linux Platform:

For Windows

Follow the below steps to install dex2jar on the Windows Platform:

1. Download Dex2jar and extract the file.

2. Open the folder and open the command prompt from here, by pressing Shift and right-clicking on the mouse. Let's start with the help command:

D:\Download\dex2jar-2.0\dex2jar-2.0> d2j-dex2jar -h
d2j-dex2jar -- convert dex to jar
usage: d2j-dex2jar [options] <file0> [file1 ... fileN]
options:
 -d,--debug-info              translate debug info
 -e,--exception-file <file>   detail exception file, default is $current_dir/[fi
                              le-name]-error.zip
 -f,--force                   force overwrite
 -h,--help                    Print this help message
 -n,--not-handle-exception    not handle any exception throwed by dex2jar
 -o,--output <out-jar-file>   output .jar file, default is $current_dir/[file-na
                              me]-dex2jar.jar
 -os,--optmize-synchronized   optmize-synchronized
 -p,--print-ir                print ir to Syste.out
 -r,--reuse-reg               reuse regiter while generate java .class file
 -s                           same with --topological-sort/-ts
 -ts,--topological-sort       sort block by topological, that will generate more
                               readable code
 -v,--verbose                 show progress
version: reader-2.0, translator-2.0, ir-2.0
3. To Decompile an APK file, type the following command:
Remember: Before decompile an android app, make sure you have pasted the APK file inside the dex2jar directory.

D:\Download\dex2jar-2.0\dex2jar-2.0> d2j-dex2jar "test.apk"
dex2jar test.apk -> .\test-dex2jar.jar

D:\Download\dex2jar-2.0\dex2jar-2.0>

For Linux (Kali Linux)

Now let it install dex2jar on the Linux Platform. I always prefer you, Kali Linux for penetration testing purposes.

1. Dex2jar comes, preinstall with Kali Linux. You do not need to install it again.

2. To run this application, go to reverse engineering and then click dex2jar.



See the options.

> Executing "d2j-dex2jar -h"
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
d2j-dex2jar -- convert dex to jar
usage: d2j-dex2jar [options] <file0> [file1 ... fileN]
options:
 -d,--debug-info              translate debug info
 -e,--exception-file <file>   detail exception file, default is $current_dir/[fi
                              le-name]-error.zip
 -f,--force                   force overwrite
 -h,--help                    Print this help message
 -n,--not-handle-exception    not handle any exception throwed by dex2jar
 -o,--output <out-jar-file>   output .jar file, default is $current_dir/[file-na
                              me]-dex2jar.jar
 -os,--optmize-synchronized   optmize-synchronized
 -p,--print-ir                print ir to Syste.out
 -r,--reuse-reg               reuse regiter while generate java .class file
 -s                           same with --topological-sort/-ts
 -ts,--topological-sort       sort block by topological, that will generate more
                               readable code
 -v,--verbose                 show progress
version: reader-2.0, translator-2.0, ir-2.0

3. I have an Android Application file on my desktop. I just want to decompile that file. So change the directory to Desktop. From here, type the following command to decompile that Android APK file.


┌──(mrdev㉿kali)-[~/Desktop]
└─$ d2j-dex2jar test.apk
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
dex2jar test.apk -> .\test-dex2jar.jar

┌──(mrdev㉿kali)-[~/Desktop]
└─$

 4. A jar file just appears on the desktop screen.




Steps to Install JD-GUI and its Usage

JD-GUI is a Java decompiler that can decompile .jar files to the original Java source code. Follow the below steps to install it on Windows or on the Linux Platform.

For Windows

1. To install it on the Windows platform click here & download it for Windows. After completion open it and extract it

2. Double-click on the application to launch.


3. Now open the file. Here see the decompiled Java code of the Android APK file.



For Linux Platform

To open the jar file you need JD-GUI, but this tool does not come pre-install with Kali Linux. So you have to install it manually.

1. Visit the official JD-GUI GitHub site. From here download it for Linux. As I am here using Debian-based Linux I am here to download the .deb file.
2. After completion of the download, open the directory. From this directory open the terminal from here.
  • Use the following command to install JD-GUI on Linux:

┌──(mrdev㉿kali)-[~/Download]
└─$ ls
jd-gui-1.6.6.deb

┌──(mrdev㉿kali)-[~/Download]
└─$ sudo chmod +x jd-gui-1.6.6.deb

┌──(mrdev㉿kali)-[~/Download]
└─$ sudo dpkg -i jd-gui-1.6.6.deb

3. Run JD-GUI by searching on All Applications.


4. Select the jar file, and see the magic.




In this way, You can decompile any APK file in this way, just follow my steps.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Ok, Go it!