-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmash.py
36 lines (28 loc) · 1003 Bytes
/
smash.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
31
32
33
34
35
36
#!/usr/bin/python
import socket
import concurrent.futures
TIMEOUT = 2.0 # You can change the duratoin
def isHTTPsAlive(childId, host):
try:
isHTTP = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
isHTTP.settimeout(TIMEOUT)
isHTTPS = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
isHTTPS.settimeout(TIMEOUT)
http = isHTTP.connect_ex((host, 80)) == 0
https = isHTTPS.connect_ex((host, 443)) == 0
isHTTP.close()
isHTTPS.close()
except:
(http, https) = (False, False)
if http or https:
print (host)
else:
pass
if __name__ == '__main__':
hostFile = str(input('List of Hosts [ex: hosts.txt] : '))
threads = int(input('Threads [ex: 30] : '))
Hosts = open(hostFile, 'r').read().splitlines()
with concurrent.futures.ThreadPoolExecutor(max_workers=threads) as \
pool_executor:
for host in Hosts:
pool_executor.submit(isHTTPsAlive, 0, host)