Android Anti-compilation tool summary

Source: Internet
Author: User
Tags java decompiler

Order:
The main purpose of summarizing anti-compilation is to learn. The use of anti-compilation related to the Chinese or modified, are immoral!

As we all know, after extracting the APK file there are two parts of the file that need to be processed, one is an XML file and the other is a Dex file (. dex), which we can get. Class from the. dex file, using the latter to get a long-coveted Java file.
The following respectively for the three format of the file for anti-compilation processing;
1. The parsing of XML files is usually done in two ways: Apktool (recommended) and Axmlprinter2.jar;
2. From DEX to class recognition Dex2jar.bat, to achieve anti-compilation;
3. The class-to-Java approach is more diversified because it's just looking at the post-compilation code: Jd-gui (Recommended), Jodeclipse (Jode's eclipse plugin), Jadclipse (Jad's eclipse plugin).
Let's make a general introduction:
1. First rename the apk file to. zip, then unzip the Class.dex file, which is the Java file compiled and then packaged by the DX tool.
2. Copy the Class.dex to the directory where the Dex2jar.bat resides. Run Dex2jar.bat class.dex to generate Classes.dex.dex2jar.jar.
3. Run the Jd-gui tool (green software, easy to use software!) ), open the jar file above to see the Java source code.
If the above steps can be self-completed, then the following content can be ignored!

These few software are detailed separately to introduce (with step A (A1,A2), B, C (sub-C1,C2,C3), ABC represents three different steps respectively):
A1. Apktool:
Typically used to generate the program's source code and pictures, XML configuration, language resources, and other files. After we have modified the files such as pictures and language resources, we can then compile them into an apk, which is the localized/modified version of the APK that the phone can install. Supports Linux, Windows work
Installation steps:
1. Install the Java environment (officially recommended JDK 1.6);
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 (not necessarily this, but it is best to choose the latest version of it!). )
3. Decompression apktool1.3.2.tar.bz2 get Apktool.jar;
Unzip apktool-install-windows.zip to any folder, copy the Apktool.jar into this folder (some people say it is all directly copied into the C:/windows, the same);
(There are currently three files in this folder: Apktool.jar/apktool.bat/aapt.exe)
4.cmd command line into the extracted apktool-install-windows-2.2_r01-3.tar.bz2 folder, enter the Apktool test whether the installation is successful;
After the installation succeeds, the following starts the anti-compilation process:
1.apktool d (file to decompile) (output folder)
Such as:
Apktool d xxx.apk (destination folder) decompile geek.apk to folder test
2.apktool B (destination folder)
To rebuild the APK from the target folder, the generated apk is in the "Destination folder" \dist folder, called out.apk.
This out.apk is not signed, so it cannot be loaded directly into the phone. Signature tools and methods see http://www.hiapk.com/bbs/thread-21261-1-1.html, here's not the point. After signing the APK, you can put it on your phone.
A2. Axmlprinter2.jar
Put it in the Android-sdk-windows-1.5_r3\tools folder
Run cmd, go to Tools directory, run Java-jar Axmlprinter2.jar main.xml > main.txt;
So we get the anti-compiled XML file;
After so much, all we get is a partial layout file and resource file, but the Java file is still a "semi-faceted".

Below, let's lift her red hijab to:

B. Dex2jar
Download: http://code.google.com/p/dex2jar/downloads/list
Method:
1. First find the Classes.dex (extracted) in the Android software installation package;
It is the Java file compiled and then packaged by the DX tool, so now we use the above mentioned 2 tools to export Java source files in reverse direction
2. Copy the Classes.dex to the directory where the Dex2jar.bat resides;
Navigate to the directory where Dex2jar.bat is located in command-line mode and run Dex2jar.bat Classes.dex
, generate Classes.dex.dex2jar.jar, half successful!

C1. Jd-gui
Download: Http://java.decompiler.free.fr/?q=jdgui
Easy to use, direct decompression to get Jd-gui, with it to open the jar file above, File-->save jar source, you can see the Dream Java source code;
We can also extract the jar file from the B-step to get the class file, here we will use Jodeclipse and jadclipse;
C2. Jodeclipse---Jode's eclipse plugin
C3. Jadclipse---jad's eclipse plugin
The following links are visible about the installation of these two eclipse plugins:
http://tgyd2006.javaeye.com/blog/553061
(C4. And a friend mentioned DJ Java Decompiler, no use, you can try!) )
However, the question was also raised:
Since eclipse upgraded to 3.3 Jad plugin has not been successfully installed on the Web read a lot of articles are also the previous version of the installation method, 3.3 currently through Eclipse's software update plugin installation mode has been exhausted.
Here's how to fix it:
1. Download the latest jad from http://www.kpdus.com/jad.html#download address, I am currently downloading jadnt158.zip;
2. Download the Jadclipse_3.3.0.jar from the http://nchc.dl.sourceforge.net/s jadclipse_3.3.0.jar address and copy it to the plugins directory of Eclipse;
3. Start or restart Eclipse, modify the Jadclipse under Windows-Preferences, Java-
Path to Decompiler such as: D:\eric\jadnt158\jad.exe (jadnt158.zip extracted directory);
4.Windows, Perference, Editors, general, and file associations modify the "*.class" default associated editor for "Jadclipse class file V Iewer "
Finished, then in the Java Class Ctrl-click on the class can see it jad anti-compiled source code;
If you find that the installation has no effect, you can delete the \configuration\org.eclipse.update in the Eclipse home directory and then perform Eclipse-clean test

Finally, the resulting Java file and the resulting XML file combination can be a Android project, you can get a relatively complete apk source code, but also some extra packages are not compiled.
But to do this step is enough for learning, our purpose is achieved!
You can also pay attention to these two articles, using different methods (Dexdump, Baksmali.jar, Smali.jar), but the effect is also good:
Http://blog.csdn.net/Android_Tutor/archive/2010/07/09/5724435.aspx
Http://www.cnblogs.com/huyipeng/archive/2010/07/25/1784679.html
Some people would say that the program can use the obfuscation to disrupt the code, but just from the internet to see a confusion about the idea:
"The code for the mixer is generally to remove all annotations and change the variable name, method name, and class name into meaningless names." After the anti-compilation generally become a, B, C,... Such a name, only a little bit to understand, and then use the eclipse's renaming method, a one-time bar related to the name changed to a meaningful name. ”
So, everyone's key code is best to play. So Library Bar! You don't have to wear panties for some people!

Android Anti-compilation tool summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.