Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/03/2012, 21:36
diego007
 
Fecha de Ingreso: enero-2012
Ubicación: en la casa
Mensajes: 34
Antigüedad: 12 años, 3 meses
Puntos: 0
Respuesta: Impedir la inyección código en mi pagina

Gracias gildus, creo que solucione el problema usando lo siguiente:
Código PHP:
if($ordenar == ""){
    
$ordenar " fecha DESC ";
}else{
    if(
$ordenar == "desendente"){
        
$ordenar " precio DESC ";
    }else{
        if(
$ordenar == "ascendente"){
            
$ordenar " precio ASC ";
        }else{
            if(
$ordenar == "nuevo"){
                
$ordenar " fecha DESC ";
            }else{
                if(
$ordenar == "antiguo"){
                    
$ordenar " fecha ASC ";
                }else{
                    
$ordenar " fecha DESC ";
                } 
y
Código PHP:
$pagina stripslashes(mysql_real_escape_string(htmlspecialchars(@$_GET["pagina"])));
$ejemplo strlen($pagina);
if (
$ejemplo 3){
    
$pagina 1;

ingrese de nuevo las direcciones y ya no me da ningún problema, el único problema sera cuando la pagina tenga mas de 1000 pies de pagina.

En este momento tengo un nuevo problema, el Websecurify scanner, me dice que otro problema que tenfo es "Open Redirect", esta es la explicación que me da el programa
Cita:
An Open Redirect is a type of a vulnerability where a parameter taken from the user is used as the target of a HTTP redirect without any validation. This vulnerability is commonly used in phishing attacks. The purpose of the attack is to get the user to visit a malicious site without realizing it.

solution: Ensure that the application can only redirect to a whitelist of approved applications.
no tengo ni idea de como solucionarlo, les adjunto la direccion y el codigo para ver si me pueden dar una mano
Cita:
index3.php?articulo=http%3A%2F%2FXPLZ6 HTTP/1.1
Código PHP:
if ($_POST) {

    
$preguntante stripslashes(mysql_real_escape_string(htmlspecialchars($_SESSION['email'])));
    
$articulo stripslashes(mysql_real_escape_string(htmlspecialchars($_POST['articulo'])));
    
$valorar 0;
    
$eliminar 0;
    
$hora date('Y-m-d H:i:s'time() -10);
    
// conocer la IP
    
if(isset( $_SERVER ['HTTP_X_FORWARDED_FOR'] ) )
    {
        
$ip $_SERVER ['HTTP_X_FORWARDED_FOR'];
    }else{
        if( isset( 
$_SERVER ['HTTP_VIA'] ) ){
            
$ip $_SERVER ['HTTP_VIA'];
        }else{
            if( isset( 
$_SERVER ['REMOTE_ADDR'] ) ){
                
$ip $_SERVER ['REMOTE_ADDR'];
            }
        }
    }
    
    
$query=sprintf("SELECT (id2) FROM preguntas ORDER BY id2 DESC LIMIT 1");
    
$result mysql_query($query$con); 
    
$id2 0;
    while(
$row mysql_fetch_array($result))
    {
        
$id2 $row['id2'];
    }
    
$id md5(md5($id2 1));
    
    
$query sprintf("SELECT * FROM articulo WHERE id= '%s' AND vendido='0' AND suspender='0' ORDER BY fecha DESC LIMIT 0,1"mysql_real_escape_string($articulo));
    
$result mysql_query($query$con); 
    if(
mysql_num_rows($result) > 0){
        while(
$row=mysql_fetch_array($result))
        {
            
$usuario $row['1'];
        }    
    }
    
    
$query sprintf("SELECT * FROM articulo WHERE id= '%s' AND vendido='0' AND suspender='0' "mysql_real_escape_string($articulo));
    
$result mysql_query($query$con); 
    if(
mysql_num_rows($result) > 0){
        
$query sprintf("SELECT * FROM preguntas WHERE articulo= '%s' AND preguntante= '%s'  ORDER BY fecha DESC LIMIT 0,1 "mysql_real_escape_string($articulo), mysql_real_escape_string($preguntante));
        
$result mysql_query($query$con);
        if(
mysql_num_rows($result) > 0){
            while(
$row=mysql_fetch_array($result))
            {
                
$fecha $row['5'];
            }
            if(
$fecha $hora){    
                
//if(trim($_POST["pregunta"]) != "" && $usuario != "" && $articulo != "" )
                
if(trim($_POST["pregunta"]) != "" && $usuario != "" && $articulo != "" && $usuario != $preguntante )
                {
// aqui es donde se ingresan los datos