魔术报价容易受到Sql注入吗?我应该使用斜杠然后对输入进行消毒吗?


Are magic quotes vulnerable to Sql Injection ? Should i use stripslashes and then sanitize the input?

我对这些神奇的引号感到困惑。
它们在我的服务器上启用,我的问题是我应该禁用它们通过使用如下函数:

if(get_magic_quotes_gpc()){
 $username=stripslashes($username);
 $password=stripslashes($password);
}

来净化我的输入,或者我应该把所有的工作都留给魔术引号。
我正在练习一些sql注入(用于学习目的),当魔术引号是我不能做任何事情,但当我使用上面的代码,我可以做SQL注入。那么我应该坚持使用魔术引号还是使用像这样的函数:

if(get_magic_quotes_gpc()){
 $username=stripslashes($username);
 $password=stripslashes($password);
 $cleanUsername=mysql_real_escape_string($username);
 $cleanPassword=mysql_real_escape_string($password);
}

我没有那么多消毒输入的经验,所以请帮助:(

魔术引号已被弃用,并将从下一个PHP版本(PHP 5.4)中删除,因此您不应该依赖它们。(参见http://www.php.net/manual/en/security.magicquotes.php)防止SQL注入的最好方法是使用PDO和prepared语句。更多信息请访问http://fr2.php.net/manual/en/pdo.prepared-statements.php,如果您需要更多信息,请在google上搜索教程。

相关文章: