Android decompiler sorting details

Programmers who develop Android hate decompilation and don't want their labor achievements to be the of others. The main purpose of decompilation is to learn. It is immoral to use decompilation for related Sinicization or modification.

After decompressing the APK file, there are two parts of files that need to be processed, one is an XML file and the other is a DEX file (. DEX). We can get. Class from the. DEX file and use the latter to get the java file we have coveted for a long time.

The following decompiles the files of these three formats respectively;

1. There are generally two ways to parse XML files: apktool (recommended) and axmlprinter2.jar;

2. From DEX to dex2jar.bat, decompilation is realized; Recognized strong;

3. The way from class to Java should be more diversified, because it only looks at the decompiled Code: JD GUI (recommended), jodeclipse (Jode's eclipse plug-in), jadclipse (JAD's eclipse plug-in).

The process is roughly as follows:

1. First rename the APK file to. Zip, and then unzip the class.dex file, which is compiled from Java file and packaged by DX tool.

2. Copy class.dex to the directory where dex2jar.bat is located. Run dex2jar.bat class.dex to generate classes.dex.dex2jar.jar.

3. Run jd-gui tool (green software, easy-to-use software!), open the jar file above, and you can see the Java source code.

These softwares are introduced in detail (steps a (divided into A1 and A2), B and C (divided into C1, C2 and C3) and ABC represent three different steps respectively):

A1. apktool:

It is usually used to generate program source code and images, XML configuration, language resources and other files. After we modify the files such as pictures and language resources, we can compile and package them into APK. After signing, the localized / modified APK can be installed on the mobile phone. Support working under Linux and windows

Installation steps:

1. Install Java environment (official recommendation JDK 1.6);

2.apktool.jar: http://www.jb51.net/softs/539819.html

Click apktool 1.3.2.tar.bz2 and apktool-install-windows-2.2_ R01-3.tar.bz2 (not necessarily this, but you'd better choose the latest version!)

3. Unzip apktool 1.3.2.tar.bz2 to get apktool.jar;

Unzip apktool-install-windows.zip to any folder and copy apktool.jar into this folder (some people say that it is the same as directly copying all apktool.jar into C: / windows);

(currently, there are three files in this folder: apktool.jar/apktool.bat/aapt.exe)

4. From the CMD command line, go to apktool-install-windows-2.2_ R01-3.tar.bz2, enter apktool to test whether the installation is successful;

After the installation is successful, the decompilation process begins as follows:

1. Apktool D (file to decompile) (output folder)

For example, apktool D xxx.apk (target folder) decompiles geek.apk into the folder test

2. Apktool B (target folder)

Rebuild the APK from the target folder. The generated APK is in the target folder \ dist folder, called out.apk.

The out.apk is unsigned, so it can't be directly installed into the mobile phone.

Not here. The APK obtained after signing can be installed into the mobile phone.

A2. AXMLPrinter2.jar

Put it in android-sdk-windows-1.5_ R3 \ tools folder

Run CMD, enter the tools directory, and run Java - jar axmlprinter2.jar main.xml > main.txt;

So we get the decompiled XML file;

After so much experience, we only get some layout files and resource files, but java files are still "half covered with Pipa".

Now, let's lift her red cap:

B. dex2jar: http://www.jb51.net/softs/353141.html

method:

1. First find the classes.dex in the Android Software installation package (extracted);

It is compiled from java files and packaged by DX tools, so now we use the two tools mentioned above to export java source files in the opposite direction

2. Copy classes.dex to the directory where dex2jar.bat is located;

In the command line mode, locate the directory where dex2jar.bat is located, run dex2jar.bat classes.dex, and generate classes.dex.dex2jar.jar. It is half successful!

C1. JD-GUI: http://www.jb51.net/softs/66904.html

It is easy to use. You can directly unzip the jd-gui, open the above jar file with it, file -- > Save jar source, and you can see the coveted java source code; We can also extract the jar file obtained in step B to obtain the class file. Here, we will use jodeclipse and jadclipse;

Finally, combining the obtained java file and the obtained XML file can get an Android project, and a relatively complete APK source code can be obtained; But there are some additional packages that have not been compiled.

But this step is enough for learning, and our goal will be achieved!

You can also pay attention to these two articles. The different methods used (dexdump, baksmali.jar, SmalI. Jar) have also achieved good results:

https://www.oudahe.com/p/42766/

https://www.oudahe.com/p/42767/

Some people will say that programs can use obfuscators to disrupt code, but a statement about obfuscators just seen on the Internet:

"Generally, the code using the scrambler is to remove all comments and change the variable name, method name and class name into some meaningless names. After decompilation, it generally becomes a, B, C,... Such names, which can only be understood a little bit. Then, use the eclipse renaming method to change the relevant names into meaningful names at one time."

Therefore, you'd better make your key code into. So library!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>