-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
30 lines (27 loc) · 1.29 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import ipaddress, requests
from multiprocessing import Process
import time, random
ip_ranges = [line.strip() for line in open('ips.txt', 'r').readlines()] #IP ranges
def range_test(network, ping):
for ip in network:
try:
start_time = time.time()
result = requests.get(f"https://{ip}/__down", timeout=(10,10))
end_time = time.time()
ping_time = round((end_time - start_time) * 1000, 2)
if int(ping_time) <= ping:
print(f"Good IP : {ip} (Ping: {ping_time} ms)")
except Exception as e:
if "CERTIFICATE_VERIFY_FAILED" in str(e):
end_time = time.time()
ping_time = round((end_time - start_time) * 1000, 2)
if int(ping_time) <= ping:
print(f"Good IP : {ip} (Ping: {ping_time} ms)")
if __name__ == '__main__':
ping = int(input('Enter the maximum delay (Ping) ms <= 10000 : '))
number_of_ranges = int(input('Enter a number of IP ranges you want scan randomly (Enter a lower number for weak CPU) : '))
ip_ranges = random.sample(ip_ranges, number_of_ranges)
for ip_range in ip_ranges:
print(ip_range, 'Started !')
network = ipaddress.ip_network(ip_range)
Process(target=range_test, args=(network, ping)).start()