吃了个火鸡面后感觉到了怀疑人生!!!!!!!!!
妈耶,在也不吃了。思路都给辣没了!!!
python端口扫描器代码如下:
#-*-coding:utf-8 from socket import * import threading import argpars lock=threading.lock() openNUm=0 threads=[] def portScanner(host,port): global openNum try: s=socket(AF_INET,SOCK_STREAM) s.connect(host,port) lock.acquire() openNum+=1 print('[*]open port%d'%(port)) loc.release() s.close() except: pass def main(): p=argparse.ArgumentParse(description='Portscanner') p.add_argument('-H',dest='host',type=str) args=p.parse_args() hostList=args.host.split(',') setdefaulttimeout(1) for host in hostList: print('Scanning the host:%s.......'%(host)) for p in range(1,1024): t=threading.Thread(target=portScanner,args=(host,port)) threads.append(t) t.start() for t in threads: t.join() if__name__=='__main__': main()
运行截图:(kali傻了在换iso中。。。。)
端口扫描器思路:
一开始是先让python给指定的IP和端口发包来断定是否开放的端口!
但是如果一个一个打印出来会耗费时间。然后在加上多线程模块,加上argpars模块,
让我们的程序能快速运行加上命令参数!