Android如何反编译APK与资源文件

Android 反编译

一、需要准备三个软件包
1. apktool
用于反编译解析资源文件
2. dex2jar
用于反编译出JAVA代码
3. jd-gui
用于查看JAVA代码

二、使用apktool反编译出资源文件

C:\>apktool d hupan.apk
I: Using Apktool 2.0.2 on hupan.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\hp\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...

此时会在当前目录下生成与apk文件名称一样的文件夹,文件夹内就是反编译出的资源文件

三、将apk文件后缀名改为 .zip ,使用压缩软件,解压出classes.dex。将解压的classes.dex文件拷贝到dex2jar文件夹内,使用dex2jar反编译出jar文件。

C:\> d2j-apk-sign.bat classes.dex
this cmd is deprecated, use the d2j-dex2jar if possible
dex2jar version: translator-0.0.9.15
dex2jar classes.dex -> classes_dex2jar.jar
Done.

此时该文件夹下会生成classes_dex2jar.jar文件,然后就可以使用jd-gui来查看该jar文件的java文件了。


所遇到的错误:

  1. 使用apktool时出现brut.androlib.err.UndefinedResObject错误提示:
I: Using Apktool 2.0.2 on hupan.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\hp\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
Exception in thread "main" brut.androlib.err.UndefinedResObject: resource spec: 0x01010462
        at brut.androlib.res.data.ResPackage.getResSpec(ResPackage.java:59)
        at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:65)
        at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:61)
        at brut.androlib.res.data.value.ResReferenceValue.getReferent(ResReferenceValue.java:57)
        at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:54)
        at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:502)
        at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:252)
        at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:135)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:102)
        at brut.apktool.Main.cmdDecode(Main.java:165)
        at brut.apktool.Main.main(Main.java:81)

解决方法:
从手机中导出framework-res.apk文件(/system/framework目录下),拷贝到apktool目录下,执行以下语句:

C:\> apktool if framework-res.apk
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值