> 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/pentesting-web/unicode-injection.md).

# Unicode Injection

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

## 简介

根据后端/前端在**接收奇怪的Unicode字符**时的行为，攻击者可能能够**绕过保护措施并注入任意字符**，从而可能被用于**滥用注入漏洞**，如XSS或SQLi。

## Unicode规范化

Unicode规范化发生在**将Unicode字符规范化为ASCII字符**时。

这种类型漏洞的常见情况是，系统在**检查用户输入后**以某种方式**修改**用户的**输入**。例如，在某些语言中，对输入进行**大写或小写处理**可能会规范化给定的输入，**将Unicode转换为ASCII**生成新字符。\
更多信息请查看：

{% content-ref url="/pages/i5C88ceIqzZR2f1RuVPY" %}
[Unicode Normalization](/pentesting-web/unicode-injection/unicode-normalization.md)
{% endcontent-ref %}

## `\u`转换为`%`

Unicode字符通常用\*\*`\u`前缀**表示。例如，字符`㱋`是`\u3c4b`（**[**在此处检查**](https://unicode-explorer.com/c/3c4B)**）。如果后端**将前缀`\u`转换为`%`**，则结果字符串将为`%3c4b`，解码后为：**`<4b`**。正如您所见，**`<`字符被注入\*\*。\
如果后端存在漏洞，您可以使用此技术**注入任何类型的字符**。\
请访问<https://unicode-explorer.com/>查找您需要的字符。

这个漏洞实际上源自一位研究人员发现的漏洞，有关更详细的解释，请查看<https://www.youtube.com/watch?v=aUsAHb0E7Cg>

## 表情符号注入

后端在**接收表情符号**时有时会表现出奇怪的行为。这就是发生在[**这篇文章**](https://medium.com/@fpatrik/how-i-found-an-xss-vulnerability-via-using-emojis-7ad72de49209)中的情况，研究人员成功通过如下有效负载实现XSS：`💋img src=x onerror=alert(document.domain)//💛`

在这种情况下，错误在于服务器在删除恶意字符后**将UTF-8字符串从Windows-1252转换为UTF-8**（基本上是输入编码和转换编码不匹配）。然后这不会给出一个正确的`<`，而是一个奇怪的Unicode字符：`‹`\
\`\`因此，他们拿到这个输出后**再次从UTF-8转换为ASCII**。这将**将`‹`规范化为`<`**，这就是该系统上漏洞利用的原理。\
这就是发生的情况：

```php
<?php

$str = isset($_GET["str"]) ? htmlspecialchars($_GET["str"]) : "";

$str = iconv("Windows-1252", "UTF-8", $str);
$str = iconv("UTF-8", "ASCII//TRANSLIT", $str);

echo "String: " . $str;
```

表情符号列表：

* <https://github.com/iorch/jakaton_feminicidios/blob/master/data/emojis.csv>
* <https://unicode.org/emoji/charts-14.0/full-emoji-list.html>

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