Android: Decompiling resources of *.apk files using android-apktool,dex2jar and JD-GUI



Since I am from flash background and in our flash environment “swf” decompiling is one of the most commonly used actions. So,I was curious whether the same reverse engineering process is applicable on Android platform or not? After some googling around I found a tool at
http://code.google.com/p/android-apktool/
which claimed to decompile *.apk files of Android. Then,without further delay I downloaded the files from download section of the above url and after completion of download,I extracted the files. Then I set the appropriate environment variables,so that I could access apktool from command line.
Then,I exported a sample.apk in some folder say sampleapp and I navigated to the that folder and used command line as follows


apktool d sample.apk

apktool usage

After that,I navigated to sampleapp folder and found a folder named sample app where there were decompiled files.While carefully examining the files,I found that the resources of sample.apk file was decompiled to the original format,but the java classes under the src folder were in .smali format.
So apktool was great for decompiling resources of android apk files.And if there is need to lookout for codes used on that apk files,you have to follow following procedure
First,you need to download two things from net

  1. dex2jar
  2. JD-GUI

  1. Unzip dex2jar and set environment variables in your respective OS,so that you could access it directly from command line.
  2. Let’s say you have someName.apk file,first unzip that file.
  3. When you unzip that file,you will get .dex extension file along with other files.Just maintain focus on .dex extension folder.
  4. Now go to command line and navigate to just unzipped folder location i.e. the location where .dex extension file exists and type on command line


//let's say our .dex extension filename be someName.dex;
//for windows
dex2jar someName.dex
//for linux versions
dex2jar.sh someName.dex

dex2jar
After doing this ,you will receive

someName.dex.dex2jar.jar

file.Now open ,this(someName.dex.dex2jar.jar) file with JD-GUI.Once you have opened it,you will see all the classes and their respective codes.
JD-GUI
This is so far the process,I have known to decompile .apk files
And finally ,I would recommend these tools, as they are not only great tools but also a way for Android developers to learn more from the sample apps whose resources aren’t readily available

Advertisements

One thought on “Android: Decompiling resources of *.apk files using android-apktool,dex2jar and JD-GUI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s