This applet is implemented under Windows to detect which ports are currently open.
You can probe a native port or enter a custom IP.
Reference URL:
Scan Port Condition:
Http://bbs.chinaunix.net/thread-4180079-1-1.html
Get the native IP
http://blog.csdn.net/blade2001/article/details/3975389
#-*-Coding:utf8-*-#!/usr/bin/python#python:2.7#platform:windows#AUTHRO:LYC#Program : Port scan#history:2015.10.13 Importsocket, time, threadsocket.setdefaulttimeout (3) defSocket_port (ip,port,portlist):"""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'portlist.append (port) lock.release () s.close ()except: PrintU'Port Scan Exception' defIp_scan (IP):"""input IP, scan the IP 0-65534 port case"""portlist= [] Try: PrintU'Start Scan%s'%IP start_time=time.time () forIinchRange (0,65534): Thread.start_new_thread (Socket_port, (Ip,int (i), portlist))PrintU'Scan Port Complete, total time:%.2f'% (Time.time ()-start_time)#return all open port numbers returnportlistexcept: PrintU'Error Scanning IP' if __name__=='__main__': #View native PortsMyName =Socket.getfqdn (Socket.gethostname ()) Myaddr=socket.gethostbyname (myname)#Enter the custom IP #myaddr = raw_input (' Input the IP want to scan:\n ')Lock =Thread.allocate_lock () Ip_scan (MYADDR)
Windows Lower Port Open condition