Simple port Scan

Source: Internet
Author: User

TCP connection scanning, based on sockets, uses threading to implement multi-threading and to control the number of processes.


Note: The Threads_limit variable depends on the host, and there are too many definitions to make the following error:


650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/86/F2/wKiom1fPfPGTqgnjAAAL7L75bGQ904.png-wh_500x0-wm_3 -wmp_4-s_3950277187.png "title=" 1.png "alt=" Wkiom1fpfpgtqgnjaaal7l75bgq904.png-wh_50 "/>


Code:

Import socketimport threading#change these vars.start_port  = 20end_port  = 1000host =  ' 8.8.8.8 ' threads_limit = 600open_port = []mylock =  threading. Lock () Def scan_port (port):     global mylock    mysock =  socket.socket (Socket.af_inet, socket. SOCK_STREAM)     if  (MYSOCK.CONNECT_EX ((host, port))  == 0):         mylock.acquire ()         open_ Port.append (port)         mylock.release () for will_scan_port  In range (start_port, end_port+1):     mythread = threading. Thread (target = scan_port, args = (Will_scan_port,))     mythread.start ( )         #limit  thread number    while  (Len (Threading.enumerate ())  >= 600):         pass    print open_port


This article is from "retrograde person" blog, declined reprint!

Simple port Scan

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.