Port Scan Tool

Source: Internet
Author: User

Simple multi-threaded port scanning Tool

You can receive an IP address as a parameter, and if you do not, the port of the native is scanned by default

1 #!/usr/bin/python2 3 ImportSocket4 Import Time5 ImportArgparse6 ImportThreading7 8 defarg_process ():9Argparser=argparse. Argumentparser (description="Port Scaner")TenArgparser.add_argument ('- I.','--ip', action='Store', dest='IP', default='localhost') Oneargs=Argparser.parse_args () Aip=Args.ip -     returnIP -  the defScan (ip,port): -     ifport>=65535: -         Pass -     Else: +Addr=(Ip,port) -sock=Socket.socket (Socket.af_inet,socket. SOCK_STREAM) +         Try: Astatus=sock.connect_ex (addr) at             ifstatus==0: -                 Print "%d opened"%Port -          -         except: -             Pass -         finally: in sock.close () -  to defMain (start,stop): +ip=arg_process () -      forPortinchRange (start,stop): the Scan (ip,port) *  $ Panax Notoginseng if __name__=='__main__': -t1=time.time () thethreads=[] +      forIinchRange (20): AT=threading. Thread (target=main,args= (3277*i,3277* (i+1))) the threads.append (t) +      forTinchThreads: - T.setdaemon (True) $ T.start () $ T.join () -T2=time.time () -delta=t2-T1 the     Print "It spend%d seconds"%delta

Port Scan Tool

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.