image1 image2 image3

HELLO I'M NITENDRA THAKUR|WELCOME TO MY PERSONAL BLOG|I LOVE TO DO CREATIVE THINGS|I'M PROFESSIONAL ANDROID APPLICATION DEVELOPER

How to get Source Codes from .apk??

Reverse engineering is nothing but a process to extract knowledge or useful information from any product, whether it’s applied while rebuilding a bike or a car or any human made product. You would come to learn many new and interesting stuffs after breaking down the actual product into the different parts and putting them together again.
Originally this concept was originally applied to hardware only but now it’s also being highly used in software, to enhance the existing software or to duplicate it. The aim behind applying this process into software is software gets developed using programming language (which can be understandable by any programmer) which gets compiled using compilers and creates binary code (i.e. machine language, which can be understandable by system), so reverse engineering process comes into the picture when this machine language code requires to be converted back into the readable code using decompilers.
Well Beginners can use 3rd party  websites to reverse engineer .apk and get the source code but issue is that you cannot get the exact .xml files or resource files of that application. below mentioned are the websites which gives you the source code :
  1. http://www.decompileandroid.com/ - This website is not working as it works previously.
2.http://www.javadecompilers.com/ - This online tool is available for the lazy android app developers who can get the java and xml codes of any .apk and much more sites are availble.

Tools for reverse engineering
Below are some of the tools which I have been using to perform reverse engineering. If you know any good tool then please share it in comment, will definitely check and explore those it!
  • Dex2jar
  • Java decompiler
  • Apktool
  • Apk Analyser
Dex2jar

Download Dex2jar 

Android projects are gathered into .dex (Dalvik Executable) records, which are thus compressed into a solitary .apk document on the gadget. dex documents can be made via consequently interpreting aggregated applications written in the Java programming dialect.

Having said that, APK contains .dex document, to watch that simply rename the .apk record with .compress document and you would get classes.dex document. Only for the more data, dex is dalvik executable and it is really an incorporated code record.

As name itself is clear as crystal, the principle motivation behind Dex2jar instrument is changing over DEX (dalvik bytecode) to JAR (Java bytecode). It additionally gives a capacity to adjust .class documents in jug and fabricate again the container and make an interpretation of it back to dex.

Java decompiler


Download JD-GUI 

Java decompiler is used to decompile and break down byte codes. It's a GUI based utility to view .class records. You simply need to load jug record, to view .class documents of venture.

Apktool

Download Apktool

Utilizing Dex2Jar, you can get and play source code records, yet to play with asset documents, we require Apktool. Utilizing Apktool, we can translate asset into almost unique shape and modify them subsequent to making a few changes.

Apk Analyser 

Apk analyser is a device gave by sony versatile. They call it as an application investigation device. Yoou can use to dissect API references, view application engineering and conditions, and dismantle bytecodes in Android applications. It gives a gorgeous UI to your application engineering and conditions.

You can utilize Apk Analyser apparatus in the event that you would prefer not to perform lengthier procedure utilizing above devices.

Procedure

Procedure for decoding .apk files, step-by-step method:
Step 1: Make a new folder and put .apk file in it (which you want to decode). Now rename the extension of this .apk file to .zip (eg.: rename from filename.apk to filename.apk.zip) and save it.
If problems in the converting into .zip please refers link After getting .zip now you get classes.dex files, etc. At this stage you are able to see drawable but not xml and java files, so continue. If you don’t see the extensions go through check the configuration

Step 2: Now extract this zip apk file in the same folder. Now download dex2jar from this link and extract it to the same folder. Now open command prompt and change directory to that folder. Then write dex2jar classes.dex and press enter. Now you get classes.dex.dex2jar file in the same folder.Then download java decompiler
And now double click on jd-gui and click on open file. Then open classes.dex.dex2jar file from that folder. Now you get class files and save all these class files (click on file then click "save all sources" in jd-gui) by src name. Extract that zip file (classes_dex2jar.src.zip) and you will get all java files of the application.At this stage you get java source but the xml files are still unreadable, so continue.

Step 3:
Now open another new folder and put these filesput .apk file which you want to decode download Apktool for windows v1.x And Apktool
install window using google and put in the same folder download framework-res.apk file using google and put in the same folder (Not all apk file need framework-res.apk file)

Open a command window

Navigate to the root directory of APKtool and type the following command: apktool if framework-res.apk.Above command should result in Framework installed ....

apktool d "appName".apk ("appName" denotes application which you want to decode) now you get a file folder in that folder and now you can easily read xml files also.

Step 4: Finally we got the res/ as well as java code of project which is our target at starting.P.S. If you are not able to get res folder by above steps please do install new apktool

Is Java 1.7 installed? Install Apktool 2.x
Is Java 1.6 or higher installed? Install Apktool 1.x
Enjoy and happy coding

Share this:

CONVERSATION

0 comments:

Post a Comment