# Objection Tutorial

<details>

<summary><strong>从零开始学习 AWS 黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS 红队专家）</strong></a><strong>！</strong></summary>

支持 HackTricks 的其他方式：

* 如果您想看到您的**公司在 HackTricks 中做广告**或**下载 PDF 版本的 HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方 PEASS & HackTricks 商品**](https://peass.creator-spring.com)
* 探索[**PEASS 家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或在 **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live) 上**关注**我们。
* 通过向 [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github 仓库提交 PR 来**分享您的黑客技巧**。

</details>

<img src="/files/wQPam8C1YmPwZ2KLeMOE" alt="" data-size="original">

**漏洞赏金提示**：**注册** Intigriti，一个由黑客创建的高级**漏洞赏金平台**！立即加入我们，开始赚取高达\*\*$100,000\*\*的赏金！[**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks)

{% embed url="<https://go.intigriti.com/hacktricks>" %}

## **介绍**

**objection - 运行时移动应用探索**

[**Objection**](https://github.com/sensepost/objection) 是一个由[Frida](https://www.frida.re)驱动的运行时移动应用探索工具包。它旨在帮助评估移动应用及其安全状况，而无需越狱或 root 移动设备。

**注意：** 这不是某种越狱/ root 绕过。通过使用 `objection`，您仍然受到您所面对的适用沙盒施加的所有限制的限制。

### 简历

**objection** 的**目标**是让用户调用**Frida 提供的主要操作**。**否则**，用户将需要为他想要测试的每个应用程序创建**单独的脚本**。

## 教程

在本教程中，我将使用您可以在此处下载的 APK：

{% file src="/files/Du0Uaf6pE6GAXvKiIHqk" %}

或从其[原始存储库](https://github.com/asvid/FridaApp)（下载 app-release.apk）

### 安装

```bash
pip3 install objection
```

### 连接

建立一个**常规的ADB连接**并在设备上**启动**frida服务器（并检查frida在客户端和服务器上的工作情况）。

如果您使用的是**已root的设备**，需要在\_**--gadget**\_选项中选择要测试的应用程序。在这种情况下：

```bash
frida-ps -Uai
objection --gadget asvid.github.io.fridaapp explore
```

### 基本操作

本教程中不会列出所有可能的objection命令，只列出我发现最有用的命令。

#### 环境

一些有趣的信息（如密码或路径）可能会在环境中找到。

```bash
env
```

#### Frida 信息

```bash
frida
```

![](/files/IXg4B3wDiy95JXQH80Jt)

#### 上传/下载

```bash
file download <remote path> [<local path>]
file upload <local path> [<remote path>]
```

#### 导入 frida 脚本

```bash
import <local path frida-script>
```

#### SSLPinning

#### SSL证书绑定

```bash
android sslpinning disable #Attempts to disable SSL Pinning on Android devices.
```

#### Root检测

```bash
android root disable  #Attempts to disable root detection on Android devices.
android root simulate #Attempts to simulate a rooted Android environment.
```

#### 执行命令

```bash
android shell_exec whoami
```

#### 截图

```bash
android ui screenshot /tmp/screenshot
android ui FLAG_SECURE false  #This may enable you to take screenshots using the hardware keys
```

### 静态分析变为动态

在真实应用中，在使用objection之前，我们应该通过**静态分析**了解本部分发现的所有信息。无论如何，通过这种方式，也许你可以看到**一些新的东西**，因为在这里你只会得到一个完整的类、方法和导出对象列表。

如果你**无法获取一些可读的源代码**，这也是有用的。

#### 列出活动、接收器和服务

```bash
android hooking list activities
```

![](/files/BfEZ5HOWD0VOpqEsGGOh)

```bash
android hooking list services
android hooking list receivers
```

### 获取当前活动

Frida 如果找不到任何内容将会启动一个错误

#### 获取当前活动

```bash
android hooking get current_activity
```

![](/files/BjBzphq9XpEdPBd4xPmc)

#### 搜索类

让我们开始查找应用程序中的类

```bash
android hooking search classes asvid.github.io.fridaapp
```

![](/files/nXG1pJYTnwbm0vH9Qe39)

#### 搜索类的方法

现在让我们提取\_MainActivity\_类中的方法：

```bash
android hooking search methods asvid.github.io.fridaapp MainActivity
```

![](/files/jlIQTtBO6p4x6OUSOmKQ)

#### 列出类的声明方法及其参数

让我们找出类的方法需要哪些参数：

```bash
android hooking list class_methods asvid.github.io.fridaapp.MainActivity
```

![](/files/RrDLRNUebbnJVznt4I0E)

#### 列出类

您还可以列出当前应用程序中加载的所有类：

```bash
android hooking list classes #List all loaded classes, As the target application gets usedmore, this command will return more classes.
```

这在你想要**挂钩一个类的方法，但只知道类名**时非常有用。您可以使用此函数**搜索拥有该类的模块**，然后挂钩其方法。

### 挂钩变得容易

#### 挂钩（监视）一个方法

从应用程序的[源代码](https://github.com/asvid/FridaApp/blob/master/app/src/main/java/asvid/github/io/fridaapp/MainActivity.kt)中，我们知道**来自** ***MainActivity*** **的** ***sum()*** **函数** 每秒运行一次。让我们尝试在每次调用该函数时**转储所有可能的信息**（参数、返回值和回溯）：

```bash
android hooking watch class_method asvid.github.io.fridaapp.MainActivity.sum --dump-args --dump-backtrace --dump-return
```

![](/files/Qg0t0xYcltAIP2CC43Xd)

#### 钩住（监视）整个类

实际上，我发现 MainActivity 类的所有方法都非常有趣，让我们**钩住它们全部**。请注意，这可能会**导致应用程序崩溃**。

```bash
android hooking watch class asvid.github.io.fridaapp.MainActivity --dump-args --dump-return
```

如果您在挂钩类时操作应用程序，您将看到**每个函数被调用**时，其**参数**和**返回**值。

![](/files/OjSJ3Hwtt20GQguQkAyR)

#### 更改函数的布尔返回值

从源代码中，您可以看到函数\_checkPin\_接收一个\_String\_作为参数，并返回一个\_boolean\_。让我们使函数**始终返回true**：

![](/files/Qg2aGBhdoc3AhzzhQRtN)

现在，如果您在PIN码文本框中输入任何内容，您将看到任何内容都是有效的：

![](/files/6eWCf5AoRoOgNEiCd9jU)

### 类实例

搜索并打印特定Java类的**活动实例**，由完全限定的类名指定。输出是尝试获取已发现的异议的字符串值的结果，该值通常**包含对象的属性值**。

```
android heap print_instances <class>
```

![](/files/I6haezBqIIyJhp29zkvp)

### Keystore/Intents

您可以使用以下方式操作密钥库和意图：

```bash
android keystore list
android intents launch_activity
android intent launch_service
```

### 内存

#### 转储

```bash
memory dump all <local destination> #Dump all memory
memory dump from_base <base_address> <size_to_dump> <local_destination> #Dump a part
```

#### 列表

```bash
memory list modules
```

![](/files/pwKZDSqzd6a5GAaHWskT)

在列表底部，您可以看到frida：

![](/files/bfrV3XbvmzCZSDlWuW2Q)

让我们来检查一下frida导出了什么：

![](/files/cnR846ADrM5TkamLcKyB)

#### 搜索/写入

您还可以使用objection在内存中搜索和写入。

```bash
memory search "<pattern eg: 41 41 41 ?? 41>" (--string) (--offsets-only)
memory write "<address>" "<pattern eg: 41 41 41 41>" (--string)
```

### SQLite

您可以使用命令 `sqlite` 与 SQLite 数据库进行交互。

### 退出

```bash
exit
```

## 我在Objection中缺少的功能

* 钩子方法有时会导致应用程序崩溃（这也是因为Frida）。
* 无法使用类的实例来调用实例的函数。也无法创建新的类实例并使用它们来调用函数。
* 没有快捷方式（类似于sslpinnin）来钩住应用程序正在使用的所有常见加密方法，以查看加密文本、明文、密钥、IV和使用的算法。

<img src="/files/wQPam8C1YmPwZ2KLeMOE" alt="" data-size="original">

**漏洞赏金提示**：**注册**Intigriti，这是一家由黑客创建的高级**漏洞赏金平台**！立即加入我们，让您的赏金高达\*\*$100,000\*\*！[**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks)

{% embed url="<https://go.intigriti.com/hacktricks>" %}

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS Red Team Expert）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想在HackTricks中看到您的**公司广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)！
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS Family**](https://opensea.io/collection/the-peass-family)，我们的独家[NFTs](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacktricks.xsx.tw/mobile-pentesting/android-app-pentesting/frida-tutorial/objection-tutorial.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
