Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/04/2009, 09:00
Avatar de farra
farra
 
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 2 meses
Puntos: 20
por ejemplo pones en la variable GET esto:

-1/**/UNION/**/ALL/**/SELECT/**/1,2,concat(username,0x3a,password),null,5,6/**/FROM
/**/usuarios/*

y te traera todos los usuarios de claves de una pagina web con registro de usuarios, claro dependiendo del numero de columnas que tenga la tabla tenes que adaptar ese codigo...

el XSS es facil de atajar... simplemente usando htmlentities();

pero el sqlinyection, es un poquito mas dificil pero tambien se puede atajar...

por ejemplo:
Código PHP:
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

mira:
http://www.forosdelweb.com/f18/ejemp...on-sql-314674/
http://www.forosdelweb.com/f13/evita...on-sql-357475/
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)

Última edición por GatorV; 16/04/2009 a las 10:59