Android逆向工程

方法一

apktool+dex2jar+jd-gui

apktool 作用:资源文件的获取,可以提取出图片文件和布局文件进行查看
dex2jar 作用:将apk反编译成java源码(classes.dex转化成jar文件)
jd-gui 作用:查看APK中的classes.dex转化成的jar文件,即源码文件

apktool下载地址:
https://ibotpeaches.github.io/Apktool/install/
dex2jar下载地址:
https://sourceforge.net/projects/dex2jar/?source=navbar
jd-gui下载地址:
http://jd.benow.ca/

1. 资源反编译

apktool下载、安装及使用
首先,到官网下载apktool需要的工具:https://ibotpeaches.github.io/Apktool/.
下载地址https://ibotpeaches.github.io/Apktool/install/
安装步骤
https://ibotpeaches.github.io/Apktool/install/
说的很清楚了,我们下载的apktool工具需要重命名为apktool.jar,同时把apktool.sh(Linux系统)也下载下来放在一个文件夹下。
用法如下:

apktool.jar     bydr         dial                  googlePinyin.apk  IPVideoTalk_1.0.0.9.apk  kongge_145          MoretvApp3.2.1.apk     Skypeforbusiness.apk
apktool.sh      bydr.apk     dial.apk              googleTalk        IPVideoTalkPro           kongge_145.apk      qq_5.1.1.6062_android  Softphone
linhu@linhu-Lenovo:~/document/Android_Notes/difProject/difTools$ ./apktool.sh --help
Unrecognized option: --help
Apktool v2.3.3 - 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
linhu@linhu-Lenovo:~/document/Android_Notes/difProject/difTools$

反编译资源文件

linhu@linhu-Lenovo:~/document/Android_Notes/difProject/difTools$ ./apktool.sh d -f -s MoretvApp3.2.1.apk 
I: Using Apktool 2.3.3 on MoretvApp3.2.1.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/linhu/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Copying raw classes.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...

2. 源码反编译

将上一步中保留的dex文件,通过dex2jar工具转成jar文件

下载dex2jar解压后将classes.dex文件拷贝到解压的目录下,通过./d2j-dex2jar.sh工具将classes.dex转化成jar包

linhu@linhu-Lenovo:~/document/Android_Notes/difProject/difTools/dex2jar-2.0$ ls
classes.dex       d2j-dex2jar.bat    d2j-dex2smali.sh                d2j_invoke.bat   d2j-jar2dex.sh      d2j-jasmin2jar.bat  d2j-smali.sh     lib
d2j-baksmali.bat  d2j-dex2jar.sh     d2j-dex-recompute-checksum.bat  d2j_invoke.sh    d2j-jar2jasmin.bat  d2j-jasmin2jar.sh   d2j-std-apk.bat
d2j-baksmali.sh   d2j-dex2smali.bat  d2j-dex-recompute-checksum.sh   d2j-jar2dex.bat  d2j-jar2jasmin.sh   d2j-smali.bat       d2j-std-apk.sh
linhu@linhu-Lenovo:~/document/Android_Notes/difProject/difTools/dex2jar-2.0$ ./d2j-dex2jar.sh classes.dex
dex2jar classes.dex -> ./classes-dex2jar.jar

3. 用jd-gui工具打开jar

用jd-gui工具打开jar文件,文件菜单中选择保存源码文件。
jd-gui打开jar文件

方法二

jadx是一款很好用的反编译工具,直接将apk打开即可反编译出java文件。

简介

Jadx是一款很好用的开源反编译工具,具有如下特点:

  • 图形化的界面。
  • 拖拽式的操作。
  • 反编译输出 Java 代码。
  • 导出 Gradle 工程。

安装及使用

jadx 本身就是一个开源项目,源代码已经在 Github 上开源了。

Jadx Github :
Jadx项目链接

有兴趣可以直接 clone 源代码,然后本地自己编译。但是多数情况下,我们是需要一个编译好的版本。编译好的版本,可以在 sourceforge 上下载到。

sourceforge 下载 jadx。

详细使用技巧请参考下面的链接:
https://blog.csdn.net/Fisher_3/article/details/78654450

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Calvin880828

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值