mac反编译安卓apk

反编译工具

apktool

两种方式

  • 下载地址1: https://ibotpeaches.github.io/Apktool/install/
  • 下载地址2: https://bitbucket.org/iBotPeaches/apktool/downloads/
dex2jar

两种方式

  • 下载地址1: https://github.com/pxb1988/dex2jar/
  • 下载地址2: https://sourceforge.net/projects/dex2jar
jd-gui
  • 下载地址:http://jd.benow.ca

apktool 安装

  • 安装方式查看 https://ibotpeaches.github.io/Apktool/install/

  • 下载好带版本号的jar修改名字为apktool.jar

  • apktool文件各式如图

    mac反编译安卓apk_第1张图片
    屏幕快照 2018-10-23 13.47.19.png

  • apktool.jarapktool存放在/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 
Updated by Connor Tumbleson 

usage: apktool
 -advance,--advanced   prints advance information.
 -version,--version    prints the version then exits
usage: apktool if|install-framework [options] 
 -p,--frame-path    Stores framework files into .
 -t,--tag           Tag frameworks using .
usage: apktool d[ecode] [options] 
 -f,--force              Force delete destination directory.
 -o,--output        The name of folder that gets written. Default is apk.out
 -p,--frame-path    Uses framework files located in .
 -r,--no-res             Do not decode resources.
 -s,--no-src             Do not decode sources.
 -t,--frame-tag     Uses framework files tagged by .
usage: apktool b[uild] [options] 
 -f,--force-all          Skip changes detection and build all files.
 -o,--output        The name of apk that gets written. Default is dist/name.apk
 -p,--frame-path    Uses framework files located in .

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
  • 反编译的目标apkcom.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/
  • 使用dex2jarclasses.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源代码了

你可能感兴趣的:(mac反编译安卓apk)