ajithkp560

Directory Scanner

Nov 3rd, 2012
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.92 KB | None | 0 0
  1. #
  2. # Share it with friends
  3. # Download full files[Dictionary] it from: http://packetstormsecurity.org/files/117773/Directory-Scanner-Tool.html
  4. # Read it : http://terminalcoders.blogspot.in/2012/10/python-directory-admin-page-phpmyadmin.html
  5. # mail me ajithkp560 [at] gmail.com
  6. #
  7. # Greets to TOF members Coded32, null void, X-Hund, Evis, John, Alex and all Unkown members
  8. # Love to AMSTECK COLLEGE, Kalliasseri : Dheeraj, Ashwin, Jhelai, Arjun, Vipin, Jitendra
  9. # Special Thanqs to Vishnu_Nath [W3P]
  10. #
  11. # Thanks: WEBSPLOIT FRAME WORK: for provide large list of Directory List
  12. #
  13. # For Exit use Ctrl+C
  14. #
  15. import time
  16. import urllib2
  17. from urllib2 import Request, urlopen, URLError
  18. import socket
  19. import sys
  20. import httplib
  21. from urlparse import urlparse
  22.  
  23. tot=0
  24. found=0
  25.  
  26. BLUE = '\033[94m'
  27. RED = '\033[91m'
  28. GREEN = '\033[32m'
  29.  
  30.  
  31. timeout = 10
  32. socket.setdefaulttimeout(timeout)
  33. print "\n"
  34. try:
  35.     print GREEN+"\t################################################################"
  36.     print "\t# http://TerminalCoders.BlogSpot.iN      OpenFire-Security.Net #"
  37.     print "\t#       ###############      ########       ############       #"
  38.     print "\t#       #             #     ##      ##      #          #       #"
  39.     print "\t#       ######   ######     ##      ##      #   ########       #"
  40.     print "\t#            #   #          ##      ##      #   #              #"
  41.     print "\t#            #   #          ##      ##      #   #####          #"
  42.     print "\t#            #   #          ##      ##      #   #####          #"
  43.     print "\t#            #   #          ##      ##      #   #              #"
  44.     print "\t#            #   #          ##      ##      #   #              #"
  45.     print "\t#            #####    [#]    ########   [#] #####              #"
  46.     print "\t#                                                              #"
  47.     print "\t# coded by Ajith KP                        DirDictionaryBruter #"
  48.     print "\t#                          Greets to Coded32 and T.O.F members #"
  49.     print "\t################################################################"
  50.     var1=0
  51.     var2=0
  52.     site = raw_input(RED+"\nURL"+BLUE+"[http/https]"+RED+"> "+GREEN)
  53.     parse=urlparse(site)
  54.     name=parse.netloc
  55.     l_file="logs/"+name+".log"
  56.     try:
  57.         try:
  58.             create=open(l_file, "w")
  59.         except(IOError):
  60.             print(GREEN+"Failed to create file: "+name+".log")
  61.         print (GREEN+"\n\tChecking website " + site + "...")
  62.         conn = urllib2.Request(site)
  63.         urllib2.urlopen(site)
  64.         print RED+"\t[V]"+GREEN+" Yes... Server is Online."+GREEN
  65.     except (urllib2.HTTPError) as Exit:
  66.         print(GREEN+"\t[!] Oops Error occured")
  67.         raw_input(GREEN+"\t[!] Possible problems: Server offline, Invalid URL,Internet offline")      
  68.         exit()
  69.     try:
  70.         dirlist = open("files/directory", "r")
  71.         adm_php = open("files/admin/php", "r")
  72.         adm_asp = open("files/admin/asp", "r")
  73.         adm_cgi = open("files/admin/cgi", "r")
  74.         adm_jsp = open("files/admin/jsp", "r")
  75.         adm_brf= open("files/admin/brf", "r")
  76.         adm_cfm = open("files/admin/cfm", "r")
  77.         php_my_adm = open("files/phpMyAdmin", "r")
  78.         shells = open("files/shells", "r")
  79.     except(IOError):
  80.         print GREEN+"Some File Not Found!"
  81.         exit()
  82.     print(RED+"\n\nSelect Option:\n\n"+GREEN+"\t1 Directory Scan\n\t2 Admin Page Scan\n\t3 phpMyAdmin Scan\n\t4 Shell Scan")
  83.     option=input(GREEN+"\n   >> "+RED)
  84.     if option==1:
  85.         dirs = dirlist.readlines()
  86.     if option==2:
  87.         print(RED+"\nSELECT FILE TYPE:\n\n"+GREEN+"\t1 PHP\n\t2 ASP\n\t3 JSP\n\t4 CGI\n\t5 CFM\n\t6 BRF")
  88.         adm_opt=input(GREEN+"\n   >> "+RED)
  89.         if adm_opt==1:
  90.             dirs = adm_php.readlines()
  91.         if adm_opt==2:
  92.             dirs = adm_asp.readlines()
  93.         if adm_opt==3:
  94.             dirs = adm_jsp.readlines()
  95.         if adm_opt==4:
  96.             dirs = adm_cgi.readlines()
  97.         if adm_opt==5:
  98.             dirs = adm_cfm.readlines()
  99.         if adm_opt==6:
  100.             dirs = adm_brf.readlines()
  101.     if option==3:
  102.         dirs = php_my_adm.readlines()
  103.     if option==4:
  104.         dirs = shells.readlines()
  105.  
  106.     print(GREEN+"\n\n\t[+]"+BLUE+" Scanning " +RED+ site + "\n")
  107.     for dirz in dirs:
  108.         dirz=dirz.replace("\n","")
  109.         dirz="/"+dirz
  110.         url_z=site+dirz
  111.         print(RED+"--> "+GREEN+"Checking "+ BLUE + url_z)
  112.         req=Request(url_z)
  113.         time.sleep(2)
  114.         try:
  115.             response = urlopen(req)
  116.         except URLError, e:
  117.             if hasattr(e, 'reason'):
  118.                 print(RED+"\t[x] "+GREEN+"Not Found")
  119.                 tot=tot+1
  120.             elif hasattr(e, 'code'):
  121.                 print(RED+"\t[x] "+GREEN+"Not Found")
  122.                 tot=tot+1
  123.         else:
  124.             try:
  125.                 logs=open(l_file, "a+")
  126.             except(IOError):
  127.                 print RED+"\t[x] Failed to create DirLogs.log"
  128.             found_url=url_z
  129.             print(RED+"\t>>>"+GREEN+" Found "+RED+found_url)
  130.             logs.writelines(found_url+"\n")
  131.             found=found+1
  132.             tot=tot+1
  133.             logs.close()
  134.    
  135.     print BLUE+"\t\nTotal scanned:",tot
  136.     print GREEN+"\tFound:",found
  137.     print RED+"\nFounded Logs are saved in %s.log, Read it" %(name)
  138.     print GREEN+"\n"
  139. except (httplib.HTTPResponse, urllib2.HTTPError, socket.error):
  140.     print "\n\t[!] Session Cancelled; Error occured. Check internet settings"
  141.     print RED+"\n\t[!] Session cancelled"
  142.     print BLUE+"\t\nTotal scanned:",tot
  143.     print GREEN+"\tFound:",found
  144.     print RED+"\nFounded Logs are saved in"+GREEN+" %s"+RED+", Read it" %(l_file)
  145.     print GREEN+"\n"
  146. except (KeyboardInterrupt, SystemExit):
  147.     print RED+"\n\t[!] Session cancelled"
  148.     print BLUE+"\t\nTotal scanned:",RED,tot
  149.     print GREEN+"\tFound:",RED,found
  150.     print GREEN+"\nFounded Logs are saved in \""+RED+"/%s"%(l_file)+GREEN+"\" , Read it"
  151.     print GREEN+"\n"
Advertisement
Add Comment
Please, Sign In to add comment