Setting up the environment for decompiling Android apps on Mac OS

Setting up the environment for decompiling Android apps on Mac OS

[[144520]]

Often, for the purpose of learning or security testing, we need to decompile the installation files of the Android app to view the source code. Let's build a decompilation environment under Mac OS.

Installation Environment

Create a basic folder

mkdir -p ~/study/apkkiller/soft/bin

mkdir -p ~/study/apkkiller/soft/src

mkdir -p ~/study/apkkiller/output/

The installation file of andorid app is apk package. To decompile apk file, you need to download apktool and dex2jar, both of which are hosted on google code:

http://code.google.com/p/android-apktool/

http://code.google.com/p/dex2jar/

Find the download address from the above two pages. Here we find the download address of apktool1.5.2 and dex2jar-0.0.9.15:

cd ~/study/apkkiller/soft/src

wget http://android-apktool.googlecode.com/files/apktool1.5.2.tar.bz2

wget http://dex2jar.googlecode.com/files/dex2jar-0.0.9.15.zip

The decompressed files are stored in the following directory:

~/study/apkkiller/soft/src/apktool1.5.2

~/study/apkkiller/soft/src/dex2jar-0.0.9.15

For ease of use, create two soft links:

ln -s ~/study/apkkiller/soft/src/apktool1.5.2/apktool.jar ~/study/apkkiller/soft/bin/apktool

ln -s ~/study/apkkiller/soft/src/dex2jar-0.0.9.15/dex2jar.sh ~/study/apkkiller/soft/bin/dex2jar

Test decompilation environment

Let's start decompiling our test apk file to see if the environment can run normally

  1. cd ~/study/apkkiller
  2. mkdir -p ~/study/apkkiller/output/test/source
  3. mkdir -p ~/study/apkkiller/output/test/result
  4.  
  5. cp ./test.apk ./output/test/source/test.zip
  6. unzip ./output/test/source/test.zip -d ./output/test/source/test
  7.  
  8. cp ./output/test/source/test/classes.dex ./output/test/source/classes.dex
  9. ~/study/apkkiller/soft/bin/dex2jar ./output/test/source/classes.dex
  10. # output ./output/test/source/classes_dex2jar.jar

To view the decompiled files, you can download the jd-gui tool and open the ./output/test/source/classes_dex2jar.jar file generated above. This tool can export all the source code packages. Download jd-gui from the following address:

http://jd.benow.ca/

http://jd.benow.ca/jd-gui/downloads/jd-gui-0.3.5.osx.i686.dmg

The apk resource files are stored in the folder ./output/test/source/test that we unzipped above. There are many xml files in it, but they are encrypted and cannot be viewed directly. At this time, you need to use the apktool tool:

java -jar ~/study/apkkiller/soft/bin/apktool d ./test.apk ./output/test/source/test_resource

Merge the exported source code and resource files to get the result we want.

<<:  Learn more about iOS 9 every day 5: Xcode Code Coverage Tools

>>:  Is heavy H5 really good?

Recommend

Many reasons to tell you that the iPhone 4s is still good enough

Speaking of the pinnacle of smartphone history, A...

How to create a hit on Douyin?

In July this year, the official TikTok revealed a...

Experience the first version of Android 9.0: Like these 6 changes

A few days ago, Google quietly released the lates...

Lao Duan talks about OTT: 8 common misunderstandings about Internet TV

Duan Youqiao, an artist of iQiyi. From an Interne...

iOS 9.1 version update: fix bugs and make details more intelligent

[[152890]] iOS 9.1 System Update Notes Apple upda...

Objective-C and the Runtime: Why is this the case?

[[148060]] I am very happy to write my own unders...

Ultra-portable display Slidenjoy trial notebook external perfect match

For laptop users, multi-screen configuration is b...

Review: The ups and downs of a marketing campaign

A marketing campaign, from planning to implementa...

Event Operations: Grasp these 5 points to increase online event participation

A popular online event can not only directly brin...

The embarrassment of Google’s smart hardware: bad luck, or a cycle of fate?

Do you still remember Google Glass ? This smart h...

Is ocean exploration really that difficult?

With the continuous development of science and te...

GoldWave Audio Processing Video Tutorial 10 Lessons

GoldWave Audio Processing Video Tutorial 10 Lesso...