Ver Mensaje Individual
  #8 (permalink)  
Antiguo 05/01/2010, 13:51
Avatar de TKZeXe
TKZeXe
 
Fecha de Ingreso: diciembre-2009
Ubicación: Flowers
Mensajes: 166
Antigüedad: 14 años, 4 meses
Puntos: 6
Respuesta: Ayuda con Blind SQL Injection

Con gusto te paso una función que tengo en una de mis webs.
que por lo demas son muy atacadas jajaj (de juegos),
usalas y pasalas al que te las pida, todo sea por ayudar en algo. ^^

Código PHP:
Ver original
  1. function check_inject()
  2.   {
  3.     $badchars = array(";","'","*","/"," \ ","DROP", "SELECT", "UPDATE", "DELETE", "drop", "select", "update", "delete", "WHERE", "where", "-1", "-2", "-3","-4", "-5", "-6", "-7", "-8", "-9",);
  4.    
  5.     foreach($_POST as $value)
  6.     {
  7.     $value = clean_variable($value);
  8.  
  9.     if(in_array($value, $badchars))
  10.       {
  11.         die("SQL Injection Detected - Make sure only to use letters and numbers!\n<br />\nIP: ".$_SERVER['REMOTE_ADDR']);
  12.       }
  13.       else
  14.       {
  15.         $check = preg_split("//", $value, -1, PREG_SPLIT_OFFSET_CAPTURE);
  16.         foreach($check as $char)
  17.         {
  18.           if(in_array($char, $badchars))
  19.           {
  20.             die("SQL Injection Detected - Make sure only to use letters and numbers!\n<br />\nIP: ".$_SERVER['REMOTE_ADDR']);
  21.           }
  22.         }
  23.       }
  24.     }
  25.   }
  26. function clean_variable($var)
  27.     {
  28.     $newvar = preg_replace('/[^a-zA-Z0-9\_\-]/', '', $var);
  29.     return $newvar;
  30.     }