# module not found? just pip install modulename
import os
import requests
import time
from multiprocessing.dummy import Pool as ThreadPool
from colorama import Fore, Style
from urllib3.exceptions import InsecureRequestWarning
from fake_useragent import UserAgent
requests.packages.urllib3.disable_warnings()

bl = Fore.BLUE
wh = Fore.WHITE
gr = Fore.GREEN
red = Fore.RED
res = Style.RESET_ALL
yl = Fore.YELLOW

headers = {'User-Agent': UserAgent().random}

def screen_clear():
    os.system('cls' if os.name == 'nt' else 'clear')

def dbman(star, config_file, result_file):
    if "://" not in star:
        star = "http://" + star
    star = star.replace('\n', '').replace('\r', '')
    url = star + config_file
    try:
        check = requests.get(url, headers=headers, timeout=5, verify=False)
        if check.status_code == 200:
            resp = check.text
            if "pma_password" in resp or "auth[password]" in resp:
                print(f"DBManager {gr}OK{res} => {star}\n")
                with open(result_file, "a") as f:
                    f.write(f'{url}\n')
            else:
                print(f"{red}Not Found{res} DBManager => {star}\n")
    except requests.exceptions.RequestException as e:
        print(f"{red}ERROR{res} {str(e)} => {star}\n")

def filter(star, result_file):
    dbman(star, "/adminer.php", result_file)
    dbman(star, "/phpmyadmin/index.php", result_file)
    dbman(star, "/myadmin/index.php", result_file)
    dbman(star, "/dbadmin/index.php", result_file)
    dbman(star, "/sql/index.php", result_file)
    dbman(star, "/phpadmin/index.php", result_file)
    dbman(star, "/mysql/index.php", result_file)
    dbman(star, "/pma/index.php", result_file)
    dbman(star, "/phpmyadmin2/index.php", result_file)
    dbman(star, "/sqlmanager/index.php", result_file)
    dbman(star, "/mysqlmanager/index.php", result_file)
    dbman(star, "/adminer/index.php", result_file)

def main():
    print(f'{gr}[ DBManager$Finder ]')
    list_file = input(f"{gr}Gimme your {red}list{gr}:{res} ")
    thread_count = int(input(f"{gr}Thread: {res}"))
    result_file = input(f"{gr}Result filename: {res}")
    with open(list_file, 'r') as f:
        star = f.readlines()
    try:
        with ThreadPool(thread_count) as pool:
            pool.map(lambda x: filter(x, result_file), star)
    except:
        pass

if __name__ == '__main__':
    screen_clear()
    main()