android apk 逆向中常用工具一览
关于apk 逆向中的一些工具的使用,看了不少文章,也使用过有很长一段时间了,今天对此做一总结,高手可以飘过,新人可以瞄两眼~~:
几种文件之间的转换命令:
1. odex -> smali
java -jar baksmali.jar -a <api_level> -x <odex_file> -d <framework_dir>
2.smali ->dex
java -Xmax512M -jar samli-2.0.jar <smali_dir> -o classes.dex
3.dex ->odex
在android平台下使用命令dexopt-wrapper实现:
dexopt-wrapper 123.apk 123.odex
4. 对odex的签名,用于对修改后的odex文件,使用源文件的一部分文件头:
busybox dd if=android.policy.odex.bak of=android.policy.odex bs=1 count=20 skip=52 seek=52 conv=notrunc
5. 对apk的签名 使用专门的签名工具:
java -jar signapk.jar platform.x509.pem platform.pk8 input.apk output.apk
6. Apktools的使用
Apktool 是apk的逆向分析工具,可用于对apk的打包 解包。
APKtool 软件包有 2 个程序组成:apktool.jar 和 aapt 运行 apktools.jar 需要 java 环境(1.6.0 版本以上)。
apktool.jar 用于解包,apktool.jar 和 aapt.exe 联合用于打包。
frank@ubuntu-troxy:~$ java -jar /data/dtgy.package/bin/apktool.jar
Apktool v1.4.3 - a tool for reengineering Android apk files
Copyright 2010 Ryszard Wi?niewski <brut.alll@gmail.com>
Apache License 2.0 (
http://www.apache.org/licenses/LICENSE-2.0)
Usage: apktool [-q|--quiet OR -v|--verbose] COMMAND [...]
COMMANDs are:
d[ecode] [OPTS] <file.apk> [<dir>]
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[uild] [OPTS] [<app_path>] [<out_file>]
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/
Apktool工具下载链接:
https://code.google.com/p/android-apktool/
相关的工具有:
java -jar AXMLPrinter2.jar AndroidManifest.xml 解开在apk 中的 AndroidManifest.xml
smali 工具
https://code.google.com/p/smali/downloads/list
dexopt-wrapper 源码
https://android.googlesource.com/platform/build/+/donut-release/tools/dexpreopt/dexopt-wrapper/
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!