[Ajuda] SQL injection - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] SQL injection (
/showthread.php?tid=487560)
SQL injection -
Mr.Hardy - 14.01.2014
Tem haver com SA:MP kkkkk
Posso sofrer SQL injection nesse cуdigo PHP?
PHP код:
$result = mysql_query("SELECT `usuario` FROM `usuarios` WHERE usuario='".$_POST['usuario']."'");
if(!mysql_fetch_row($result))
{
$problema = true;
}
$result = mysql_query("SELECT `usuario`,`senha`,`ultimaskin` FROM `usuarios` WHERE usuario='".$_POST['usuario']."'");
while($data = mysql_fetch_array($result)) // Make $data an array of the query you just executed.
{
$senha = $data['senha'];
$usuario = $data['usuario'];
$ultimaskin = $data['ultimaskin'];
}
Estou mostrando somente a parte que tenho б duvida. E se posso ser atacado como evitar?
Re: SQL injection -
Kmatsu - 14.01.2014
Sim, vocк pode .-.
use:
mysql_real_escape_string
Re: SQL injection -
Mr.Hardy - 14.01.2014
Implementa nesse cуdigo pra min? Huheuehue
PHP код:
$result = mysql_query("SELECT `usuario`,`senha`,`ultimaskin` FROM `usuarios` WHERE usuario='".$_POST['usuario']."'");
while($data = mysql_fetch_array($result)) // Make $data an array of the query you just executed.
{
$senha = $data['senha'];
$usuario = $data['usuario'];
$ultimaskin = $data['ultimaskin'];
}
function udb_hash($pass)
{
$length = strlen($pass);
$s1 = 1;
$s2 = 0;
for($i=0; $i<$length; $i++)
{
$s1 = ($s1 + ord($pass[$i])) % 65521;
$s2 = ($s2 + $s1) % 65521;
}
$wy= ($s2 << 16) + $s1;
return $wy;
}
if($senha == $_POST['senha'])
{
$problema = false;
$_SESSION['logado'] = 1;
$_SESSION['usuario'] = $usuario;
$_SESSION['skin'] = $ultimaskin;
echo "<meta http-equiv='refresh' content='0; url=naoachou.php'>";
}
Re: SQL injection -
Falcon. - 14.01.2014
Prepared Statements
Re: SQL injection -
GWMPT - 14.01.2014
....
NГO USE MYSQL_*
Estas funзхes jб estгo desactualizadas.
Use MySQLi_*
E use mysqli_escape_string para "limpar" o "input"