banner
lca

lca

真正的不自由,是在自己的心中设下牢笼。

How to decompile an APK on macOS to view its source code.

Tools Needed

Check apktool version

 apktool --version

image

Install dex2jar on Mac

 brew install dex2jar

Step 1: Decompiling APK file with Apktool

 apktool d xxx.apk

image

From apktool, you can view some source code files of the apk. Decompiling in this way only allows you to view smali source code.

image.png

Step 2: Decompiling dex to jar with dex2jar

Change the file extension of the apk file to zip.

image

Extract the zip file to get the file with dex extension, then use dex2jar to convert the dex file to jar file.

 d2j-dex2jar classes.dex

image

Alternatively, you can directly download dex2jar, then execute

sh d2j-dex2jar.sh classes.dex

If the compilation fails and shows a version issue, you need to modify the version in the dex file header.

image

The magic field in the dex file header is an 8-byte fixed character array that represents the type and version of the dex file. The following are the magic field contents in the headers of different versions of dex files:

• Android 1.0 and 1.1 versions: dex 035
• Android 1.5 version: dex 035
• Android 1.6 version: dex 036
• Android 2.0 to 2.3.7 versions: dex 035
• Android 3.0 to 3.2.6 versions: dex 036
• Android 4.0 to 4.0.4 versions: dex 035
• Android 4.1 to 4.4.4 versions: dex 036
• Android 5.0 to 6.0.1 versions: dex 037
• Android 7.0 to 7.1.2 versions: dex 038
• Android 8.0 and above versions: dex 039

After obtaining the jar file, you can use jd-gui to view the jar code.

Step 3: Viewing jar code with JD-GUI

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.