Friday, 8 July 2011

How to decompile Android application to get sourcecode

Hi Friends,
reverse engineering is everywhere. but reverse engineering is meant for  code review of  vulnerable application. so I hope you guys will not  use this reverse engineering  tricks to do any illegal things.
all android application are running  on Dalvik , which is a Virtual Machine having register-base  architecture and different from Java Virtual Machine by sun-microsystem (and now by oracle ) which is stack machine.
hence all android application is consist of Dalvik Executable (.dex).  hence to convert those  android application( *.apk) to source code we have to follow below steps

(Note : apk is packing of  .dex  file and other resources.)

step to decompile

1) convert  .dex file format to  .class file
2) convert  .class file format to  java code file

1) android application will come with .apk file format. which contains  .dex file .
hence  to convert .dex file in to .class file ( and those compress .class files  are placed in .jar file)
one need to have .dex  to  .class file converter .(both are binary format)
you can download such  tool from below link.


 after downloading you need to extract them and it will have following files in you  file system.





















then you open  command prompt and run batch file name dex2jar followed by your  apk file name with full path, if it is not resides on same directory.










then it will convert your  appname.apk file to  appname.apk.dex2jar.jar.

 which is pure bytecode  and can run on  java virtual machine.


 

2)  now you have  .jar file and   to convert this jar to java code there are many java decompilers are available .
but I have used  free one available on internet.  you can download from here
java decomipler

now  use this  compile and it will   generate souce code files for you.


 I hope  you like this  method  to decompile you  favorite android application.
there are such other tools available to decompile or reverse engineering  your android application.

No comments:

Post a Comment