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 calledtes.apkThe apK file is changed totes.zipFile and unzip toTes folderIn the
  • 2, open thetesFolder and find itclasses.dexThis file, this file is the source code, and of course you can’t see it right now.
  • 3. Then copyclasses.dexThis file is decompressed aboveDex2jar - 2.0. ZipIn this folder, as shown below

  • 4. Specify a path toDex2jar - 2.0 -In this folder, compileclasses.dexThis file, the command I’m executing here isd2j-dex2jar.bat classes.dexRemember the space. And then you getclasses-dex2jar.jarFiles and a.zipThe file, hereclasses-dex2jar.jarThat’s what we’re going to need.
  • 5. Double-click to open itJd - GUI - 1.6.6. JarAnd will beclasses-dex2jar.jardragJd - GUI - 1.6.6. JarYou 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