Androguard Documentation:官方文档阅读笔记

news2024/10/6 14:36:17

打算快速阅读下官方文档,然后做一个笔记方便查阅,文章目录按照官方文档目录来的

DOCUMENTATION

Getting Started

使用 androguard axmlandroguard arsc解码分析AndroidManifest.xml或者resources.arsc。
创建call graphs可以使用androguard cg,control flow graphs使用androguard decompile
要分析apk文件和dex文件可以使用AnalyzeAPK(filename)AnalyzeDEX(filename)
a, d, dx = AnalyzeAPK("examples/android/abcore/app-prod-debug.apk")
The three objects you get are a an APK object, d an array of DalvikVMFormat object and dx an Analysis object.
在apk对象中,可以获取到apk的各种信息,包括包名、权限信息、AndroidManifest.xml或其它资源文件。
DalvikVMFormat corresponds to the DEX file found inside the APK file. You can get classes, methods or strings from the DEX file. But when using multi-DEX APK’s it might be a better idea to get those from another place. The Analysis object should be used instead, as it contains special classes, which link information about the classes.dex and can even handle many DEX files at once.

Getting Information about an APK

a.get_permissions()
#getting a list of all activites, which are defined in the AndroidManifest.xml
a.get_activities()
a.get_package()
a.get_app_name()
a.get_app_icon() # path of the icon
#Get the numeric version and the version string, and the minimal, maximal, target and effective SDK version
 a.get_androidversion_code()
a.get_androidversion_name()
a.get_min_sdk_version()
a.get_max_sdk_version()
 a.get_target_sdk_version()
 a.get_effective_target_sdk_version()

有关AndroidManifest.xml

 #you can even get the decoded XML for the AndroidManifest.xml
a.get_android_manifest_axml().get_xml()
#use the AndroidManifest.xml as an ElementTree object
a.get_android_manifest_xml()

Using the Analysis object
可根据特定api构建调用图
~androguard.core.analysis.analysis.Analysis对象中有all information about the classes, methods, fields and strings inside one or multiple DEX files,Additionally it enables you to get call graphs and crossreferences (XREFs) for each method, class, field and string. This means you can investigate the application for certain API calls or create graphs to see the dependencies of different classes.

dx.get_classes() #  get all classes from the Analysis

get_classes返回ClassAnalysis对象
其中被标记为 EXTERNAL的类并没有在dex文件中定义
A ClassAnalysis does not contain the actual code but the ClassDefItem can be loaded using the get_vm_class():
dx.get_classes()[2].get_vm_class()
If the class is EXTERNAL, a ExternalClass is returned instead.

XREFs(交叉引用)

可以理解为在一个类中调用了另一个类的方法或者对象。
XREFs are generated for four things: Classes、Methods、Fields、Strings
XREFs work in two directions: xref_from and xref_to. To means, that the current object is calling another object. From means, that the current object is called by another object.
使用其提供的测试apk进行测试:examples/android/TestsAndroguard/bin/TestActivity.apk

Get XREFs for method calls
In order to get the class, you can simply use classes or find_classes():
dx.classes['Ltests/androguard/TestActivity;']
This will return a ClassAnalysis object. Now you can iterate over all methods inside the class and query for the xrefs (the output is abbreviated):

for meth in dx.classes['Ltests/androguard/TestActivity;'].get_methods():
   print("inside method {}".format(meth.name))
   for _, call, _ in meth.get_xref_to():
   print(" calling -> {} -- {}".format(call.class_name, call.name))   

输出图
可以看到testCall方法调用了很多的其它方法
同样的思路也可以用在API类中,如:

for meth in dx.classes['Ljava/io/File;'].get_methods():
	print("usage of method {}".format(meth.name))
	for _, call, _ in meth.get_xref_from():
	print(" called by -> {} -- {}".format(call.class_name, call.name))

Get XREFs for Strings
查找哪些字符串在被不同地方引用
You can use either strings or find_strings() to get the proper object for the XREFs:
如: dx.strings['boom']

for _, meth in dx.strings['boom'].get_xref_from():
	print("Used in: {} -- {}".format(meth.class_name, meth.name))

Get XREFs for Fields
Fields are a little bit different and do not use xref_from and xref_to but xref_read() and xref_write()
可以使用find_methods() 查找fields
For example, you want to get the read’s and write’s to the field value inside tests.androguard. TestActivity:

for field in dx.find_fields(classname='Ltests/androguard/TestActivity;', fieldname='^value$'):
	print("Field: {}".format(field.name))
	for _, meth in field.get_xref_read():
	print(" read in {} -- {}".format(meth.class_name, meth.name))
	for _, meth in field.get_xref_write():
	print(" write in {} -- {}".format(meth.class_name, meth.name))

Basic Blocks

可以使用 decompile 来获取 Control Flow Graph (CFG)
androguard decompile -d output_folder -f jpg --limit "LTestDefaultPackage.*" examples/android/TestsAndroguard/bin/TestActivity.apk
之后生成的图片,每一个矩形都是一个DVMBasicBlock

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/25564.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

快消品b2b电子商务网站建设方案

互联网在改造电商行业商业运作模式和提升运营效率作用方面功不可没,目前B2B电商发展正处在交易上升期特别是B2B快消品电商,这个以万亿为单位的流通规模市场必将掀起巨大的社会价值和运营效率。当然在讨论快消品流通B2B电商行业之前,我们先简单…

C++语言的return语句的一点说明

C语言的return语句的一点说明 为了完成某一功能的程序指令(语句)的集合,称为函数。在程序中,编写函数的主要目的是将一个需要很多行代码的复杂问题分解为一系列简单的任务来解决,而且,同一个任务&#xff0…

程序员副业之无货源闲鱼

我将从以下这些方面来介绍闲鱼副业。 1. 闲鱼平台能不能挣钱? 2. 闲鱼平台都有哪几种挣钱方式? 3. 小白在闲鱼上怎么挣钱? 4. 能挣多少? 5. 如何养号? 6. 得到高权重的账号闲鱼上架该选什么商品? 7. 卖…

城市消费券,拒绝恶意爬取

作为提振经济的重要把手,城市消费券的作用不言而喻。公开数据显示,2022 年全国各地公布的消费券累计超 100 万亿,在撬动各地消费的过程中起到了举足轻重的作用。 然而,仔细分析各地的核销率就会发现,有很大一部分消费…

Zookeeper系列文章—入门

目录 前言 测试 创建节点 更改节点 删除节点 前言 遵照前文已经对Zookeeper进行了安装 linux安装Zookeeper3.5.7详解_兜兜转转m的博客-CSDN博客 接下来我们从整体架构方面了解一下Zookeeper: ZooKeeper 是一个树形目录服务,其数据模型和Unix的文件系统目录树很类…

安装完Vmware-tools后找不到共享文件夹的解决办法-Ubuntu 18有效

首先确认VMware-tools安装好了 如果VMware-tools一直灰色,可以根据这篇文章的方式解决:解决VMware Tools灰色的方法 设置共享文件夹 如果找不到共享文件夹,可以先尝试这个方法:共享文件夹设置方式 特殊情况解决方法 在VMware…

Java:阻塞队列BlockingQueue与应用场景

目录 阻塞队列 BlockingQueue的常用方法 生产者消费者应用场景 阻塞队列 阻塞队列BlockingQueue继承自父类Queue,该队列是线程安全的,可以安全的与多个生产者和消费者线程一起使用。 与阻塞队列相对的,存在“非阻塞队列”的概念&#xff0c…

Python采集某购物软件数据信息,轻松拿捏千元外包项目

前言 嗨嗨,想必知道外包这个词的人应该不少吧 话说,接外包有多的也有少的,少的几十,多的emm上限我就不说了,嘿嘿 今天要不要来看看一个千元的外包项目? 是采集某购物软件的一些数据信息 咋说&#xff…

Excel常用图表,看看哪个还不会?

图表是指可以直接展示数据关于时间、数量等关系,对知识挖掘和信息直观生动感起关键作用的图形结果,是对数据关系进行形象“可视化”的手段。所以将数据转换为图表能使数据更为直观。 常见图表 Excel为用户提供了10几种图表,包括柱形图、折线…

【网安神器篇】——Crunch字典生成工具

作者名:Demo不是emo 主页面链接:主页传送门 创作初心:舞台再大,你不上台,永远是观众,没人会关心你努不努力,摔的痛不痛,他们只会看你最后站在什么位置,然后羡慕或鄙夷座…

小啊呜产品读书笔记001:《邱岳的产品手记-07》第13讲 无用却必要:产品规划【上】 第14讲 留白与节奏:产品规划【下】

小啊呜产品读书笔记001:《邱岳的产品手记-07》第13讲 无用却必要:产品规划【上】 & 第14讲 留白与节奏:产品规划【下】一、今日阅读计划二、泛读&知识摘录1、第13讲 无用却必要:产品规划【上】2、第14讲 留白与节奏&#…

Linux set 命令的使用方法

Linux set 命令的使用方法 set 语句是内置的 shell 命令,可以显示并设置 shell 和 Linux 的环境变量。在这篇文章中,我们将尝试使用 set 命令,并且进行一些简单的剖析。 预备工作 请登录您的终端,或者打开虚拟机并且连接&#x…

出海淘金TikTok,正确姿势是什么?

提起海外版抖音TikTok,相信大家并不陌生。TikTok在继美国封禁风波之后,虽然在美国市场的扩张受到了一定阻碍,但并不妨碍它的电商领域在英国市场以及东南亚市场混得风生水起。据统计,TikTok目前是Apple App Store上下载次数最多的应…

显示DataFrame中每行(或列)中,每个位置以前出现过的最小值:cummin()函数

【小白从小学Python、C、Java】 【计算机等级考试500强双证书】 【Python-数据分析】 显示DataFrame中每行(或列)中 每个位置以前出现过的最小值 cummin()函数 选择题 下列说法错误的是? import pandas as pd myDF pd.DataFrame({"A":[5,2,6], "B":[9…

通用后台管理系统前端界面Ⅸ——数据表格渲染及处理+前端分页

1、找 在页面添加table表格&#xff0c;从element-ui官网查找&#xff0c;包括数据一起复制过来&#xff0c;查看显示没有问题后&#xff0c;把tableData清空为空数组。 <template><div><el-table :data"tableData" height"auto" border …

智慧燃气解决方案-最新全套文件

智慧燃气解决方案-最新全套文件一、建设背景二、建设思路三、建设方案四、获取 - 智慧燃气全套最新解决方案合集一、建设背景 近年来城市燃气取得了巨大的发展&#xff0c;我们在享受清洁能源带来方便的同时&#xff0c;也带来了新的问题&#xff1a; ● 居民用户数量的大量增…

想知道如何图片转文字?这几个方法你别错过

工作中我们经常要处理很多含有文字的图片&#xff0c;并且大多数时候我们都需要里面的文字内容&#xff0c;如果你一个一个对照着码出来的话&#xff0c;这是很费时费力的工程&#xff0c;其实我们可以想办法将图片内容转换成文字&#xff0c;然后直接复制就可以使用了。那么你…

第十章:字典树(trie)与并查集

第十章&#xff1a;字典树&#xff08;trie&#xff09;与并查集一、字典树&#xff08;trie&#xff09;引入1、什么是字典树&#xff1f;2、思路分析3、复杂度分析4、模板&#xff08;1&#xff09;问题&#xff1a;&#xff08;2&#xff09;模板&#xff1a;&#xff08;3&…

vscode开发高频、通用插件集合(精选15个)

vscode开发通用插件集合1.Live Serve2. Chinese3. GitLens4. Color Highlight5. Highlight Matching Tag6. any-rule7. Time Master 或 Code Time8. Vetur9. ESLint10. Vue-format11. ENV12. background13. Code Runner14. Local History15. Postcode此文仅是本人多年的一些经验…

在全链路追踪中加入对方法(Method)追踪

在全链路追踪中加入对方法(Method)追踪 全链路追踪主要是在微服务场景下&#xff0c;实现了服务和服务之间的调用链关系。 这次尝试一下在单体应用中&#xff0c;怎么在全链路追踪技术中加入对方法(Method)追踪。 单体应用是用Springboot开放的一个简单CRUD应用&#xff0c;全…