Tuesday, 17 March 2015

How to decode an android application-APK file and reengineer

How to decode an android application to JAVA

1- http://stackoverflow.com/questions/1249973/decompiling-dex-into-java-sourcecode

Get these tools:
1) dex2jar, which is made by a Chinese student. It will translate dex files to jar files
2) jd-gui to view the java files in the jar

The source code is quite readable as dex2jar makes some optimizations.

And here's the procedure on how to decompile:

Step 1:
Convert classes.dex in test_apk-debug.apk to test_apk-debug_dex2jar.jar
d2j-dex2jar.sh -f -o output_jar.jar apk_to_decompile.apk
Note: In the Windows machines all the .sh scripts are replaced by .bat scripts
dex2jar documentation

Step 2:
Open the jar in JD-GUI

How to decode res (resource files)

C:\Users\ars\Desktop\APKtool\prebuilt\aapt\windows>aapt c -S .\res -C .\out 2>error.txt

Crunching PNG Files in source dir: .\res
To destination dir: .\out

Android Asset Packaging Tool
 aapt l[ist] [-v] [-a] file.{zip,jar,apk}
   List contents of Zip-compatible archive.

C:\Users\ars\Desktop\APKtool\prebuilt\aapt\windows>aapt c -S .\res\layout -C .\out

Crunching PNG Files in source dir: .\res\layout
To destination dir: .\out