Advertisement
ajithkp560

TOF Port Scanner

May 22nd, 2012
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.18 KB | None | 0 0
  1. #If u like this
  2. #share it via facebook and twitter
  3. import httplib
  4. from socket import *
  5. print "\t################################################################"
  6. print "\t#                                        www.teamopenfire.com  #"
  7. print "\t#       ###############      ########       ############       #"
  8. print "\t#       #             #     ##      ##      #          #       #"
  9. print "\t#       ######   ######     ##      ##      #   ########       #"
  10. print "\t#            #   #          ##      ##      #   #              #"
  11. print "\t#            #   #          ##      ##      #   #####          #"
  12. print "\t#            #   #          ##      ##      #   #####          #"
  13. print "\t#            #   #          ##      ##      #   #              #"
  14. print "\t#            #   #          ##      ##      #   #              #"
  15. print "\t#            #####    [#]    ########   [#] ##### Port Scanner #"
  16. print "\t#                                                              #"
  17. print "\t#                                            coded by Ajith KP #"
  18. print "\t#                          Greets to Coded32 and T.O.F members #"
  19. print "\t################################################################"
  20.  
  21. try:
  22.     site = raw_input("WebSite/IP: ")
  23.     site = site.replace("http://","")
  24.     print ("\t\nChecking website " + site + "...")
  25.     conn = httplib.HTTPConnection(site)
  26.     conn.connect()
  27.     print "\t\n[OK] Server is Online.\n"
  28. except (httplib.HTTPResponse, socket.error) as Exit:
  29.     print("\t [X] Oops Error occured")
  30.     raw_input("\t [X] Possible problems: Server offline, Invalid URL,Internet offline\n")      
  31.     exit()
  32. ip = gethostbyname(site)
  33. print 'Scanning ', site, ip,'...\n\n'
  34.  
  35. try:
  36.     for port in range(20,2000): #change the port range here
  37.         scan = socket(AF_INET, SOCK_STREAM)
  38.         connect = scan.connect_ex((ip, port))
  39.         if (connect == 0) :
  40.             print  "\tPort",port,": Open"
  41.         else : #if you don't want scan closed ports erase from else: to....
  42.             print "port",port,": Close" #.....print "Port,port,":Open" ...here
  43.         scan.close()
  44.  
  45. except (KeyboardInterrupt, SystemExit):
  46.     print "\n\t[X] Session cancelled"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement