import socket
import threading
import queue
#定一个消息队列
q = queue.Queue()
def scanner(host):
while not q.empty():
#当消息队列不为空的时候就从中取一个端口
port = q.get()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.00000000000001)
if not s.connect_ex((host, port)):
print(f'[+]{host}:{port} is open\n')
host = input('ip:')
for port in range(1, 65536):
#将端口放入消息队列中
q.put(port)
for _ in range(1024):
#启动线程
threading.Thread(target = scanner, args = (host)).start()
Python多线程端口扫描
最新推荐文章于 2024-06-17 17:35:06 发布