From 09b5e2df3148348b5bcb486f3b8d1a5e104190e7 Mon Sep 17 00:00:00 2001 From: six Date: Thu, 22 Feb 2024 04:17:06 +0000 Subject: [PATCH] Add v9serv_check.py --- v9serv_check.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 v9serv_check.py diff --git a/v9serv_check.py b/v9serv_check.py new file mode 100644 index 0000000..5c46349 --- /dev/null +++ b/v9serv_check.py @@ -0,0 +1,39 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- +import requests +import concurrent.futures + +services = [ +'https://g6.network/', +'https://cryptoctf.org/', +] + +ip_address = "209.250.246.26" +ports = [80, 443] + +def check_service(srv): + try: + r = requests.get(srv, timeout=4) # Added timeout for better control + if r.status_code != 200: + print(f"{srv}\n{r.status_code}") + except Exception as e: # It's better to catch a specific exception, but for demonstration, we use a general one. + print(f"Problem with {srv}: {e}") + +def check_ports(port): + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: + sock.settimeout(4) + result = sock.connect_ex((ip_address, port)) + if result == 0: + print(f"{ip_address} on port {port}: OPEN") + else: + print(f"{ip_address} on port {port}: CLOSED or FILTERED") + +# Use ThreadPoolExecutor to manage a pool of threads +# Adjust the max_workers based on your requirements or leave it as default to let Python decide +with concurrent.futures.ThreadPoolExecutor(max_workers=120) as executor: + # Map the function and its arguments to the executor + # The map function returns results in the order that the calls were started + executor.map(check_service, services) + +with concurrent.futures.ThreadPoolExecutor(max_workers=120) as executor: + executor.map(check_ports, ports) \ No newline at end of file