Android: Decompile apk to step on the pit/apktool/dex2jar/JDGUI

Description of Requirement

I want to decompile the apk file, and I found this blog: Android APK decompilation is so simple and detailed (with attached photos) , which is very useful for reference~ But the tool download links in it are all 404, and this miscellaneous fish is in the process of actual operation There is also a problem of billions of dots and dots, so I coded this blog to record it~
Click here for the toolkit: myDemos , branch: deApk
Toolkit directory structure

Use & step on the pit

According to the Android APK decompilation is so simple and detailed explanation (attached photos) this blog, the three tools have a clear division of labor: apktool is used to decompile static resources such as layouts and pictures in the apk, dex2jar is used to decompile the class files in the apk, and JDGUI It is used to view the compilation result of dex2jar - the source code of .class in the jar package.
The following are the details of the use and stepping on these three tools:

apktool

First record the operation process, copy the apk file that needs to be decompiled to the apktool folder:
myApk. apk
enter "cmd" in the address bar of the explorer and press Enter, and you can open the command line in the current folder (no more details below):
Open the command line in the current folder
Execute the following command:

apktool d -f apk名称.apk

apktool decompilation result
The generated apk folder with the same name is the result of decompilation~the output of the command line can be without error.

// The following is the personal record of stepping on the pit ——————————————————————————————————————————————————————————— ————

Unsupported major.minor version 51.0

To run apktool, you first need to build a java environment, and it is best to install a higher version of jdk. For example, this miscellaneous fish installed jdk1.6 at the beginning, and reported an error "Unsupported major.minor version 51.0", and did not report again after modifying jdk1.9thisWrong~ (Let’s read it briefly here: Later, I compiled dex2jar locally, and the 1.9 version was too high to report an error, and the 1.6 version was too low to report an error. Finally, I registered and downloaded jdk1.8 on the oracle official website, and re-organized the environment to be OK)So it is recommended to use jdk1.8 directly~
I originally wanted to upload jdk to git, but since it exceeded the limit of 100M for a single file, I can only troublesome friends in need to download it by myself~
oracle-jdk1.8 download , if you don’t have an account, just go through the registration process and fill in some information ;
If you are not familiar with the configuration of java environment variables, click here: Configuration and detailed explanation of java environment variables (the most detailed tutorial in the whole network)

Exception in thread “main” brut.androlib.AndrolibException: Could not decode …

The error report caused by the java version problem has been solved, take a closer look: there is still an error report! Du Niang gave a solution: download a higher version of apktool.jar from apktool and replace it~ (the original link for reference is at the end of the article)

dex2jar

This tool is used to decompile .class files, which can be said to be the most troublesome step in the actual operation of this miscellaneous fish... because the final solution to the error report is to directly pull the source code from the gitee warehouse: dex2jar, and according to README.md After compiling locally, the toolkit (dex-tools-2.2) is generated and used, and the various previous error reports do not feel necessary to elaborate. Sometimes it feels like one path is not going to work, maybe you should try to change your thinking and find another way!
In general, the operation process is similar to apktool, first copy the apk file to be decompiled to the dex-tools-2.2 folder, and then execute the following command in this folder:

d2j-dex2jar.bat -f apk名称.apk

PS: The scripts in dex-tools-2.2 have both .bat and .sh formats, and should also be used under Linux (reasonable guess). The
dex2jar decompilation result
generated apk with the same name as the dex2jar.jar file is the result of decompilation ~ command line The output result can be without error.

JDGUI

This is the single most worry-free of the three tools! T_T is easy to use, no problem~
Double-click to run jd-gui.exe under the JDGUI folder, drag the jar file generated by dex2jar into the graphical interface, or open the jar file by operating on the interface.
Double-click to run jd-gui.exe

reference documents

[1] Android APK decompilation is so simple and detailed (with attached photos)
[2] Solve the pit----Unsupported major.minor version 51.0
[3] Android reverse: apktool decompilation reports an error Exception in thread “main” brut.androlib .AndrolibException: Could not decode ...

Guess you like

Origin blog.csdn.net/qq_36604536/article/details/129205848