android - 如何使用 androguard 或 aapt 从 .apk 中提取过滤器意图?
问题描述
我需要从 APK 文件中提取过滤器意图功能,我可以使用开源库 androguard 提取权限和硬件组件,我使用它的 APK 类来提取功能,但是对于过滤器意图,我遇到了错误。
*************
filter_intent_accepted = apk.get_intent_filters()
TypeError: get_intent_filters() missing 2 required positional arguments: 'itemtype' and 'name'
Process finished with exit code 1
我还检查了他们发表评论的功能。我尝试了所有可能的论点,但没有得到任何结果。
功能是:
def get_intent_filters(self, itemtype, name):
"""
Find intent filters for a given item and name.
Intent filter are attached to activities, services or receivers.
You can search for the intent filters of such items and get a dictionary of all
attached actions and intent categories.
:param itemtype: the type of parent item to look for, e.g. `activity`, `service` or `receiver`
:param name: the `android:name` of the parent item, e.g. activity name
:return: a dictionary with the keys `action` and `category` containing the `android:name` of those items
"""
d = {"action": [], "category": []}
for i in self.xml:
# TODO: this can probably be solved using a single xpath
for item in self.xml[i].findall(".//" + itemtype):
if self._format_value(item.get(NS_ANDROID + "name")) == name:
for sitem in item.findall(".//intent-filter"):
for ssitem in sitem.findall("action"):
if ssitem.get(NS_ANDROID + "name") not in d["action"]:
d["action"].append(ssitem.get(NS_ANDROID + "name"))
for ssitem in sitem.findall("category"):
if ssitem.get(NS_ANDROID + "name") not in d["category"]:
d["category"].append(ssitem.get(NS_ANDROID + "name"))
if not d["action"]:
del d["action"]
if not d["category"]:
del d["category"]
return d
我应该将哪些参数传递给函数?我已经尝试过它的定义示例,但我无法弄清楚。提前致谢。
解决方案
def printIntentFilters(itemtype, name):
print ('\t' + name + ':')
for action,intent_name in apk.get_intent_filters(itemtype, name).items():
print ('\t\t' + action + ':')
for intent in intent_name:
print ('\t\t\t' + intent)
return
# Intent filters
print('\nServices and their intent-filters:')
services = apk.get_services()
serviceString = 'service'
for service in services:
printIntentFilters(serviceString, service)
print('\nReceivers and their intent-filters:')
receivers = apk.get_receivers()
receiverString = 'receiver'
for receiver in receivers:
printIntentFilters(receiverString, receiver)
推荐阅读
- inno-setup - Inno Setup - 自动生成选项以允许用户选择要安装的文件
- python - 谷歌分析在报告 API 中获取用户 ID
- c++ - 将指向临时 std::string 的指针传递给另一个线程
- bash - 如果程序打印了某些消息,如何在bash中继续while循环?
- reactjs - github 页面的子文件夹向我显示旧的反应代码而不是新网站
- z3 - 来自 z3 模型的 NoneType 输出
- asp.net-core - 在 ASP.NET Core 3 应用程序中检索 IIS 的 ApplicationName
- java - 如何从 Java 桌面(Netbeans)上的 firebase 检索数据
- sql - PostgreSQL 子查询数组返回整行而不是单列
- ansible - 如何使用 Ansible 模块将 Base64 var 解码为二进制文件