您的位置:首页 > 移动开发 > Android开发

Android快速分析apk工具aapt的使用教程

2016-05-21 10:48 357 查看
aapt简介

aapt即Android Asset Packaging Tool,我们可以在SDK的platform-tools目录下找到该工具。aapt可以查看、 创建、 更新ZIP格式的文档附件(zip, jar, apk)。 也可将资源文件编译成二进制文件,尽管你可能没有直接使用过aapt工具,但是build scripts和IDE插件会使用这个工具打包apk文件构成一个Android 应用程序。

主要用法

下面的这个参数列表基本向我们展示了如何使用aapt以及aapt的基本功能了。

复制代码代码如下:

aapt l[ist]:列出资源压缩包里的内容。

aapt d[ump]:查看APK包内指定的内容。

aapt p[ackage]:打包生成资源压缩包。

aapt r[emove]:从压缩包中删除指定文件。

aapt a[dd]:向压缩包中添加指定文件。

aapt v[ersion]:打印aapt的版本。

使用aapt
这里我就用一个应用来做测试sample,应用为:应用汇应用市场。

列举出apk中的所有文件

复制代码代码如下:

walfred@ubuntu:~/lab$ aapt l yingyonghui.apk



当然这个apk的内容太多,一张纸显示不了所有的内容,你可以将其重定向到一个专门的文件中去,这样查看也方便。

复制代码代码如下:

walfred@ubuntu:~/lab$ aapt l yingyonghui.apk > yingyonghui.txt

查看apk的基本信息

aapt最实用的功能,通过d(ump)参数可以查看该apk的基本信息以及权限等,但该参数还有一个value,可以选用的value值如下:

d参数的语法如下:

复制代码代码如下:

aapt d[ump] [--values] WHAT file.{apk} [asset [asset ...]]

values:

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.

查看基本信息

复制代码代码如下:

walfred@ubuntu:~/lab$ aapt d badging yingyonghui.apk



查看应用权限

复制代码代码如下:

walfred@ubuntu:~/lab$ aapt d permissions yingyonghui.apk



结语

怎么样,aapt这个小工具本领还真不小吧,当我们在判断一个apk是否有恶意行为时,我们第一步可以考虑使用aapt这个tool哦,我们可以分析这个apk的权限列表,一旦有部分权限过大,比如发送短信、读取联系人信息等权限时,就可以进一步分析这个apk了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: