Simple Port Scanner


Simple Port Scanner source code

#!/usr/bin/python
import sys,os
from socket import *
os.system('clear')

def about():
        print "#################################################"
        print "# Simple Port Scanner"
        print "# DDR encoding"
        print "# Blog chennaihackers.blogspot.com"
        print "#################################################"
def usage():
        print "[?] usage : ./portScan.py 1 65500 IP --- All PORTS"
        print "[?] usage : ./portScan.py 21      IP --- Single PORT"

def main():
        if (int(len(sys.argv))==1):
                about()
                usage()

        if (int(len(sys.argv)) == 3):
                #one port
                about()
                try:socket(AF_INET, SOCK_STREAM).connect((sys.argv[2], int(sys.argv[1]))); print "[!] PORT : ", int(sys.argv[1])," OPEN"
                except: pass

        if (int(len(sys.argv)) == 4):
                #range
                about()
                port = 0
                for port in range( int(sys.argv[1]) , int(sys.argv[2]) ):
                        try:socket(AF_INET, SOCK_STREAM).connect((sys.argv[3], port)); print "[!] PORT : ", port," OPEN"
                        except: pass
main()
print "#############################"
print "http://chennaihackers.blogspot.com"
print "====>CHENNAI HACKERS CONNECT<===="
print "#############################"


To Copy the Source code:
http://pastie.org/7152102

0 comments: