标签:rom app target decode def pop start [] 代码
利用TCP连接创建一个socket扫描port
上代码:
#TCP import socket from threading import Thread def get_port(open_port,host,ports): while True: if ports: port = ports.pop(0) c = socket.socket(socket.AF_INET,socket.SOCK_STREAM) c.settimeout(0.5) try: c.connect((host,port)) except socket.timeout as e: print(‘[-]%d‘ % port) del c else: print(‘[+]%d‘ % port) c.send(‘1‘.encode()) portocol = c.recv(1024).decode() open_port[port] = portocol c.close() del c else: break def main(): host = "192.168.1.33" open_port = {} ports = list(range(1,65535)) t_list = [] for var in range(100): t_list.append(Thread(target=get_port,args=(open_port,host,ports,))) for t in t_list: t.start() for t in t_list: t.join() get_port(open_port,host,ports) print(open_port) if __name__ == ‘__main__‘: main()
标签:rom app target decode def pop start [] 代码
原文地址:https://www.cnblogs.com/kmnskd/p/9928357.html