break a time, with break the c0de…

portscanner.py


This is python port scanner finished by me :This is python port scanner finished by me :

#!/usr/bin/python
# -*- coding: utf-8 -*-
# -*- port scanner by gunslinger_ feb 9 2010
# -*- usage : ./portscanner -t [targethost] -s [startport] -e [endport]
 
import sys
from socket import *

asciitext = '''
                   _                                          
                  | |                                         
  _ __   ___  _ __| |_   ___  ___  __ _ _ __  _ __   ___ _ __ 
 | '_ \ / _ \| '__| __| / __|/ __|/ _` | '_ \| '_ \ / _ \ '__|
 | |_) | (_) | |  | |_  \__ \ (__| (_| | | | | | | |  __/ |   
 | .__/ \___/|_|   \__| |___/\___|\__,_|_| |_|_| |_|\___|_|   
 | |                                                          
 |_|                                               by gunslinger_  '''

option = '''
Usage: ./portscanner.py [options]
Options: -t, --target    <hostname/ip>   |   Target to bruteforcing
         -s, --start     <portstart>     |   Number start port scanning
         -e, --end       <portend>       |   Number end port scanning
         -h, --help      <help>          |   print this help

Example: ./portscanner.py -t 192.168.1.1 -s 0 -e 8000

'''

for arg in sys.argv:
	if arg.lower() == '-t' or arg.lower() == '--target':
           hostname = sys.argv[int(sys.argv[1:].index(arg))+2]
	elif arg.lower() == '-s' or arg.lower() == '--start':
           startport = sys.argv[int(sys.argv[1:].index(arg))+2]
	elif arg.lower() == '-e' or arg.lower() == '--end':
	   endport = sys.argv[int(sys.argv[1:].index(arg))+2]
	elif arg.lower() == '-h' or arg.lower() == '--help':
	  print (asciitext)
	  print (option)
	  sys.exit
	elif len(sys.argv) <= 1 or 2 or 3 or 4 or 5 or 6:
	  print (asciitext)
	  print (option)
	  sys.exit()
 
for port in range(int(startport), int(endport)):
    try:
      socket(AF_INET, SOCK_STREAM).connect((hostname, port)); 
      print "[+] port is open ::", port
    except: 
      pass

Example :

                   _
                  | |
  _ __   ___  _ __| |_   ___  ___  __ _ _ __  _ __   ___ _ __
 | '_ \ / _ \| '__| __| / __|/ __|/ _` | '_ \| '_ \ / _ \ '__|
 | |_) | (_) | |  | |_  \__ \ (__| (_| | | | | | | |  __/ |
 | .__/ \___/|_|   \__| |___/\___|\__,_|_| |_|_| |_|\___|_|
 | |
 |_|                                               by gunslinger_

Usage: ./portscanner.py [options]
Options: -t, --target    <hostname/ip>   |   Target to bruteforcing
         -s, --start     <portstart>     |   Number start port scanning
         -e, --end       <portend>       |   Number end port scanning
         -h, --help      <help>          |   print this help

Example: ./portscanner.py -t 192.168.1.1 -s 0 -e 8000

gunslinger@localhost:~/python/python_documenter$

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s