一.背景
1.最初使用aapt是为了做安卓应用的安全性测试。对于普通用户权限的应用我们通常使用的方法是在shell下run-as ,如返回值为run-as: Package ‘’ is not debuggable,我们就认为测试通过。在我们的安卓平台从7.x升为9.x以后,以后我们测试的应用改为系统权限,对于系统权限的app,run-as不再检查是否是debuggable,会显示“package not debuggable”。对此开发建议使用aapt的命令检查应用的安全性。
2.先将安卓应用pull到windows PC端然后使用aapt做安全性测试,具体的命令:
aapt l -a |findstr debuggle
二.aapt使用详解:
aapt是android自动打包工具之一。
环境配置:
aapt一般在android sdk的build-tools中对应文件夹里面,将其路径添加到环境变量中,即可在命令行中直接使用aapt命令;
aapt参数详解
aapt 命令后可直接查看参数详解
aapt l[ist] [-v] [-a] file.{zip,jar,apk}
1.aapt l xxx.apk :查看apk目录
2.aapt l -a xxx.apk:详细列出apk内容;
若内容较多,可保存到本地文件中,如 aapt l -a xxx.apk > xxx.txt
3.aapt l -v xxx.apk : 以table的形式输出目录
1>table的表目有:Length、Method、Size、Ratio、Date、Time、CRC-32、Name。
2>其中Method表示压缩形式,有:Deflate及Stored两种,即该Zip目录采用的算法是压缩模式 or 存储模式。
3>可以看出resources.arsc、*.png采用压缩模式,而其它采用压缩模式。
4>Ratio表示压缩率。CRC-32未明其意,Sodino盼指教。
4.aapt dump 命令
aapt d[ump] [—values] WHAT file.{apk} [asset[asset …]]
badging-----------Print the label and icon for the app declared in APK
permissions------Print the permissions from the APK
resources---------Print the resource table from the APK
configurations----Print the configurations in the APK
xmltree-------------Print the compiled xmls in the given assets
xmlstrings---------Print the strings of the given compiled xml assets
1.aapt d badging xxx.apk :显示标签、图标和应用程序的相关描述
2.aapt d permissions xxx.apk :显示apk所具有的系统权限
3.aapt d resources xxx.apk :查看apk资源
4.aapt d configurations xxx.apk :查看apk配置
5.aapt d xmltree facebook_googleplay_V1.0.0.apk res/anim-v21/design_bottom_sheet_slide_out.xml :查看xml的树形结构
6.aapt d xmlstrings facebook_googleplay_V1.0.0.apk res/anim-v21/design_bottom_sheet_slide_out.xml :查看xml中所有的string
dump命令的应用场景举例之查询包名和版本号
参考文章:https://blog.csdn.net/qq_33912215/article/details/88965571