飘逸的python - 写个端口扫描器及各种并发尝试(多线程/多进程/gevent/futures)
端口扫描器原理很简单,无非就是操作socket,能connect就认定这个端口开放着。importsocket
defscan(port):
s=socket.socket()
ifs.connect_ex(('localhost',port))==0:
printport,'open'
s.close()
if__name__=='__main__':
map(scan,range(1,6553