端口扫描器(自己写的,感谢某位大牛的指导)
import threading
import Queue
import os
import socket
def test_port(host,port):
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
s.connect_ex((host,port))
s.close
return True;
except:
return False;
def main(host,queue):
while True:
try:
port=queue.get(timeout=1)
except:
break
if test_port(host,port):
print "%s: %s" % (host,port)
if __name__=='__main__':
queue=Queue.Queue();
for i in range(60000):
queue.put(i)
host='192.168.1.213'
tmp=[]
for _ in xrange(800):
t=threading.Thread(target=main,args=(host,queue))
t.setDaemon(True)
t.start()
for t in tmp:
t.join()