Objection 教程
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
介绍
objection - 运行时移动探索
Objection 是一个由 Frida 提供支持的运行时移动探索工具包。它的目标是帮助评估移动应用及其安全态势,而无需越狱或 root 的移动设备。
注意: 这并不是某种越狱 / root 绕过。使用 objection 时,你仍然受制于目标应用所在沙箱施加的所有限制。
概述
The goal of objection is let the user call the main actions that offers Frida. Otherwise, the user will need to create a single script for every application that he wants to test.
教程
在本教程中,我将使用可以在此处下载的 APK:
或者从其 original repository (download app-release.apk)
安装
pip3 install objection
连接
建立一个 常规 ADB 连接 并在设备上 启动 frida server(并检查 frida 在 client 和 server 两端是否正常工作)。
如果你使用的是 rooted device,则需要在 –gadget 选项中选择你要测试的应用。在本例中:
frida-ps -Uai
objection --gadget asvid.github.io.fridaapp explore
基本操作
本教程不会列出 objections 的所有可能命令,仅包含我认为更有用的那些。
环境
在环境中可能会发现一些有趣的信息(例如 passwords 或 paths)。
env
.png)
Frida 信息
frida
.png)
上传/下载
file download <remote path> [<local path>]
file upload <local path> [<remote path>]
导入 frida 脚本
import <local path frida-script>
SSLPinning
android sslpinning disable #Attempts to disable SSL Pinning on Android devices.
Root 检测
android root disable #Attempts to disable root detection on Android devices.
android root simulate #Attempts to simulate a rooted Android environment.
执行命令
android shell_exec whoami
截图
android ui screenshot /tmp/screenshot
android ui FLAG_SECURE false #This may enable you to take screenshots using the hardware keys
Static analysis 动态化
在真实的应用中,在使用 objection 之前,我们应该通过 static analysis 得到本节中发现的所有信息。无论如何,通过这种方式你也许能看到 一些新东西,因为这里你只会得到类、方法和 exported objects 的完整列表。
如果某种情况下你无法获取应用的可读源代码,这也很有用。
列出 activities、receivers 和 services
android hooking list activities
.png)
android hooking list services
android hooking list receivers
如果未找到,Frida 会抛出错误
获取当前 Activity
android hooking get current_activity
.png)
搜索类
让我们开始在应用程序中查找类
android hooking search classes asvid.github.io.fridaapp
.png)
搜索类的方法
现在让我们提取类 MainActivity: 中的方法
android hooking search methods asvid.github.io.fridaapp MainActivity
.png)
列出类中声明的方法及其参数
让我们找出该类的方法需要哪些参数:
android hooking list class_methods asvid.github.io.fridaapp.MainActivity
.png)
列出类
你也可以列出当前应用程序中已加载的所有类:
android hooking list classes #List all loaded classes, As the target application gets usedmore, this command will return more classes.
这在你想要 hook the method of a class and you only know the name of the class 且只知道该 class 名称时非常有用。你可以使用这个函数来 search which module owns the class,然后 hook 它的 method。
Hooking being easy
Hooking (watching) a method
From the source code of the application we know that the function sum() from MainActivity is being run every second. Lets try to dump all possible information each time the function is called (参数、返回值 和 backtrace):
android hooking watch class_method asvid.github.io.fridaapp.MainActivity.sum --dump-args --dump-backtrace --dump-return
.png)
Hooking (监视) 整个类
实际上,我觉得 MainActivity 类的所有方法都很有趣,让我们 hook 它们全部。注意,这可能会导致应用程序 crash。
android hooking watch class asvid.github.io.fridaapp.MainActivity --dump-args --dump-return
If you play with the application while the class is hooked you will see when 每个函数被调用、它的 参数 和 返回值。
.png)
更改函数的 boolean 返回值
从源代码可以看到函数 checkPin 接受一个 String 作为参数并返回一个 boolean。让该函数 始终返回 true:
.png)
现在,如果你在 PIN 码的文本框中输入任何内容,你会看到任何输入都被视为有效:
.png)
类实例
搜索并打印由完全限定类名指定的 特定 Java class 的实时实例。Out 是尝试为已发现的 objection 获取字符串值的结果,该字符串通常 包含该对象的属性值。
android heap print_instances <class>
.png)
Keystore/Intents
你可以使用以下方式操作 keystore 和 intents:
android keystore list
android intents launch_activity
android intent launch_service
内存
转储
memory dump all <local destination> #Dump all memory
memory dump from_base <base_address> <size_to_dump> <local_destination> #Dump a part
列表
memory list modules
.png)
在列表的底部你可以看到 frida:
.png)
让我们查看 frida 导出了什么:
.png)
搜索/写入
你也可以使用 objection 在内存中搜索和写入:
memory search "<pattern eg: 41 41 41 ?? 41>" (--string) (--offsets-only)
memory write "<address>" "<pattern eg: 41 41 41 41>" (--string)
SQLite
您可以使用命令 sqlite 与 sqlite 数据库交互。
退出
exit
我在 Objection 中缺少的功能
- Hooking 方法有时会导致应用程序崩溃(这也与 Frida 有关)。
- 你不能使用类的实例来调用该实例的方法,也不能创建类的新实例并用它们来调用方法。
- 没有像 sslpinnin 那样的快捷方式,可以 hook 应用使用的所有常见加密方法,以查看密文、明文、密钥、IV 和所用算法。
参考资料
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
HackTricks

