如何反编译360 apk文件
2015-12-25 11:33
441 查看
要做Android逆向第一步就是apktool.
apktool将apk中得代码反编译成smali代码.
然而,某些app利用apktool的一些"死角", 让其不能正常工作, 导致整个反汇编过程失败.
幸运的是apktool是开源的, 于是你自己编一个apktool来逆向那些app了~
首先来看, 默认情况下, 使用apktool反编译360手机卫士发生了什么:
命令:
代码:
然后发生异常:
代码:
然后 我们发现什么都没有输出.
于是我们要解决这个问题.
解决这个问题的第一步就是, 要找到apktool源码的位置:(可能你需要翻墙)
apktool的代码有两个下载地址(一个是github上, 一个是他们的官网上?) 粗略看了貌似代码是一样的:
git clone https://github.com/iBotPeaches/Apktool.git
git clone https://bitbucket.org/iBotPeaches/apktool.git
随便下载一个源码, 然后, 找到崩溃的最后一句的位置:
ResTypeSpec.java的第78行:(被我注释掉的,就是第78行了: 是的, 直接注释掉, 就可以解决不能反编译360卫士的问题)
代码:
为什么这里可以直接注释掉? 因为根据上下文来看, 这只是一个无关痛痒的异常, 没必要因为这个异常让反编译过程终止. 所以都懒得继续看什么, 直接注释掉这个异常,就OK了.
然后, 关于如何编译apktool工程, 请一定要参看其官网的描述:
====================================================
http://ibotpeaches.github.io/Apktool/build/
How to Build Apktool from source
Apktool is a collection of 1 project, containing 5 sub-projects.
brut.apktool.lib - (Main, all the Library code)
brut.apktool.cli - The cli interface of the program
brut.j.dir - Utility project
brut.j.util - Utility project
brut.j.common - Utility project
smali - submodule of JesusFreke’s smali tool
The main project can be found below
https://github.com/iBotPeaches/Apktool
Requirements
JDK (1.7)
git
Build Steps
We use gradle to build. It’s pretty easy. First clone the repository.
git clone --recursive git://github.com/iBotPeaches/Apktool.git
cd Apktool
For steps 4-6 use ./gradlew for unix based systems or gradlew.bat for windows.
[./gradlew][gradlew.bat] applyPatches - Applies smali patches, creating brut.apktool.smali directory.
[./gradlew][gradlew.bat] build fatJar - Builds Apktool, including final binary.
Optional (You may build a Proguard jar) [./gradlew][gradlew.bat] build fatJar proguard
After 1-2 minutes you should have a jar file at
./brut.apktool/apktool-cli/build/libs/apktool-xxxxx.jar
Cleaning
Cleaning the project, removes all build directories and wipes the brut.apktool.smali directory. You must reapply patches via step 4 above to re-create the brut.apktool.smali. This must be done before building Apktool again..
====================================================
鉴于有的人英文不行? 那就提供一键编译方法吧:(Linux/MAC下)
步骤一:首先进入到代码根目录, 要清理一下缓存目录:
$ rm -rf brut.apktool.smali/ && rm ./brut.apktool/apktool-cli/build/libs/apktool-cli.jar
步骤二: 在代码根目录, 一键编译:
$ ./gradlew applyPatches && ./gradlew build fatJar && ./gradlew build fatJar proguard && ./brut.apktool/apktool-cli/build/libs/apktool-cli.jar
注: 如果是window下, 请讲上述步骤二的"./gradlew"全部替换为"gradlew.bat", 步骤一的清理缓存,请自行查找替代命令
注2: JDK1.7是编译必须的. 可能你还需要在本地配置下gradle命令环境, 也许不需要.
编译成功以后, 你就可以拿到apktool-xxxxx.jar.
然后使用这个apktool-xxxxx.jar去反编译360试试?
代码:
伸手党: apktool-cli.jar放在百度云盘了:
链接: http://pan.baidu.com/s/1i4oWc2D 密码: nktm
授人以鱼,不若授人以渔. 以上就是解决那些不能被反编译的apk的方法~
over
最后把apktool-cli.jar
改为apktool.jar 替换apktool文件下的apktool.jar
在反编译就成功了
apktool将apk中得代码反编译成smali代码.
然而,某些app利用apktool的一些"死角", 让其不能正常工作, 导致整个反汇编过程失败.
幸运的是apktool是开源的, 于是你自己编一个apktool来逆向那些app了~
首先来看, 默认情况下, 使用apktool反编译360手机卫士发生了什么:
命令:
代码:
$ java -jar apktool.jar ~/Desktop/xxx/360.apk -f -o ~/Desktop/xxx/360.apk_out/
然后发生异常:
代码:
I: Using Apktool 2.0.3-831765-SNAPSHOT on 360.apk I: Loading resource table... Exception in thread "main" brut.androlib.AndrolibException: Multiple res specs: drawable/ at brut.androlib.res.data.ResTypeSpec.addResSpec(ResTypeSpec.java:78) at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:248) at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:212) at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:154) at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:116) at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:78) at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47) at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:544) at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:63) at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:55) at brut.androlib.Androlib.getResTable(Androlib.java:66) at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:198) at brut.androlib.ApkDecoder.decode(ApkDecoder.java:96) at brut.apktool.Main.cmdDecode(Main.java:165) at brut.apktool.Main.main(Main.java:81)
然后 我们发现什么都没有输出.
于是我们要解决这个问题.
解决这个问题的第一步就是, 要找到apktool源码的位置:(可能你需要翻墙)
apktool的代码有两个下载地址(一个是github上, 一个是他们的官网上?) 粗略看了貌似代码是一样的:
git clone https://github.com/iBotPeaches/Apktool.git
git clone https://bitbucket.org/iBotPeaches/apktool.git
随便下载一个源码, 然后, 找到崩溃的最后一句的位置:
ResTypeSpec.java的第78行:(被我注释掉的,就是第78行了: 是的, 直接注释掉, 就可以解决不能反编译360卫士的问题)
代码:
public void addResSpec(ResResSpec spec) throws AndrolibException { if (mResSpecs.put(spec.getName(), spec) != null) {// fuck 360 // throw new AndrolibException(String.format("Multiple res specs: %s/%s", getName(), spec.getName())); } }
为什么这里可以直接注释掉? 因为根据上下文来看, 这只是一个无关痛痒的异常, 没必要因为这个异常让反编译过程终止. 所以都懒得继续看什么, 直接注释掉这个异常,就OK了.
然后, 关于如何编译apktool工程, 请一定要参看其官网的描述:
====================================================
http://ibotpeaches.github.io/Apktool/build/
How to Build Apktool from source
Apktool is a collection of 1 project, containing 5 sub-projects.
brut.apktool.lib - (Main, all the Library code)
brut.apktool.cli - The cli interface of the program
brut.j.dir - Utility project
brut.j.util - Utility project
brut.j.common - Utility project
smali - submodule of JesusFreke’s smali tool
The main project can be found below
https://github.com/iBotPeaches/Apktool
Requirements
JDK (1.7)
git
Build Steps
We use gradle to build. It’s pretty easy. First clone the repository.
git clone --recursive git://github.com/iBotPeaches/Apktool.git
cd Apktool
For steps 4-6 use ./gradlew for unix based systems or gradlew.bat for windows.
[./gradlew][gradlew.bat] applyPatches - Applies smali patches, creating brut.apktool.smali directory.
[./gradlew][gradlew.bat] build fatJar - Builds Apktool, including final binary.
Optional (You may build a Proguard jar) [./gradlew][gradlew.bat] build fatJar proguard
After 1-2 minutes you should have a jar file at
./brut.apktool/apktool-cli/build/libs/apktool-xxxxx.jar
Cleaning
Cleaning the project, removes all build directories and wipes the brut.apktool.smali directory. You must reapply patches via step 4 above to re-create the brut.apktool.smali. This must be done before building Apktool again..
====================================================
鉴于有的人英文不行? 那就提供一键编译方法吧:(Linux/MAC下)
步骤一:首先进入到代码根目录, 要清理一下缓存目录:
$ rm -rf brut.apktool.smali/ && rm ./brut.apktool/apktool-cli/build/libs/apktool-cli.jar
步骤二: 在代码根目录, 一键编译:
$ ./gradlew applyPatches && ./gradlew build fatJar && ./gradlew build fatJar proguard && ./brut.apktool/apktool-cli/build/libs/apktool-cli.jar
注: 如果是window下, 请讲上述步骤二的"./gradlew"全部替换为"gradlew.bat", 步骤一的清理缓存,请自行查找替代命令
注2: JDK1.7是编译必须的. 可能你还需要在本地配置下gradle命令环境, 也许不需要.
编译成功以后, 你就可以拿到apktool-xxxxx.jar.
然后使用这个apktool-xxxxx.jar去反编译360试试?
代码:
$ java -jar apktool-xxxxx.jar ~/Desktop/xxx/360.apk -f -o ~/Desktop/xxx/360.apk_out/
伸手党: apktool-cli.jar放在百度云盘了:
链接: http://pan.baidu.com/s/1i4oWc2D 密码: nktm
授人以鱼,不若授人以渔. 以上就是解决那些不能被反编译的apk的方法~
over
最后把apktool-cli.jar
改为apktool.jar 替换apktool文件下的apktool.jar
在反编译就成功了
相关文章推荐
- iOS获取网络图片的宽、高
- 看看什么叫老牛吃嫩草
- HDU1260 Tickets(简单dp)
- Appdelegate里面跳转页面
- 指针-数组逆序
- 两个软硬程度一样的鸡蛋,它们在某一层摔下会碎,有个100层的建筑,要求最多用两个鸡蛋确 定鸡蛋安全下落的临界位置,给出临界位置?如果是n层楼,m个鸡蛋,请给出确定临界位置的算法
- easyui datagrid 多列排序,该如何处理[多列同时order,只针对某一列order]
- 仿推特进入设置界面友好的指示提示框
- 面试总结
- 让项目同时支持ARC和非ARC
- 多彩浏览器win10版 隐私声明
- Volley封装
- 无损音乐下载器 Delphi版
- 远端linux服务器安装apache(图解过程)
- 安装 android 本地安装ADT 遇到的问题
- Linux中守护进程详解
- Android开发笔记(二十七)对象序列化
- 青瓷引擎之纯JavaScript打造HTML5游戏第二弹——《跳跃的方块》Part 4
- 生产实习(Android)七
- xcode真机调试错误