安卓逆向工程之apktool工具集
Android apktool是一个用来处理APK文件的工具,可以对APK进行反编译生成程序的源代码和图片、XML配置、语言资源等文件,也可以添加新的功能到APK文件中。apk反编译软件有个组合套餐,apktool、dex2jar和jd-gui。
apktool——可以反编译软件的布局文件、图片等资源,方便大家学习一些很好的布局;
dex2jar——将apk反编译成java源码(classes.dex转化成jar文件);
jd-gui——查看APK中classes.dex转化成出的jar文件,即源码文件。
## 1、apktool文件的下载
apktool是反编译Android apk文件的工具,apktool的主页是https://ibotpeaches.github.io/Apktool/。我们可以从这里找到最新版本的apktool.jar文件https://bitbucket.org/iBotPeaches/apktool/downloads/,以及apktool的安装说明。
## 2、apktool的安装
前面我们已经下载了最新的apktool.jar文件,最新版本是2.4.0,请按照以下步骤操作,参考https://ibotpeaches.github.io/Apktool/install/:
新建文本文件,将下面的脚本复制到文本并保存,然后重命名为apktool.bat;
@echo off
set PATH=%CD%;%PATH%;
java -jar "%~dp0\apktool.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9
从上面脚本中也可以看到是用apktool.jar文件去处理;
将下载的apktool_2.4.0.jar文件重命名为apktool.jar;
## 3、apktool的使用
将上述两个文件apktool.bat和apktool.jar文件放到同一文件夹下(任意路径),打开命令窗口(win+R-->cmd-->enter);
定位到apktool所在的文件夹;
输入以下命令:
apktool d***.apk-o objectFolderPath
其中,objectFolderPath为可选项,如果此项不存在,软件将会在apktool文件夹下新建一个apk文件名的文件夹,否则存储到目标文件夹;
## 4、功能描述
```
D:\My Documents\Desktop\apktool-install-windows-r04-brut1>apktool
Apktool v1.4.3 - a tool for reengineering Android apk files
Copyright 2010 Ryszard Wi?niewski <[email protected]>
Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
Usage: apktool [-q|--quiet OR -v|--verbose] COMMAND [...]
COMMANDs are:
d <file.apk> [<dir>]//解压APK
Decode <file.apk> to <dir>.
OPTS:
-s, --no-src
Do not decode sources.
-r, --no-res
Do not decode resources.
-d, --debug
Decode in debug mode. Check project page for more info.
-f, --force
Force delete destination directory.
-t <tag>, --frame-tag <tag>
Try to use framework files tagged by <tag>.
--keep-broken-res
Use if there was an error and some resources were dropped, e.g.:
"Invalid config flags detected. Dropping resources", but you
want to decode them anyway, even with errors. You will have to
fix them manually before building.
b [<app_path>] [<out_file>]//构建APK
Build an apk from already decoded application located in <app_path>.
It will automatically detect, whether files was changed and perform
needed steps only.
If you omit <app_path> then current directory will be used.
If you omit <out_file> then <app_path>/dist/<name_of_original.apk>
will be used.
OPTS:
-f, --force-all
Skip changes detection and build all files.
-d, --debug
Build in debug mode. Check project page for more info.
if|install-framework <framework.apk> [<tag>]
Install framework file to your system.
For additional info, see: http://code.google.com/p/android-apktool/
```
## 5、常见问题
apktools 工具反编译抛出异常 :Exception in thread “main” brut.androlib.AndrolibException: Could not decode
使用apktools反编译apk时,输入命令:apktool.batd test.apk
此时,可能会报bug:
Exception in thread “main” brut.androlib.AndrolibException: Could not decode
这个问题,就是apktool.jar比较老旧的问题。
apktools.jar下载官网:
https://ibotpeaches.github.io/Apktool/install/
对应平台下载,更新即可。
页:
[1]