android 反编译相关工具介绍
文章目录
有时我们看到一些比较好玩的功能,总想探究是怎么实现的,这个时候就需要一些反编译的手段,帮助自己了解内部的部分实现,提供思路。
那都有哪些反编译的手段,有哪些工具可以帮忙我们呢,下面让我一一道来。
APKTOOL
下载地址
https://ibotpeaches.github.io/Apktool/
$ apktool d test.apk I: Using Apktool 2.6.0 on test.apk I: Loading resource table... I: Decoding AndroidManifest.xml with resources... I: Loading resource table from file: 1.apk I: Regular manifest package... I: Decoding file-resources... I: Decoding values */* XMLs... I: Baksmaling classes.dex... I: Copying assets and libs... I: Copying unknown files... I: Copying original files... $ apktool b test I: Using Apktool 2.6.0 on test I: Checking whether sources has changed... I: Smaling smali folder into classes.dex... I: Checking whether resources has changed... I: Building resources... I: Building apk file... I: Copying unknown files/dir...
ODEX TO DEX TO JAR
需要两个 jar 文件, smali
和 baksmali
,这两个文件下载地址:
利用 baksmali
将 odex
转换成 smali
baksmali 主要用于将 odex 转换成 smali,算一个中间步骤,指令帮助如下:
$ java -jar baksmali-2.5.2.jar -h
usage: baksmali [--version] [--help] [<command [<args>]]
Options:
--help,-h,-? - Show usage information
--version,-v - Print the version of baksmali and then exit
Commands:
deodex(de,x) - Deodexes an odex/oat file
disassemble(dis,d) - Disassembles a dex file.
dump(du) - Prints an annotated hex dump for the given dex file
help(h) - Shows usage information
list(l) - Lists various objects in a dex file.
See baksmali help <command> for more information about a specific command
通过如上帮助命令,可以看到将 odex 转换成 smali 的指令
java -jar baksmali-2.5.2.jar x xxxx.odex
那将 odex 转换成 smali 之后,再利用 smali.jar 文件将 smali 转换成 dex
利用 smali
工具将转换成 dex
下载对应版本的 smali.jar,将刚刚生成的 smali 转换成 dex,帮助指令如下:
java -jar smali-2.5.2.jar -h
usage: smali [-v] [-h] [<command [<args>]]
Options:
-h,-?,--help - Show usage information
-v,--version - Print the version of baksmali and then exit
Commands:
assemble(ass,as,a) - Assembles smali files into a dex file.
help(h) - Shows usage information
See smali help <command> for more information about a specific command
生成 dex 的命令如下:
java -jar smali-2.5.2.jar a <dir> -o <file>
其中 dir 为 odex 转换成 smali 的文件夹,file则是最终的dex文件,如: demo.dex
利用 dex2jar 将 dex 转换成 jar
下载地址:
https://github.com/pxb1988/dex2jar/releases
$ dex2jar-0.0.9.15/d2j-dex2jar.sh a.dex dex2jar a.dex -> a-dex2jar.jar
JD-GUI 将 jar 文件进行反编译
文章作者 Brook
上次更新 2020-06-16