zoukankan      html  css  js  c++  java
  • 转载分析apk工具aapt的使用,解析其原理

    通过apktool我们的确可以反编译已经序列化后的AndroidManifest.xml和资源文件等等,但是有没有一种快速有效的工具在不解包的前提下可以获得某一apk的基本内容、权限以及该apk的基本信息呢?答案就是有,这个工具就是今天要介绍的aapt。

    aapt简介

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

    主要用法

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

    1
    2
    3
    4
    5
    6
    
    aapt l[ist]:列出资源压缩包里的内容。
    aapt d[ump]:查看APK包内指定的内容。
    aapt p[ackage]:打包生成资源压缩包。
    aapt r[emove]:从压缩包中删除指定文件。
    aapt a[dd]:向压缩包中添加指定文件。
    aapt v[ersion]:打印aapt的版本。

    使用aapt

    这里我就用一个应用来做测试sample,应用为:应用汇应用市场。 列举出apk中的所有文件

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

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

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

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

    1
    2
    3
    4
    5
    6
    7
    8
    
    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.

    查看基本信息

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

     查看应用权限

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

    结语

    怎么样,aapt这个小工具本领还真不小吧,当我们在判断一个apk是否有恶意行为时,我们第一步可以考虑使用aapt这个tool哦,我们可以分析这个apk的权限列表,一旦有部分权限过大,比如发送短信、读取联系人信息等权限时,就可以进一步分析这个apk了。

    最后推荐:爱加密关于某银行apk的安全分析实例

     

     

     

  • 相关阅读:
    js实现观察者模式
    磁盘阵列操作实战
    淘宝知名工程师
    Java线程并发控制基础知识
    java多线程总结
    NIO系列1:框架拆解
    Java NIO 系列教程
    Java NIO系列教程(三-十二) Buffer
    Java NIO系列教程(二) Channel
    Java NIO系列教程(一) Java NIO 概述
  • 原文地址:https://www.cnblogs.com/ablansetaimeng/p/4583607.html
Copyright © 2011-2022 走看看