python-检测指定端口

 1 import socket
 2 
 3 sk = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
 4 sk.settimeout(1)
 5 
 6 
 7 for ip in range(0,254):
 8     try:
 9         sk.connect(("192.168.1."+str(ip),443))
10         print("192.168.1.%d server open \n"%ip)
11     except Exception:
12         print("192.168.1.%d server not open"%ip)
13 
14 sk.close()

猜你喜欢

转载自www.cnblogs.com/LyShark/p/9066943.html
今日推荐