Android:Decompile
lastmod 2025-02-13created 2016-10-195 edits
About Android decompilation (Decompile).
Tools
- APK to JAR.
- DEX2JAR - https://code.google.com/p/dex2jar/
- Decompress APK.
- APKTool - https://code.google.com/p/android-apktool/
- JAR Decompiler .
- JD-GUI - http://java.decompiler.free.fr/?q=jdgui
- JAD - http://www.varaneckas.com/jad/
APK Decompile
A summary of how to decompile an Android apk file with APK tool, dex2jar, and jd-gui.
apk tool
- http://code.google.com/p/android-apktool/
- Download: the apktool-install- file for windows, apktool-file
- Extract both downloaded archives
- Create a folder named apktool in android-sdk/platform-tools/ on your computer
- Copy and paste aapt.exe, apktool.bat, apktool.jar (the files resulting from compressing the downloaded files, 3 in total) into the apktool folder.
- apk tool is ready
dex2jar
- http://code.google.com/p/dex2jar/
- Download: dex2jar-0.0.7.9-snopshot.zip -> extract
- Paste the extracted folder into android-sdk/platform-tools/ on your computer and shorten the folder name to dex2jar
Setting environment variables to use apk tool and dex2jar
- In the environment variable settings, edit Path among the system environment variables
- Add the path mycomputer/andorid-sdk/platform-tools
- Add the path /andorid-sdk/platform-tools/apktool on your computer
- Add the path /andorid-sdk/platform-tools/dex2jar on your computer
- After adding the 3 paths to the Path system variable, open cmd
- cmd: type adb! -> if a bunch of output scrolls by, it's working
- cmd: type apktool! -> if a bunch of output scrolls by, it's working
- cmd: type dex2jar! -> if a bunch of output scrolls by, it's working
- apk tool and dex2jar are ready to use!!!!
Preparing the jd-gui decompiler
- Download: http://java.decompiler.free.fr/?q=jdgui
- Reference: http://blog.naver.com/fromyongsik/40159603066
Extracting the apk file from an Android device or virtual device
- When using a virtual device running on VirtualBox
- Start the virtual device and check its IP in the wifi settings.
- Open a cmd window and
- adb connect (the IP you found)
- adb devices: shows the connected virtual devices.
- Run adb shell. In shell mode,
shell@android:/ $ pm list package -f
shows the list of apks installed on the virtual device.
Find the path and name of the apk to extract in the list, and - adb pull /data/app/com.HelloWorld.apk (path and name of the apk to extract)
Decompiling the extracted apk file with apktool
- apktool d extracted-apk-name output-directory (e.g. apktool d HelloWorld.apk out)
- The out folder will contain a res folder, a smali folder, androidmanifest.xml, and an apktool.yml file.
- You can see that *.smali files for the apk's java files have been created in the smali folder.
- That's it for preparing to reverse an Android apk. Now let's build an Android apk file and reverse it!
- Create an Android test project to reverse with Eclipse.
- Right-click the Android project -> android tools -> select export unsinged application package.... -> set the path for the apk file
- The Android apk file is created
| WARNING |
| With apktool you can get the resource files and configuration files from an apk, but it is hard to view the Java source. |
Viewing the source of an apk file with dex2jar and jd-gui
- Change the extension of the apk file whose Java files you want to see to zip.
- Extract it with a program such as ALZip.
- A res folder, androidManiFest.xml, classes.dex, and resources.arsc are created.
- The Java files can be read through classes.dex.
- Open cmd
- In cmd, go to the path of the classes.dex file
- In cmd, type dex2jar classes.dex
- Something runs and completes
- A classes_dex2jar.jar file is created in that path.
- Extracting the jar file lets you see the class files of the apk.
- Run the jd-gui program and open the classes_dex2jar.jar file.
- You can see the packages and Java source.
Decompiling java.class to java.java with jad
- Go to www.varaneckas.com/jad
- Download the jad.zip file for windows
- After extracting jad.zip, copy and paste the executable into the java/jdk/bin folder on your computer.
- Ready to decompile with jad
- In cmd, go to the path of the class file you want to decompile, then in the console type
jad -p aaa.class > bbb.java
This decompiles aaa.class and creates bbb.java in that path.
See also
Favorite site
- Decompiling Android APKs
- How to decompile Android
- Decompiling dex files
- How to modify dex files
- Odex Deodex tutorial #1: What are odex & deodex?
- Odex Deodex tutorial #2 (subtitle: extracting dex files)
- Odex Deodex tutorial #3 (subtitle: modifying and applying dex files)
- Odex & Deodex command summary
- SOFTDX DEX TOOLS v1.0
References
-
Android_how_to_use_decompile_tools.pdf ↩
Pages that link here