魔术引号容易受到 Sql 注入攻击吗?我应该使用 stripslashes 然后清理输入吗?

发布于 2024-12-13 09:36:27 字数 589 浏览 3 评论 0原文

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

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);
}

我在清理输入方面没有太多经验,所以请提供任何帮助:(

I'm confused about these magic quotes.
They are enabled on my server, and my question is should i disable them
by using functions like :

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

to sanitize my input or should i leave all the job to magic quotes.
I'm practicing some sql injection (for learning purposes) and when magic quotes are on
i cant do anything, but when i use the code above i can do sql injection.
So should i stick with magic quotes or use functions like this:

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

I dont have that much experience on sanitizing inputs so any help please :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑咖 2024-12-20 09:36:27

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

Magic quotes are deprecated and will be removed from the next version of PHP (PHP 5.4), so you shouldn't rely on them. (See http://www.php.net/manual/en/security.magicquotes.php) The best way to prevent SQL injection is to use PDO and prepared statements. See https://www.php.net/manual/en/pdo.prepared-statements.php for more and search for a tutorial on google if you need more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文