preface
Today, I saw a good APK, but I don’t know exactly how to implement it, so I want to see others’ code with a learning attitude. Again think oneself not quite can decompile the knowledge of respect, after some operation, finally gain something. So here comes today’s article, which I want to record in case I forget how to do it.
The preparatory work
- Decompiler related tools (Baidu network disk)
Link: pan.baidu.com/s/1xSJstHwH… Extraction code: UKZW
Jar 2, dex2jar-2.0.zip 3, JD-gui.jar
- The official address
1. Apktool 2, Dex2JAR 3, JD-GUI
Step 1: Unpack and configure the tools
-
1. Create a local apkTool folder and put all the tools you have downloaded into this folder
-
2. Create an apktool.bat file in apktool
@echo off setlocal set BASENAME=apktool_ chcp 65001 2>nul >nul
set java_exe=java.exe
if defined JAVA_HOME ( set java_exe=”%JAVA_HOME%\bin\java.exe” )
rem Find the highest version .jar available in the same directory as the script setlocal EnableDelayedExpansion pushd “%~dp0” if exist apktool.jar ( set BASENAME=apktool goto skipversioned ) set max=0 for /f “tokens=1* delims=-_.0” %%A in (‘dir /b /a-d %BASENAME%*.jar’) do if %%~B gtr ! max! set max=%%~nB :skipversioned popd setlocal DisableDelayedExpansion
rem Find out if the commandline is a parameterless .jar or directory, For fast unpack/repack if “%~1″==”” goto load if not “%~2″==”” goto load set ATTR=%~a1 if “%ATTR:~0,1%”==”d” (rem Directory, rebuild set fastCommand=b) if “%ATTR:~0,1%”==”-” if “%~x1″==”.apk” (rem apk file, unpack set fastCommand=d )
:load %java_exe% -jar -Duser.language=en -Dfile.encoding=UTF8 “%~dp0%BASENAME%%max%.jar” %fastCommand% %*
rem Pause when ran non interactively for /f “tokens=2” %%# in (“%cmdcmdline%”) do if /i “%%#” equ “/c” pause
Note: __of course, you do not have to use the above content, the baidu web disk provided above already contains the apk.bat file
- 3. Unzip the dex2jar-2.0.zip folder
Step 2: Modify the apK suffix to be decompiled and decompress it
- 1. Suppose I have a name called
tes.apk
The apK file is changed totes.zip
File and unzip toTes folder
In the - 2, open the
tes
Folder and find itclasses.dex
This file, this file is the source code, and of course you can’t see it right now. - 3. Then copy
classes.dex
This file is decompressed aboveDex2jar - 2.0. Zip
In this folder, as shown below
- 4. Specify a path to
Dex2jar - 2.0 -
In this folder, compileclasses.dex
This file, the command I’m executing here isd2j-dex2jar.bat classes.dex
Remember the space. And then you getclasses-dex2jar.jar
Files and a.zip
The file, hereclasses-dex2jar.jar
That’s what we’re going to need. - 5. Double-click to open it
Jd - GUI - 1.6.6. Jar
And will beclasses-dex2jar.jar
dragJd - GUI - 1.6.6. Jar
You can see the source code. But if it’s obfuscated and you can only see the obfuscated code, it’s not very clear how to unobfuscate the obfuscated code, if you’re clear you’re welcome to obfuscate.
The last
After writing so much, I feel like I’ve only scratched the surface of decompilation, and I can’t do anything about confusing code, so keep learning and keep learning. If you are interested in decompilation or have your own opinion, please feel free to join us at 493180098