mac反编译安卓apk
2018-10-23 本文已影响0人
Morgan7
反编译工具
apktool
两种方式
- 下载地址1: https://ibotpeaches.github.io/Apktool/install/
- 下载地址2: https://bitbucket.org/iBotPeaches/apktool/downloads/
dex2jar
两种方式
jd-gui
- 下载地址:http://jd.benow.ca
apktool 安装
-
下载好带版本号的
jar
修改名字为apktool.jar
-
屏幕快照 2018-10-23 13.47.19.pngapktool
文件各式如图 -
将
apktool.jar
和apktool
存放在/usr/local/bin
-
终端输入
apktool
显示下面 安装成功
$ apktool
Apktool v2.3.4 - a tool for reengineering Android apk files
with smali v2.2.2 and baksmali v2.2.2
Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
Updated by Connor Tumbleson <connor.tumbleson@gmail.com>
usage: apktool
-advance,--advanced prints advance information.
-version,--version prints the version then exits
usage: apktool if|install-framework [options] <framework.apk>
-p,--frame-path <dir> Stores framework files into <dir>.
-t,--tag <tag> Tag frameworks using <tag>.
usage: apktool d[ecode] [options] <file_apk>
-f,--force Force delete destination directory.
-o,--output <dir> The name of folder that gets written. Default is apk.out
-p,--frame-path <dir> Uses framework files located in <dir>.
-r,--no-res Do not decode resources.
-s,--no-src Do not decode sources.
-t,--frame-tag <tag> Uses framework files tagged by <tag>.
usage: apktool b[uild] [options] <app_path>
-f,--force-all Skip changes detection and build all files.
-o,--output <dir> The name of apk that gets written. Default is dist/name.apk
-p,--frame-path <dir> Uses framework files located in <dir>.
For additional info, see: http://ibotpeaches.github.io/Apktool/
For smali/baksmali info, see: https://github.com/JesusFreke/smali
开始反编译
目录结构
AndroidDecompilation/
├── Decompile
│ └── com.stub.StubApp.apk
├── apktool
├── apktool.jar
├── dex2jar-2.0
│ ├── d2j-baksmali.bat
│ ├── d2j-baksmali.sh
│ ├── d2j-dex-recompute-checksum.bat
│ ├── d2j-dex-recompute-checksum.sh
│ ├── d2j-dex2jar.bat
│ ├── d2j-dex2jar.sh
│ ├── d2j-dex2smali.bat
│ ├── d2j-dex2smali.sh
│ ├── d2j-jar2dex.bat
│ ├── d2j-jar2dex.sh
│ ├── d2j-jar2jasmin.bat
│ ├── d2j-jar2jasmin.sh
│ ├── d2j-jasmin2jar.bat
│ ├── d2j-jasmin2jar.sh
│ ├── d2j-smali.bat
│ ├── d2j-smali.sh
│ ├── d2j-std-apk.bat
│ ├── d2j-std-apk.sh
│ ├── d2j_invoke.bat
│ ├── d2j_invoke.sh
│ └── lib
│ ├── antlr-runtime-3.5.jar
│ ├── asm-debug-all-4.1.jar
│ ├── d2j-base-cmd-2.0.jar
│ ├── d2j-jasmin-2.0.jar
│ ├── d2j-smali-2.0.jar
│ ├── dex-ir-2.0.jar
│ ├── dex-reader-2.0.jar
│ ├── dex-reader-api-2.0.jar
│ ├── dex-tools-2.0.jar
│ ├── dex-translator-2.0.jar
│ ├── dex-writer-2.0.jar
│ └── dx-1.7.jar
├── dex2jar-2.0.zip
├── jd-gui-osx-1.4.0
│ ├── JD-GUI.app
│ │ └── Contents
│ │ ├── Info.plist
│ │ ├── MacOS
│ │ │ └── universalJavaApplicationStub.sh
│ │ └── Resources
│ │ ├── Java
│ │ │ └── jd-gui-1.4.0.jar
│ │ └── jd-gui.icns
│ ├── LICENSE
│ ├── NOTICE
│ └── README.md
└── jd-gui-osx-1.4.0.tar
-
反编译的目标apk
com.stub.StubApp.apk
存放路径Decompile/com.stub.StubApp.apk
进入此目录$ cd /Decompile
-
执行
$ apktool d com.stub.StubApp.apk
-
执行
$ ls
结果
com.stub.StubApp com.stub.StubApp.apk
- 反编译java源文件
将com.stub.StubApp.apk
修改为com.stub.StubApp.zip
JavaSourceCode
用来存放源码
$ mv com.stub.StubApp.apk com.stub.StubApp.zip
$ mkdir JavaSourceCode
$ unzip com.stub.StubApp.zip -d JavaSourceCode/
- 使用
dex2jar
对classes.dex
生成classes.jar
-
JavaSourceCode
里面会有一个classes.dex
文件 - 进入
$ cd JavaSourceCode/
执行cp classes.dex ../../dex2jar-2.0/
执行cd ../../dex2jar-2.0
$ sudo chmod +x d2j_invoke.sh
$ sh d2j-dex2jar.sh classes.dex
- 会生成
classes-dex2jar.jar
- 使用
jd-gui
工具打开这个classes-dex2jar.jar
包就可以看到java
源代码了