Turn from
Use Python to write a simple instance of Port scanner sharing _python_ script House http://www.jb51.net/article/76630.htm
-*-Coding:utf8-*-#!/usr/bin/python#python:2.7.8#platform:windows#AUTHRO:WUCL#Program : Port scan#history:2015.6.1 Importsocket, time, threadsocket.setdefaulttimeout (3) defSocket_port (ip,port):"""Enter IP and port number, scan to determine if port is open""" Try: ifport>=65535: PrintU'end of port scan's=Socket.socket (socket.af_inet, socket. SOCK_STREAM) Result=s.connect_ex ((ip,port))ifresult==0:lock.acquire ()PrintIp,u':', Port,u'Port Open'lock.release () s.close ( )except: PrintU'Port Scan Exception' defIp_scan (IP):"""input IP, scan the IP 0-65534 port case""" Try: PrintU'Start Scan%s'%IP start_time=time.time () forIinchRange (0,65534): Thread.start_new_thread (Socket_port, (Ip,int (i)))PrintU'Scan Port Complete, total time:%.2f'% (Time.time ()-start_time) raw_input ("Press Enter to Exit") except: PrintU'Error Scanning IP' if __name__=='__main__': URL=raw_input ('Input the IP want to scan:\n') Lock=Thread.allocate_lock () ip_scan (URL)
Use Python to write a simple instance of port scanner share "Go"