Monday, May 14, 2012

3 easy steps android apk Reverse Engineer to get java source-code


Android applications are packed inside a APK file, which is just a ZIP file containing among other things a compact Dalvik Executable (.dex) file.

First step is to extract the “classes.dex” file from the APK:

$ unzip program.apk classes.dex
Archive: program.apk
inflating: classes.dex

Now, we use the tool dex2jar to convert the classes.dex file to Java .class files:
 
$ bash dex2jar/dex2jar.sh ./classes.dex
version:0.0.7.8-SNAPSHOT
2 [main] INFO pxb.android.dex2jar.v3.Main - dex2jar ./classes.dex -> ./classes.dex.dex2jar.jar
Done.

here bash is to execute bash script dex2jar.sh and ./classes.dex is one of your extracted apk files

here output will be dex2jar.jar

From here we obtain the file “classes.dex.dex2jar.jar”, now we can use the java decompiler JD-GUI to extract the source code:
 
$ ./jd-gui classes.dex.dex2jar.jar

Now just go to “File -> Save all sources” and it will generate the zip file “classes.dex.dex2jar.src.zip” containing all the decompiled Java source code 

No comments:

Post a Comment