let's talk about APK's anti-compilation process in detail today, but I haven't been completely clear about it before.
First, the preparatory work
The first thing to do is to prepare three tools for anti-compilation. All three tools can be downloaded by Baidu. Is the three tools shown.
These three tools have their respective functions:
(1) The Apktool tool is used to decompile the files under Res in the APK, i.e. all XML files (including manifest.xml).
(2) The Dex2jar tool is used to decompile the. class file in the APK, which is all Java code for the Android project.
(3) The jd-gui-0.3.3 tool is not used to decompile, it is used to view the files that are obtained by using Dex2jar decompile. You can be happy like this.
Check out the Java code you want to see.
+++++++++++++++++++++ I'm a split line +++++++++++++++++++++++++++++++++++
Of course, there are two of these tools that are compressed and need to be decompressed. Then put all the tools in one place. Like I put it.
"E:\APK Anti-compilation tool" under this folder. The contents of this folder are as follows:
+++++++++++++++++++++++ I'm a split line +++++++++++++++++++++++++++++++++
All right, the basic tools are ready. Then the apk that you need to decompile is also ready, and then unzip it with 360. For example
I'm going to decompile a file named mycode.apk, after extracting it, the whole is as follows:
This file I put in the "E:\apk file" under this directory, "APK file" is the name of the folder.
Let's take a look at what's in the "Mycode" folder after decompression. As follows:
Found a familiar "res" folder, this file can view Mycode this Android project's resource files, but unfortunately
In addition to a few pictures, you can see that other XML files are garbled (some can't even see the picture). and the Classes.dex file below
Contains all the Java code for this project, one of our main Mycode objects.
Well, there's nothing good about this folder. Look on it, and we'll start to decompile it!!
Second, the Anti-compilation tour
I'm using a Windows system. So open the cmd window under Windows. Let's start by explaining how to use CMD to enter a directory.
It's enough to be familiar with two directories:
(1) Direct input "drive letter:" Will go directly to a disk. For example, enter the E-drive and enter "E:" directly.
(2) then the CD command, you can enter a directory of the current disk. For example, I want to enter the "APK Anti-compilation Tool" Under the E-disk folder,
it can be so Enter the CD \apk Anti-compilation tool. where "CD \" means the root directory of the current drive letter is entered.
It's enough to know the two basic commands. The following is the real anti-compilation it!
++++++++++++++++++++++ Ornate Split Line ++++++++++++++++++++++++++++++++
first go to the Anti-compilation tool directory and enter it as follows in CMD:
then use the following command to decompile, as follows:
This completes the first anti-compilation, the results of the anti-compilation where then? In the folder where Apktool is located, there will be a file named "Mycode".
folder, this is the result of anti-compilation!
Let's take a look at the anti-compilation syntax, and then look at the results of the anti-compilation. I'm enclosing the lines in a different line, the red line.
There's nothing to say, see what your Apktool full name is, follow the input, and the Yellow line D represents decode, the parsed command. The most important thing is that
The content in the Blue line is the APK object you want to decompile, so be sure to write down the full path name! When this statement executes correctly, it compiles
It worked.
OK, let's look at the results of the anti-compilation, the folder where Apktool is "E:\APK Anti-compilation Tool" (mine is like this). as follows:
Found one more Mycode folder. This is the result of the anti-compilation, look inside the content, as follows:
Original folder is stored in the source code, the inside of the things are still a bunch of garbled. What we need is res this folder, which contains all the
XML file and resource picture, at this time are not garbled, casually use Notepad to open can be viewed. and the manifest file below can also be used
Notepad open to see, this time is not garbled. In this way, we complete the mycode.apk of the resource file for this file.
++++++++++++++++++++++ Gorgeous split ++++++++++++++++++++++++++++++++
We continue compiling, looking at the resource file is not enough, but also want to look at the Java code. It's going to take two other tools, Dex2jar and
Jd-gui. using these two tools, as with Apktool, you also need to switch to the directory where they are in cmd ! Because I put them
with Apktool placed in a directory, so there's no need to switch around here to save you. Continue with the anti-compilation.
Do you remember that there is a Classes.dex file under the folder you unzipped in front of mycode.apk? Right! That's it, for convenience, copy it to
Below the folder where Dex2jar is located, as follows:
Immediately above, enter the following command in CMD:
This is the easy way to decompile successfully. The result of the decompile is to generate a Classes-dex2jar file under the file where the Dex2jar is located .
As follows:
This classes-dex2jar includes all the Java code we want. How do you see that? Use Jd-gui Tools! such as:
After running the Jd-gui tool, select Open File and open the Classes-dex2jar file. As follows:
Specific view code I will not post, protect people's code! Anyway come to this step, mycode.apk inside all the things, XML resources
Files as well as Java code are available to view the learning!
Android APK anti-compilation