反编译APK的实现

1》Installation for Apktool
我的是 Mac系统,其他系统的可参考官网Install Instructions.

  • Mac OS X:
    1. Download Mac wrapper script (Right click, Save Link As apktool)
    2. Download apktool-2 (find newest here)
    3. Rename downloaded jar to apktool.jar
    4. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)
    5. Make sure both files are executable (chmod +x)
    6. Try running apktool via cli

2》遇到的问题一

$ chmod +x
Password:
usage: chmod [-fhv] [-R [-H | -L | -P]] [-a | +a | =a [i][# [ n]]] mode|entry file …
chmod [-fhv] [-R [-H | -L | -P]] [-E | -C | -N | -i | -I] file …

解决方法:

1
2
$ chmod +x /Users/apktool.jar 
$ chmod +x /Users/apktool.txt

3》遇到问题二

-bash: /Users/apktool.txt: Permission denied
-bash: /Users/apktool: No such file or directory

原因:目录错了/Users/local/bin/和/usr/local/bin/是不一样的。

解决方法:
Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)

1
2
3
4
5
$ cd  /usr/local/bin/
$ mv apktool.txt apktool
$ chmod +x apktool.jar
$ chmod +x apktool
$ apktool -v

4》反编译 facebook apk

1
2
$ cd /Users/emily/Documents/MyTool    //apk 文件目录
MyTool emily$ apktool d facebook-156-0-0-36-100.apk

在相同目录下看到 facebook 文件夹,里面有源码文件。

5》完整正确流程

  • Mac OS X:
  1. Download Mac wrapper script (Right click, Save Link As apktool), 命名为 apktool,存储格式为所有文件(系统默认是txt)

    1. Download apktool-2 (find newest here)
  2. Rename downloaded jar to apktool.jar

  3. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)

  4. Make sure both files are executable (chmod +x)
    打开 Terminal

1
2
3
4
5
6
7
$ cd /usr/local/bin/
$ mv apktool.txt apktool // 把apktool.txt 改名为apktool
$ chmod +x apktool.jar
$ chmod +x apktool
$ apktool -v //到这一步就是安装好了
$ cd /Users/emily/Documents/MyTool //需要反编译的 apk 所在目录
$ apktool d facebook-156-0-0-36-100.apk

6》反编译结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
I: Using Apktool 2.3.1 on facebook-156-0-0-36-100.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
S: WARNING: Could not write to (/Users/emily/Library/apktool/framework), using /var/folders/px/72q9wmwx10jbv32_2pbhc3740000gn/T/ instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
I: Loading resource table from file: /var/folders/px/72q9wmwx10jbv32_2pbhc3740000gn/T/1.apk
I: Regular manifest package...
I: Decoding file-resources...
S: Could not decode file, replacing by FALSE value: b9b.g.png
S: Could not decode file, replacing by FALSE value: bcc.9.png
S: Could not decode file, replacing by FALSE value: b59.png
S: Could not decode file, replacing by FALSE value: cz4.png
S: Could not decode file, replacing by FALSE value: bt5.g.png
S: Could not decode file, replacing by FALSE value: gjq.g.png
S: Could not decode file, replacing by FALSE value: be1.g.png
S: Could not decode file, replacing by FALSE value: dqa.g.png
S: Could not decode file, replacing by FALSE value: bvw.g.png
S: Could not decode file, replacing by FALSE value: hd9.png
S: Could not decode file, replacing by FALSE value: cjb.png
S: Could not decode file, replacing by FALSE value: ds3.
S: Could not decode file, replacing by FALSE value: hng.
S: Could not decode file, replacing by FALSE value: cy3.g.png
S: Could not decode file, replacing by FALSE value: gxy.png
S: Could not decode file, replacing by FALSE value: bjp.png
S: Could not decode file, replacing by FALSE value: pf.9.png
···