Hi ! 🙂 “Apktool” is another reverse engineering tool specifically designed to decode, edit, analyse and rebuild android apk files. Here I will state the steps to installing Apktool version 2.0 on ubuntu 14.0. With the migration of Apktool to its version 2.0, some settings have reduced. According to the documentation of “Apktool” now it doesn’t required to add aapt separately, since it is included in the the apktool itself.
The default framework included in the Apktool is enough to decode most apk files except the manufacture apks, since they require additional framework-res specific for the manufacture.
Setting up APKTool
Download apktool.jar and apktool wrapper script for Linux environment from their official web site -> http://ibotpeaches.github.io/Apktool/install/ .
- Change the owner of the files to your username of home directory.
This is required to allow access to the files.
Command $ chown -R username:username apktool.jar
Command $ chown -R username:username apktool
- Change permission to allow executing the files
Command $ sudo chmod +x apktool.jar
Command $ sudo chmod +x apktool
- Move the files to usr/local/bin
Command $ sudo mv apktool.jar /usr/local/bin
Command $ sudo mv apktool /usr/local/bin
Now you can run apktool commands from any directory.
Open a new terminal and execute apktool, you can see the help menu. Confirms the installation.
Command $ apktool
Now the environment is ready. So let’s try decompiling and rebuilding an random apk.
Decompiling …
Command $: apktool d <any.apk>
Ex.
Command $: apktool d PlayStore_v5.3.5.apk
The playstore apk is decompiled in to a new folder in the same directory.
The decompiled files include all the source files and resource files. The resource files are suffixed with .smali.
Rebuilding…
When you rebuild the resulted decompiled source files, two new folders will be created at the same location.
dist foler –> contains the rebuild apk file
Getting Framework-res
Before start decompiling any apk, find the available framework-res for the decompile to be properly happend.
Ex.
If your device is rooted, then you can pull out the available framework-res files.
Check for the available res files with following command.
Command $ adb shell
Command $ pm list packages -f
Pull out any available framework res files.
Command $ adb pull /system/framework/framework-res.apk
Note:
When your are trying to disassemble manufacture apks for instance Settings.apk, Contacts.apk, Maps.apk etc. you need to have proper framework resource. If that is not then you won’t be able to do the decoding properly.
Ex: When trying to decompile Maps.apk it says “Can’f find framework resources for package of id:2”
The valid range of framework resource file ids range from (1 – 9. If you get something like 127.apk that is an inner package id.
Ex.
Cheers ! 🙂