使用 Apktool 解压 APK 并打包

Android应用加固中,如果对apk中的SO文件进行加固,需首先使用 apktool 解压apk文件。

apktool 除了可以解压apk外,还可以在修改后重新打包。

功能

  • 将apk解压为原来的形式(包括resources.arsc,class.dex,so等)

  • 将解压的资源重新打包成apk

  • 组织和处理依赖于框架资源的apk

  • Smali调试

  • 执行自动化任务

安装方式

访问 https://ibotpeaches.github.io/Apktool/install,根据开发环境选择对应版本。

使用方式

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>.

解压apk

切换目录

解压apk

apktool d <file_apk>

解压后,会生成一个同名的文件夹

查看SO文件

本范例的SO文件保存于C:\Program Files (x86)\apktool\angrybots5.5.3\lib\armeabi-v7a目录下,开发者可根据自己的实际情况定位SO文件目录。

SO加固

不同语言开发的SO文件加固方式不同,详情请访问:

打包apk

切换目录

打包apk

apktool b <app_path>

查看apk文件

本范例的新apk文件保存于C:\Program Files (x86)\apktool\angrybots5.5.3\dist目录下,开发者可根据自己的实际情况定位apk所在目录。

文件对比

最后更新于