import socket
import time
import threading
def scan_port(ip,port):
try:
s = socket.socket()
s.settimeout(0.001)
s.connect((ip,port))
print(port)
s.close()
except:
pass
def scan_all_port(ip,max_port):
for port in range(1,max_port):
threading._start_new_thread(scan_port,(ip,port))
time.sleep(0.001)
if __name__ == '__main__':
ip = socket.gethostbyname(socket.gethostname())
scan_all_port(ip,65535)
Python 端口扫描
最新推荐文章于 2024-04-08 00:47:24 发布