Use Python to write a simple instance of port scanner share "Go"

Source: Internet
Author: User

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"

Related Article

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.