我能举个例子来说明sql注入是如何发生的吗?
我是 PHP 新手,即将发布。我正在使用 mysql_real_escape_string();对于所有用户输入以及所有 $_GET 和 $_REQUEST 变量。我想测试一下,但不确定它是如何完成的,以便我可以防止它并采取适当的措施。
I am new to PHP and coming close to launching. I am using mysql_real_escape_string(); for all user input and all $_GET and $_REQUEST variables. I wanted to test it out but not sure how it's done so i can prevent it and put in proper measures.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在所有表单字段(包括隐藏字段)中输入类似于以下字符串的字符串:
如果没有正确转义它,您将收到 sql 错误。如果您收到该 sql 错误,那么您应该能够弄清楚如何编写一个查询来执行与原始查询不同的操作。
Try inputting a string similar to the one below in all your form fields (including the hidden ones):
If you're not escaping it properly, you'll get a sql error. If you get that sql error, you should then be able to figure out how to write a query that does something different than what the original one intended.
,您完全错了。
首先,mysql_real_escape_string()与“用户输入”无关。这是与数据库相关的功能,与用户无关。
接下来,它与“所有输入”无关,因为它的使用仅限于字符串。因此,如果您有这样的代码,那么
您在这里进行的转义绝对没有用处并且无法保护任何内容。
至于测试——有点棘手。不过,互联网上有一些工具,我相信你可以谷歌一些。
well, you are entirely wrong.
First, mysql_real_escape_string() has nothing to do with "user input". This is database-related function, not user-related.
Next, it has nothing to do with "all input" as it's usage limited to strings only. So, if you have a code like this
you have here escaping absolutely useless and protects nothing.
as for the test - it's kinda tricky. however, there are tools in the internet, I am sure you can google some.