hacktricks/mobile-pentesting/ios-pentesting/ios-uiactivity-sharing.md

83 lines
5.4 KiB
Markdown
Raw Normal View History

2024-02-08 03:08:28 +00:00
# iOS UIActivity Sharing
2022-04-28 16:01:33 +00:00
<details>
2024-01-12 07:54:15 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-01-12 07:54:15 +00:00
Other ways to support HackTricks:
2022-04-28 16:01:33 +00:00
2024-01-12 07:54:15 +00:00
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-09 12:24:06 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2024-01-12 07:54:15 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-02-08 03:08:28 +00:00
# UIActivity Sharing Simplified
2022-04-28 16:01:33 +00:00
2024-02-08 03:08:28 +00:00
From iOS 6 onwards, third-party applications have been enabled to **share data** such as text, URLs, or images using mechanisms like AirDrop, as outlined in Apple's [Inter-App Communication guide](https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW3). This feature manifests through a system-wide _share activity sheet_ that surfaces upon interacting with the "Share" button.
2024-02-08 03:08:28 +00:00
A comprehensive enumeration of all the built-in sharing options is available at [UIActivity.ActivityType](https://developer.apple.com/documentation/uikit/uiactivity/activitytype). Developers may opt to exclude specific sharing options if they deem them unsuitable for their application.
2024-02-08 03:08:28 +00:00
## **How to Share Data**
2024-02-08 03:08:28 +00:00
Attention should be directed towards:
2024-02-08 03:08:28 +00:00
- The nature of the data being shared.
- The inclusion of custom activities.
- The exclusion of certain activity types.
2024-02-08 03:08:28 +00:00
Sharing is facilitated through the instantiation of a `UIActivityViewController`, to which the items intended for sharing are passed. This is achieved by calling:
```bash
$ rabin2 -zq Telegram\ X.app/Telegram\ X | grep -i activityItems
0x1000df034 45 44 initWithActivityItems:applicationActivities:
```
2024-02-08 03:08:28 +00:00
Developers should scrutinize the `UIActivityViewController` for the activities and custom activities it's initialized with, as well as any specified `excludedActivityTypes`.
2024-02-08 03:08:28 +00:00
## **How to Receive Data**
2024-02-08 03:08:28 +00:00
The following aspects are crucial when receiving data:
2024-02-08 03:08:28 +00:00
- The declaration of **custom document types**.
- The specification of **document types the app can open**.
- The verification of the **integrity of the received data**.
2024-02-08 03:08:28 +00:00
Without access to the source code, one can still inspect the `Info.plist` for keys like `UTExportedTypeDeclarations`, `UTImportedTypeDeclarations`, and `CFBundleDocumentTypes` to understand the types of documents an app can handle and declare.
2024-02-08 03:08:28 +00:00
A succinct guide on these keys is available on [Stackoverflow](https://stackoverflow.com/questions/21937978/what-are-utimportedtypedeclarations-and-utexportedtypedeclarations-used-for-on-i), highlighting the importance of defining and importing UTIs for system-wide recognition and associating document types with your app for integration in the "Open With" dialogue.
2024-02-08 03:08:28 +00:00
## Dynamic Testing Approach
2024-02-08 03:08:28 +00:00
To test **sending activities**, one could:
2024-02-08 03:08:28 +00:00
- Hook into the `init(activityItems:applicationActivities:)` method to capture the items and activities being shared.
- Identify excluded activities by intercepting the `excludedActivityTypes` property.
2024-02-08 03:08:28 +00:00
For **receiving items**, it involves:
2024-02-08 03:08:28 +00:00
- Sharing a file with the app from another source (e.g., AirDrop, email) that prompts the "Open with..." dialogue.
- Hooking `application:openURL:options:` among other methods identified during static analysis to observe the app's response.
- Employing malformed files or fuzzing techniques to evaluate the app's robustness.
2022-04-28 16:01:33 +00:00
2024-02-08 03:08:28 +00:00
## References
* [https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06h-testing-platform-interaction](https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06h-testing-platform-interaction)
2022-04-28 16:01:33 +00:00
<details>
2024-01-12 07:54:15 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-01-12 07:54:15 +00:00
Other ways to support HackTricks:
2022-04-28 16:01:33 +00:00
2024-01-12 07:54:15 +00:00
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-09 12:24:06 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2024-01-12 07:54:15 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>