#__Coding__Onefat__utf_8
import socket
import threading
def test(host,port):
clint=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
clint.settimeout(4)
try:
clint.connect(host,port)
print("sucess %s:%d",host,port)
except Exception:
print("%s:%d connect fail....",host,port)
ip_file=open("host.txt")
port_file=open("port.txt")
ip_list=[]
port_list=[]
for host in ip_file:
ip_list.append(host.strip())
for port in port_file:
port_list.append(port.strip())
ip_file.close()
port_file.close()
threads=[]
for host in ip_list:
for port in port_list:
t=threading.Thread(target=test,args=(host,port))
threads.append(t)
for threads in threads:
threads.start()
for threads in threads:
threads.join()