# iOS UIActivity Sharing

## iOS UIActivity Sharing

<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>

## UIActivity Sharing Simplified

从iOS 6开始，第三方应用程序可以使用AirDrop等机制共享文本、URL或图像等数据，如苹果的[应用间通信指南](https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW3)中所述。此功能通过系统范围的\_共享活动表\_实现，用户与“分享”按钮交互时会出现该表。

可以在[UIActivity.ActivityType](https://developer.apple.com/documentation/uikit/uiactivity/activitytype)中找到所有内置共享选项的详尽枚举。开发人员可以选择排除特定的共享选项，如果认为这些选项不适合其应用程序。

### **如何共享数据**

应注意以下内容：

* 要共享的数据的性质。
* 包括自定义活动。
* 排除某些活动类型。

通过实例化`UIActivityViewController`来实现共享，将要共享的项目传递给它。这可以通过调用实现：

```bash
$ rabin2 -zq Telegram\ X.app/Telegram\ X | grep -i activityItems
0x1000df034 45 44 initWithActivityItems:applicationActivities:
```

开发人员应该仔细审查`UIActivityViewController`的初始化活动和自定义活动，以及任何指定的`excludedActivityTypes`。

### **如何接收数据**

在接收数据时，以下几个方面至关重要：

* **自定义文档类型**的声明。
* 指定应用程序可以打开的**文档类型**。
* 验证接收数据的**完整性**。

即使没有访问源代码，也可以检查`Info.plist`中的键，如`UTExportedTypeDeclarations`，`UTImportedTypeDeclarations`和`CFBundleDocumentTypes`，以了解应用程序可以处理和声明的文档类型。

关于这些键的简明指南可在[Stackoverflow](https://stackoverflow.com/questions/21937978/what-are-utimportedtypedeclarations-and-utexportedtypedeclarations-used-for-on-i)上找到，强调了定义和导入UTIs以供系统广泛识别，并将文档类型与您的应用程序关联以在“打开方式”对话框中集成的重要性。

### 动态测试方法

要测试**发送活动**，可以：

* 钩入`init(activityItems:applicationActivities:)`方法以捕获正在共享的项目和活动。
* 通过拦截`excludedActivityTypes`属性来识别排除的活动。

对于**接收项目**，涉及：

* 从其他来源（例如AirDrop，电子邮件）与应用程序共享文件，以触发“打开方式...”对话框。
* 钩入`application:openURL:options:`等在静态分析期间识别的其他方法，以观察应用程序的响应。
* 使用格式错误的文件或模糊技术来评估应用程序的健壮性。

### 参考资料

* <https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06h-testing-platform-interaction>


---

# 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/ios-pentesting/ios-uiactivity-sharing.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.
