android apk反编译
1.工具介绍及下载
1) apktool
资源文件获取,可以提取出图片文件和布局文件进行使用查看
2) dex2jar
将apk反编译成Java源码(classes.dex转化成jar文件)
3) jd-gui
查看APK中classes.dex转化成出的jar文件,即源码文件
下载地址;https://code.google.com/archive/p/innlab/downloads
2. 反编译过程
打开cmd命令行,定位到apk目录:
C:\Users\Jason>E: C:\Users\Jason>cd E:\installer\apk E:\installer\apk>
1) res及xml反编译
E:\installer\apk>"E:\Program Files (x86)\Android\apktool\apktool.bat" d -f test.apk
其中
"E:\Program Files (x86)\Android\apktool\apktool.bat"
为apktool.bat安装路径。
cmd输出结果如下:
I: Using Apktool 2.1.1 on test.apk I: Loading resource table... I: Decoding AndroidManifest.xml with resources... I: Loading resource table from file: C:\Users\Jason\apktool\framework\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...
证明反编译成功,得到test文件夹,可在该文件夹中查看反编译出来的res及xml文件。
2) 重新打包
E:\installer\apk>"E:\Program Files (x86)\Android\apktool\apktool.bat" b test
cmd输出结果如下:
I: Using Apktool 2.1.1 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...
证明编译成功。在test目录下生成build、dist两个文件夹,其中dist中存放重新打包的apk文件。
3) java反编译
a) 解压test.apk得到classes.dex文件,cmd定位到该目录:
E:\installer\apk>cd testtest
b) 运行
E:\installer\apk\testtest>"E:\Program Files (x86)\Android\apktool\dex2jar-2.0\d2j-dex2jar.bat" classes.dex
得到classes-dex2jar.jar文件,其中
"E:\Program Files (x86)\Android\apktool\dex2jar-2.0\d2j-dex2jar.bat"
为d2j-dex2jar.bat的安装路径。
cmd输出结果如下:
dex2jar classes.dex -> .\classes-dex2jar.jar
证明反编译成功。
c) 通过jd-gui中的jd-gui.exe打开classes-dex2jar.jar文件,就可以查看java源码了。