Opening part:
"For software developers, code security protection is also one of the most important factors. However, Google Android chose Java Dalvik VM to easily crack and modify its programs, first, the APK file is actually a zip package. We can modify the zip extension to see the internal file structure, which is similar to the jar compression format of Sun javame, however, the binary code on Android is compiled into the DEX bytecode, and all java files are eventually compiled into the file. As managed code, since the virtual machine can recognize it, then we can easily decompile. All the class calls and methods involved are embodied in it. As for logic execution, you can view them through real-time debugging. Of course, this requires some tracing programs we have compiled. Google sets permissions on the Android Market to protect the security of the app-Private folder. However, we can still get the required files by using the system that modifies the value. "
From: http://www.cnblogs.com/huyipeng/archive/2010/07/25/1784679.html
After several days, Android users know that there are two parts of files to be processed after extracting the APK file. One is an XML file and the other is a DEX file (. dex), we can. dex file. class, use the latter to get the long-awaited Java file.
The following code decompile these three formats of files;
1. there are two methods for parsing XML files: apktool (recommended) and axmlprinter2.jar; <br/> 2. from Dex to class dex2jar. bat, achieving decompilation; recognized as strong; <br/> 3. the methods from class to Java should be more diversified, because only the decompiled code can be viewed: JD-Gui (recommended) and jodeclipse (Eclipse plug-in of jode ), jadclipse (Eclipse plug-in of JAD ). <Br/>
Let's give a general introduction to this process:
1. First, change the APK file name to .zip, and decompress the class. Dex file, which is the Java file compiled and then packaged by the DX tool. <Br/> 2. Copy class. Dex to the directory where dex2jar. bat is located. Run dex2jar. Bat class. Dex to generate classes. Dex. dex2jar. jar. <Br/> 3. Run JD-GUI tools (green software, easy to use software !), Open the JAR File above and you will see the Java source code. </P> <p>
If you can complete the above steps, you can ignore the detailed descriptions of these software!
The software is further divided into three steps (Steps A (A1, A2), B, c (C1, C2, C3), and ABC respectively ):
A1. apktool:
It is usually used to generate program source code and images, xml configuration, language resources, and other files. After modifying images, language resources, and other files, we can compile and package them into an APK. After signing, we can install the local/modified APK on the mobile phone. Support for Linux and Windows
Installation steps:
1. Install the Java environment (JDK 1.6 is officially recommended );
2. Download apktool. jar: http://code.google.com/p/android-apktool/downloads/list
Click to download apktool1.3.2.tar.bz2 and apktool-install-windows-2.2_r01-3.tar.bz2 (this is not necessarily the case, but it is best to select the latest version !)
3.decompress apktool1.3.2.tar.bz2 to obtain apktool. jar;
Decompress apktool-install-windows.zip to any folder, and import apktool. jar into this folder (some people say that all are directly merged into C:/Windows, the same way );
(Currently, this folder contains three files: apktool. Jar/apktool. BAT/aapt.exe)
4.20.execute the command line to decompress the folder obtained from apktool-install-windows-2.2_r01-3.tar.bz2, and enter apktool to test whether the installation is successful;
After the installation is successful, the decompilation process starts as follows:
1. apktool D (file to be decompiled) (Output Folder) <br/> example: apktool D xxx.apk (target folder) decompile my.apk to the folder myapk <br/> 2.apk tool B (target folder) <br/> re-create the APK from the target folder. The generated APK is in the "target folder"/distfolder and named out.apk. <Br/>
This out.apk does not have a signature, so it cannot be directly installed into the mobile phone. For the signature tools and methods, see http://www.hiapk.com/bbs/thread-21261-1.html. The APK obtained after the signature can be installed in the mobile phone.
A2. axmlprinter2.jar
Put it in the android-sdk-windows-1.5_r3/Tools Folder
Run cmd, go to the tools directory, and run Java-jar axmlprinter2.jar main. xml> main.txt;
Then we get the decompiled XML file;
After so much experience, we only get part of the layout file and resource file, but the Java file is still "half-masked ".
Next, let's set off her red cover:
B. dex2jar
Download: http://code.google.com/p/dex2jar/downloads/list
Method:
1. First find classes. Dex in the Android software installation package (decompress it );
It is compiled by a Java file and packaged by the DX tool, so now we use the two tools mentioned above to export the Java source file in reverse direction.
2. Copy classes. Dex to the directory where dex2jar. bat is located;
In command line mode, locate the directory where dex2jar. bat is located and run dex2jar. Bat classes. Dex.
, Generate classes. Dex. dex2jar. jar, half done!
C1. JD-GUI
Download: http://java.decompiler.free.fr /? Q = jdgui
Easy to use, directly decompress get JD-GUI, use it to open the jar file above, file --> Save jar source, you can see the dream of Java source code;
We can also decompress the JAR file obtained by step B to obtain the class file. Here, we will use jodeclipse and jadclipse;
C2. jodeclipse--- Eclipse plug-in of jode
C3. jadclipse--- Eclipse plug-in of Jad
For the installation of these two Eclipse plug-ins, see the following link:
Http://tgyd2006.javaeye.com/blog/553061
(C4. some friends mentioned that DJ Java decompiler has never been used. You can try it !)
However, some people have raised this question:
The Jad plug-in has not been successfully installed since eclipse was upgraded to 3.3. I have read many articles on the Internet and installed it in previous versions, 3.3 currently, the plug-in installation method through eclipse software update is no longer available.
The solution is as follows:
1. Slave;
2. Download jadclipse_3.0.jar from http://nchc.dl.sourceforge.net/s... jadclipse_3.0.jar and copy it to the eclipse plugins directory;
3. Start or restart eclipse and modify
Path to decompiler such as: D:/Eric/jadnt158/jad.exe(directory after jadnt158.zip extraction );
4. For Windows-> perference-> General-> editors-> File Associations, change "*. Class" to "jadclipse class File Viewer" by default"
After that, press CTRL in the Java class and click the class to see the source code after its Jad decompilation;
If the installation is ineffective, you can delete/configuration/org. Eclipse. Update under the eclipse main directory, and then execute eclipse-clean to try again.
Finally, you can combine the obtained Java file with the obtained XML file to obtain a relatively complete APK source code. However, some additional packages are not compiled.
However, this step is enough for learning and our goal is achieved!
Some people may say that the program can use obfuscators to disrupt the code, but a saying about obfuscators just came out on the Internet:
"The code using the obfuscators generally removes all comments and changes the variable name, method name, and class name to meaningless names. After decompilation, it is generally changed to a, B, c ,... such a name can only be understood a little bit, and the method of renaming eclipse can be used to change the relevant names at one time to meaningful names."
Therefore, it is best to compress the key code into the. So library! Some people don't have to wear underpants!
Thank you for the following:
Http://blog.csdn.net/Android_Tutor/archive/2010/07/09/5724435.aspx
Http://www.cnblogs.com/huyipeng/archive/2010/07/25/1784679.html
You can also pay attention to the above two articles, using different methods (dexdump, baksmali. jar, smali. Jar), the results are also good!
If you have any skills to prevent decompilation, leave a message to inform us that all programmers will thank you!