> For the complete documentation index, see [llms.txt](https://hacktricks.xsx.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacktricks.xsx.tw/mobile-pentesting/ios-pentesting/ios-app-extensions.md).

# iOS App Extensions

<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)，我们的独家[**NFT**](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>

应用扩展通过允许应用与其他应用或系统进行交互，提供自定义功能或内容，增强了应用的功能。这些扩展包括：

* **自定义键盘**：在所有应用中提供独特的键盘，替代默认的 iOS 键盘。
* **共享**：允许直接与社交网络或其他人分享。
* **今日视图（小部件）**：从通知中心的今日视图快速传递内容或执行任务。

当用户与这些扩展进行交互时，例如从主机应用程序共享文本，扩展会在其上下文中处理此输入，利用共享的信息执行其任务，详细信息请参阅 Apple 的文档。

### **安全考虑**

关键的安全方面包括：

* 扩展及其包含的应用程序通过进程间通信进行通信，而不是直接通信。
* **今日小部件**是独特的，因为它可以请求其应用程序通过特定方法打开。
* 允许在私有容器内共享数据访问，但限制直接访问。
* 某些 API，包括 HealthKit，对应用程序扩展是禁止的，应用程序扩展也不能启动长时间运行的任务，访问相机或麦克风，除了 iMessage 扩展。

### 静态分析

#### **识别应用程序扩展**

要在源代码中查找应用程序扩展，请在 Xcode 中搜索 `NSExtensionPointIdentifier`，或检查应用程序包中指示扩展的 `.appex` 文件。如果没有源代码，请使用 grep 或 SSH 在应用程序包中定位这些标识符。

#### **支持的数据类型**

检查扩展的 `Info.plist` 文件以查找 `NSExtensionActivationRule`，以识别支持的数据类型。这种设置确保只有兼容的数据类型会触发主机应用程序中的扩展。

#### **数据共享**

应用程序与其扩展之间的数据共享需要一个共享容器，通过“应用程序组”进行设置，并通过 `NSUserDefaults` 访问。这个共享空间对于扩展发起的后台传输是必要的。

#### **限制扩展**

应用程序可以限制某些扩展类型，特别是自定义键盘，确保敏感数据处理符合安全协议。

### 动态分析

动态分析包括：

* **检查共享项目**：钩入 `NSExtensionContext - inputItems`，查看共享的数据类型和来源。
* **识别扩展**：通过观察内部机制（如 `NSXPCConnection`）发现哪些扩展处理您的数据。

像 `frida-trace` 这样的工具可以帮助理解底层进程，特别是对于那些对进程间通信的技术细节感兴趣的人。

## 参考资料

* <https://mas.owasp.org/MASTG/iOS/0x06h-Testing-Platform-Interaction/>
* <https://mas.owasp.org/MASTG/tests/ios/MASVS-PLATFORM/MASTG-TEST-0072/>

<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)，我们的独家[**NFT**](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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/ios-pentesting/ios-app-extensions.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.
