Windows Lower Port Open condition

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.