Last active
March 1, 2025 10:11
-
-
Save im-hanzou/44bc88e371b97425a8d90b87c536260d to your computer and use it in GitHub Desktop.
Mass Scan opened 3306 port using multiprocessing. Install library mysql (pip install mysql-connector-python colorama)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import mysql.connector | |
| import multiprocessing | |
| import re | |
| from colorama import init, Fore | |
| init(autoreset=True) | |
| def check_mysql_port(host): | |
| port = 3306 | |
| try: | |
| connection = mysql.connector.connect( | |
| host=host, | |
| port=port, | |
| user='root', | |
| password='toor', | |
| connection_timeout=5 | |
| ) | |
| print(Fore.GREEN + "Remote MySQL Service:" + Fore.CYAN + f"{port} " + Fore.GREEN + "for " + Fore.MAGENTA + f"{host} " + Fore.GREEN + "IS OPENED.") | |
| with open('hostlive.txt', 'a') as live_file: | |
| live_file.write(f"{host}\n") | |
| connection.close() | |
| except mysql.connector.errors.ProgrammingError as err: | |
| if 'using password' in str(err): | |
| print(Fore.GREEN + "Remote MySQL Service:" + Fore.CYAN + f"{port} " + Fore.GREEN + "for " + Fore.MAGENTA + f"{host} " + Fore.GREEN + "IS OPENED.") | |
| with open('hostlive.txt', 'a') as live_file: | |
| live_file.write(f"{host}\n") | |
| else: | |
| print(Fore.RED + "Remote MySQL Service:" + Fore.CYAN + f"{port} " + Fore.RED + "for " + Fore.MAGENTA + f"{host} " + Fore.RED + "IS LOGIN DISABLED.") | |
| except mysql.connector.errors.InterfaceError as err: | |
| print(Fore.RED + "Remote MySQL Service:" + Fore.CYAN + f"{port} " + Fore.RED + "for " + Fore.MAGENTA + f"{host} " + Fore.RED + "IS CLOSED/RESTRICTED.") | |
| except mysql.connector.errors.DatabaseError as err: | |
| if '1130 (HY000)' in str(err): | |
| print(Fore.RED + "Remote MySQL Service:" + Fore.CYAN + f"{port} " + Fore.RED + "for " + Fore.MAGENTA + f"{host} " + Fore.RED + "IS RESTRICTED.") | |
| else: | |
| print(Fore.RED + "Remote MySQL Service:" + Fore.CYAN + f"{port} " + Fore.RED + "for " + Fore.MAGENTA + f"{host} " + Fore.RED + "IS CLOSED.") | |
| except Exception as err: | |
| print(Fore.YELLOW + f"Error: {err} HOST ERROR!:" + Fore.MAGENTA + f"{host}") | |
| def process_host_list(host_list): | |
| with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool: | |
| pool.map(check_mysql_port, host_list) | |
| def clean_host(host): | |
| return re.sub(r'^https?://', '', host).split('/')[0] | |
| if __name__ == "__main__": | |
| banner = """ | |
| ================================ | |
| | IM-Hanzou MySQL Port Scanner | | |
| ================================ | |
| """ | |
| print(Fore.MAGENTA + banner) | |
| file_name = input(Fore.CYAN + "Host Lists filename: ") | |
| try: | |
| with open(file_name, 'r') as file: | |
| hosts = [clean_host(line.strip()) for line in file.readlines()] | |
| process_host_list(hosts) | |
| print(Fore.CYAN + "\nScan complete and saved to: " + Fore.MAGENTA + "hostlive.txt") | |
| except FileNotFoundError: | |
| print(Fore.RED + f"File {file_name} not found.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment