import socket import concurrent.futures import os def clear_screen(): if os.name == "nt": os.system("cls") else: os.system("clear") def scan_port(port): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(1) result = sock.connect_ex((target_server, port)) if result == 0: open_ports.append(port) sock.close() except socket.error: pass def is_valid_ip(target_server): try: socket.inet_aton(target_server) return True except socket.error: return False clear_screen() print(""" ██████╗██╗ ██╗ ██╗ ████████╗ ██████╗ ██████╗ ██╗ ██╔════╝██║ ██║ ██║ ╚══██╔══╝██╔═══██╗██╔═══██╗██║ ██║ ███████║ ██║ ██║ ██║ ██║██║ ██║██║ ██║ ╚════██║██ ██║ ██║ ██║ ██║██║ ██║██║ ╚██████╗ ██║╚█████╔╝ ██║ ╚██████╔╝╚██████╔╝███████╗ ╚═════╝ ╚═╝ ╚════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ BY : Amoo_zanjirrbuf """) target_server = input("Enter the server IP: ") if not is_valid_ip(target_server): print("Invalid server IP. Please enter a valid IP address.") exit() clear_screen() print(""" ████████╗██╗ ██╗███████╗ █████╗ ██████╗ ███████╗██████╗ ███████╗ ╚══██╔══╝██║ ██║██╔════╝██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔════╝ ██║ ███████║█████╗ ███████║██████╔╝█████╗ ██║ ██║███████╗ ██║ ██╔══██║██╔══╝ ██╔══██║██╔══██╗██╔══╝ ██║ ██║╚════██║ ██║ ██║ ██║███████╗██║ ██║██║ ██║███████╗██████╔╝███████║ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═════╝ ╚══════╝ """) threads = input("How many ports should I scan per second? (Recommended is 30): ") max_workers = int(threads) clear_screen() starting_port = input("the starting port : ") ending_port = input("the ending port : ") open_ports = [] port_range = range(int(starting_port), int(ending_port)) num_ports_scanned = 0 print(""" ███████╗ ██████╗ █████╗ ███╗ ██╗███╗ ██╗██╗███╗ ██╗ ██████╗ ██╔════╝██╔════╝██╔══██╗████╗ ██║████╗ ██║██║████╗ ██║██╔════╝ ███████╗██║ ███████║██╔██╗ ██║██╔██╗ ██║██║██╔██╗ ██║██║ ███╗ ╚════██║██║ ██╔══██║██║╚██╗██║██║╚██╗██║██║██║╚██╗██║██║ ██║ ███████║╚██████╗██║ ██║██║ ╚████║██║ ╚████║██║██║ ╚████║╚██████╔╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ """) with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor: futures = [executor.submit(scan_port, port) for port in port_range] for future in concurrent.futures.as_completed(futures): num_ports_scanned += 1 print(f"Scanned {num_ports_scanned}/{len(port_range)} ports.", end="\r") clear_screen() print(""" ██████╗ ██████╗ ███████╗███╗ ██╗ ██╔═══██╗██╔══██╗██╔════╝████╗ ██║ ██║ ██║██████╔╝█████╗ ██╔██╗ ██║ ██║ ██║██╔═══╝ ██╔══╝ ██║╚██╗██║ ╚██████╔╝██║ ███████╗██║ ╚████║ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ██████╗ ██████╗ ██████╗ ████████╗███████╗ ██╔══██╗██╔═══██╗██╔══██╗╚══██╔══╝██╔════╝ ██████╔╝██║ ██║██████╔╝ ██║ ███████╗ ██╔═══╝ ██║ ██║██╔══██╗ ██║ ╚════██║ ██║ ╚██████╔╝██║ ██║ ██║ ███████║ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ """) if open_ports: print("IP : " + target_server) print("\nOpen ports:") for port in open_ports: print(port) else: print("\nNo open ports found try turning threads lower. \n\n")