我可以被这个代码破解吗? [英] can I be hacked with this code?

查看:167
本文介绍了我可以被这个代码破解吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我购买了一个脚本,其中包含一些奇怪的代码. 我是PHP的初学者,但是对诸如清理输入数据之类的知识有点了解.

I purchased a script that has some weird code in it. I'm a PHP beginner but know a little about things like sanitizing input data.

这是代码:

<form action="sendpass.php" method="post" id="sendpassform">
<input type="text" name="email" />
<input type="submit" name="sendpass" value="Send" />
</form>
?>

...
if($_REQUEST['email'] != ''){
  $email = $_REQUEST['email'];
  $k = mysql_query("SELECT * FROM users WHERE email='".$email."'") or die(mysql_error());
  $result= mysql_fetch_array($k);
  ....
}

我很好奇的是,是否有人可以使用此表单来入侵网站,因为电子邮件字段只是以任何转义的形式直接传递给了SQL ...

What I'm curious of, is if someone can hack the site using this form, because the email field is just passed directly to SQL with any escaping...

推荐答案

您应该使用$email = mysql_real_escape_string($_REQUEST['email']);

这应该可以防止任何SQL注入攻击.

That should prevent any SQL injection attacks.

有可能回答您的问题,但是是否有损坏取决于您对从MySQL检索到的数据(未显示)的处理方式

To answer your question, it's possible but whether there is any damage or not depends on what you do with the data retrieved from MySQL (not shown)

这篇关于我可以被这个代码破解吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆