使用python實(shí)現(xiàn)掃描端口示例
2017-06-18 08:31:05
10636
python最簡(jiǎn)潔易懂的掃描端口代碼.運(yùn)行絕對(duì)會(huì)很有驚奇感
from threading import Thread, activeCount
import socket
import os
def test_port(dst,port):
os.system('title '+str(port)) cli_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
indicator = cli_sock.connect_ex((dst, port))
if indicator == 0:
print(port)
cli_sock.close()
except:
pass
if __name__=='__main__':
dst = '192.168.0.22'
i = 0
while i < 65536:
if activeCount() <= 200:
Thread(target = test_port, args = (dst, i)).start()
i = i + 1
while True:
if activeCount() == 2:
break
input('Finished scanning.')
會(huì)員登錄
賬號(hào)登錄還沒(méi)有賬號(hào)?立即注冊(cè)