<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comentarios en: Filtros genéricos y la seguridad</title>
	<atom:link href="http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/</link>
	<description>Diseño y Programación</description>
	<lastBuildDate>Wed, 08 Feb 2012 16:34:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>Por: 15 herramientas gratuitas para detectar vulnerabilidades de Inyección de SQL</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-11137</link>
		<dc:creator>15 herramientas gratuitas para detectar vulnerabilidades de Inyección de SQL</dc:creator>
		<pubDate>Wed, 30 May 2007 16:37:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-11137</guid>
		<description>[...] el lenguaje de programación provea para este fin, en lo posible no debemos reinventar la rueda y hacer funciones que algunas veces no sirven de [...]</description>
		<content:encoded><![CDATA[<p>[...] el lenguaje de programación provea para este fin, en lo posible no debemos reinventar la rueda y hacer funciones que algunas veces no sirven de [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: alex</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10401</link>
		<dc:creator>alex</dc:creator>
		<pubDate>Thu, 29 Mar 2007 14:45:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10401</guid>
		<description>Hmm, no soy experto ni desarrollo en PHP :) pero escuché buenos comentarios de &lt;a href=&quot;http://www.php.net/pdo&quot; rel=&quot;nofollow&quot;&gt;PDO&lt;/a&gt;, aunque no sé si a eso te referías.

Saludos</description>
		<content:encoded><![CDATA[<p>Hmm, no soy experto ni desarrollo en PHP <img src='http://www.buayacorp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  pero escuché buenos comentarios de <a href="http://www.php.net/pdo" rel="nofollow">PDO</a>, aunque no sé si a eso te referías.</p>
<p>Saludos</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: DN</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10399</link>
		<dc:creator>DN</dc:creator>
		<pubDate>Thu, 29 Mar 2007 09:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10399</guid>
		<description>Por cierto... ¿existe alguna librería o clase que unifique todas las funciones de acceso a datos? De una forma un poco más sencilla (Si es posible) que las del propio PHP.

Es que llamar así a pelo a las funciones de mysqli me da un noseque, y todas las que vi usan las funciones &quot;clásicas&quot; de acceso a mySQL de PHP</description>
		<content:encoded><![CDATA[<p>Por cierto... ¿existe alguna librería o clase que unifique todas las funciones de acceso a datos? De una forma un poco más sencilla (Si es posible) que las del propio PHP.</p>
<p>Es que llamar así a pelo a las funciones de mysqli me da un noseque, y todas las que vi usan las funciones "clásicas" de acceso a mySQL de PHP</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: jdeveloper</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10173</link>
		<dc:creator>jdeveloper</dc:creator>
		<pubDate>Fri, 09 Mar 2007 23:39:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10173</guid>
		<description>je, tienes razon, se me habia escapado lo de htmlchars, de todas formas, si es un texto se supone que va entre comillas no? ¿No seria mas sensto usar tambien mysql_real_escapte o algo asi se llama la funcion? A mi me queda claro que tiene muchos contras.</description>
		<content:encoded><![CDATA[<p>je, tienes razon, se me habia escapado lo de htmlchars, de todas formas, si es un texto se supone que va entre comillas no? ¿No seria mas sensto usar tambien mysql_real_escapte o algo asi se llama la funcion? A mi me queda claro que tiene muchos contras.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: DN</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10161</link>
		<dc:creator>DN</dc:creator>
		<pubDate>Thu, 08 Mar 2007 16:02:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10161</guid>
		<description>Jejeje ya se que no es tuya ;)

Pero estas funciones en general valen para lo mismo que las magic quotes: Dar falsas esperanzas con la seguridad.</description>
		<content:encoded><![CDATA[<p>Jejeje ya se que no es tuya <img src='http://www.buayacorp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Pero estas funciones en general valen para lo mismo que las magic quotes: Dar falsas esperanzas con la seguridad.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: alex</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10160</link>
		<dc:creator>alex</dc:creator>
		<pubDate>Thu, 08 Mar 2007 15:11:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10160</guid>
		<description>Completamente de acuerdo DN, pero el motivo por el que existen este tipo de funciones, es consecuencia del craso error que cometieron los desarrolladores de PHP al no incluir el soporte para consultas parametrizadas desde las primeras versiones de este lenguaje.

Saludos
PS. Yo &lt;a href=&quot;http://www.forosdelweb.com/showthread.php?t=470146&quot; rel=&quot;nofollow&quot;&gt;no inventé&lt;/a&gt; esa función :)</description>
		<content:encoded><![CDATA[<p>Completamente de acuerdo DN, pero el motivo por el que existen este tipo de funciones, es consecuencia del craso error que cometieron los desarrolladores de PHP al no incluir el soporte para consultas parametrizadas desde las primeras versiones de este lenguaje.</p>
<p>Saludos<br />
PS. Yo <a href="http://www.forosdelweb.com/showthread.php?t=470146" rel="nofollow">no inventé</a> esa función <img src='http://www.buayacorp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: DN</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10159</link>
		<dc:creator>DN</dc:creator>
		<pubDate>Thu, 08 Mar 2007 14:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10159</guid>
		<description>Perdonad... pero... ¿nadie ve que es una imprudencia jugar con las consultas de SQL? Yo lo tengo claro... a mi que se me dejen de inventos raros con funciones chungas y que se pongan todos a usar mysqli y consultas parametrizadas.

Todavía no tengo ni una sola razón por lo que no sea recomendable usarlo.</description>
		<content:encoded><![CDATA[<p>Perdonad... pero... ¿nadie ve que es una imprudencia jugar con las consultas de SQL? Yo lo tengo claro... a mi que se me dejen de inventos raros con funciones chungas y que se pongan todos a usar mysqli y consultas parametrizadas.</p>
<p>Todavía no tengo ni una sola razón por lo que no sea recomendable usarlo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: alex</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10157</link>
		<dc:creator>alex</dc:creator>
		<pubDate>Thu, 08 Mar 2007 12:03:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10157</guid>
		<description>Tal como mencionas, tanto en el código original como en el que modificaste, todavía quedan varios problemas, por ejemplo falla para el siguiente valor: &lt;code&gt;1 &lt;&gt;OR&lt;&gt; 1=1&lt;/code&gt;.

En fin, me parece que el que escribió esa función no se dió cuenta de lo que estaba haciendo.</description>
		<content:encoded><![CDATA[<p>Tal como mencionas, tanto en el código original como en el que modificaste, todavía quedan varios problemas, por ejemplo falla para el siguiente valor: <code>1 &lt;&gt;OR&lt;&gt; 1=1</code>.</p>
<p>En fin, me parece que el que escribió esa función no se dió cuenta de lo que estaba haciendo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: jdeveloper</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10156</link>
		<dc:creator>jdeveloper</dc:creator>
		<pubDate>Thu, 08 Mar 2007 09:56:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10156</guid>
		<description>yo haria

[code]
function antiinjection($str) {
	$banchars = array (&quot;&#039;&quot;, &quot;,&quot;, &quot;;&quot;, &quot;--&quot;, &quot;)&quot;, &quot;(&quot;,&quot;\n&quot;,&quot;\r&quot;);
        $banwords = array (&quot; or &quot;,&quot; OR &quot;,&quot; Or &quot;,&quot; oR &quot;,&quot; and &quot;, &quot; AND &quot;,&quot; aNd &quot;,&quot; aND &quot;,&quot; AnD &quot;); //faltan algunas permutaciones del and,se sobreentiende espero gracias a la observacion del primero comentario
	if ( eregi ( &quot;[a-zA-Z0-9]+&quot;, $str ) ) {
                $str = str_replace ( $banchars, &#039;&#039;, ( $str ) );
		$str = str_replace ( $banwords, &#039;&#039;, ( $str ) );
	} else {
		$str = NULL;
	}
	$str = trim($str);
	$str = strip_tags($str);
	$str = stripslashes($str);
	$str = addslashes($str);
	$str = htmlspecialchars($str);
	return $str;
}
[/code]

El orden de aplicar str_replace es estrictamente ese, primero escapo los caracteres peligrosos y despues quito los and y or. Y aun asi seguro que queda algun bug por ahi.

El orden estricto en que aplico los replaces es para evitar por ejemplo ;OR; que en el ejemplo, solo quitaria los ;

De esta forma por ejemplo Select user from users where id=2 ;OR; 1=1 quedaria:

Despues del primer replace: Select user from users where id=2 OR 1=1
Y en el segundo replace, pues ya se quitaria el or, teniendo un sql mal formado pero polo menos no devuelve algo indeseado: Select user from users where id=2  1=1

Presupongo que se va a hacer un select, porque si vas a hacer un insert o un update, claro, no te vas a cargar lo que escribe alguien. Si lo que insertas o modificas no va a meterse como enlace en href, en principio con hacer lo de stripslashes y eso llegaria pienso yo.</description>
		<content:encoded><![CDATA[<p>yo haria</p>
<div class="hiliter"><strong>code:</strong>
<pre class="code">&nbsp;
function antiinjection<span style="color:#008800; font-weight:bold;">&#40;</span>$str<span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span>
	$banchars = array <span style="color:#008800; font-weight:bold;">&#40;</span>&quot;<span style="color: #808080; font-style: italic;">'&quot;, &quot;,&quot;, &quot;;&quot;, &quot;--&quot;, &quot;)&quot;, &quot;(&quot;,&quot;\n&quot;,&quot;\r&quot;);</span>
        $banwords = array <span style="color:#008800; font-weight:bold;">&#40;</span>&quot; or &quot;,&quot; OR &quot;,&quot; Or &quot;,&quot; oR &quot;,&quot; and &quot;, &quot; AND &quot;,&quot; aNd &quot;,&quot; aND &quot;,&quot; AnD &quot;<span style="color:#008800; font-weight:bold;">&#41;</span>; <span style="color: #808080; font-style: italic;">//faltan algunas permutaciones del and,se sobreentiende espero gracias a la observacion del primero comentario</span>
	if <span style="color:#008800; font-weight:bold;">&#40;</span> eregi <span style="color:#008800; font-weight:bold;">&#40;</span> &quot;<span style="color:#008800; font-weight:bold;">&#91;</span>a-zA-Z0<span style="">-9</span><span style="color:#008800; font-weight:bold;">&#93;</span>+&quot;, $str <span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span>
                $str = str_replace <span style="color:#008800; font-weight:bold;">&#40;</span> $banchars, <span style="color: #808080; font-style: italic;">'', ( $str ) );</span>
		$str = str_replace <span style="color:#008800; font-weight:bold;">&#40;</span> $banwords, <span style="color: #808080; font-style: italic;">'', ( $str ) );</span>
	<span style="color:#008800; font-weight:bold;">&#125;</span> else <span style="color:#008800; font-weight:bold;">&#123;</span>
		$str = NULL;
	<span style="color:#008800; font-weight:bold;">&#125;</span>
	$str = trim<span style="color:#008800; font-weight:bold;">&#40;</span>$str<span style="color:#008800; font-weight:bold;">&#41;</span>;
	$str = strip_tags<span style="color:#008800; font-weight:bold;">&#40;</span>$str<span style="color:#008800; font-weight:bold;">&#41;</span>;
	$str = stripslashes<span style="color:#008800; font-weight:bold;">&#40;</span>$str<span style="color:#008800; font-weight:bold;">&#41;</span>;
	$str = addslashes<span style="color:#008800; font-weight:bold;">&#40;</span>$str<span style="color:#008800; font-weight:bold;">&#41;</span>;
	$str = htmlspecialchars<span style="color:#008800; font-weight:bold;">&#40;</span>$str<span style="color:#008800; font-weight:bold;">&#41;</span>;
	return $str;
<span style="color:#008800; font-weight:bold;">&#125;</span>
&nbsp;</pre>
</div>
<p>El orden de aplicar str_replace es estrictamente ese, primero escapo los caracteres peligrosos y despues quito los and y or. Y aun asi seguro que queda algun bug por ahi.</p>
<p>El orden estricto en que aplico los replaces es para evitar por ejemplo ;OR; que en el ejemplo, solo quitaria los ;</p>
<p>De esta forma por ejemplo Select user from users where id=2 ;OR; 1=1 quedaria:</p>
<p>Despues del primer replace: Select user from users where id=2 OR 1=1<br />
Y en el segundo replace, pues ya se quitaria el or, teniendo un sql mal formado pero polo menos no devuelve algo indeseado: Select user from users where id=2  1=1</p>
<p>Presupongo que se va a hacer un select, porque si vas a hacer un insert o un update, claro, no te vas a cargar lo que escribe alguien. Si lo que insertas o modificas no va a meterse como enlace en href, en principio con hacer lo de stripslashes y eso llegaria pienso yo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Eber Irigoyen</title>
		<link>http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10139</link>
		<dc:creator>Eber Irigoyen</dc:creator>
		<pubDate>Wed, 07 Mar 2007 18:42:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.buayacorp.com/archivos/filtros-genericos-y-la-seguridad/#comment-10139</guid>
		<description>escaped characters... And... Or...</description>
		<content:encoded><![CDATA[<p>escaped characters... And... Or...</p>
]]></content:encoded>
	</item>
</channel>
</rss>

