哪些 SQL 注入方法不会被“破坏”?通过 mysql_real_escape_string();?
是否存在仅使用 utf8 编码的 mysql_real_escape_string();
无法保护的 SQL 注入方法列表?
对于整数,我使用 intval();
它足够安全吗?
对于那些认为我想获得“教程”来攻击任何人的人:不,我不会。我只是想知道如何让我的应用程序更加安全,并且我想知道它们是否能够 99% 地抵御黑客攻击
Is there a list of SQL injection methods which can't be protected with just using mysql_real_escape_string();
with utf8 encoding?
For integer, I'm using intval();
Is it secure enough?
For those who think I want to get "tutorial" to hack anyone: No, I won't. I just want to know how to make my applications more secure, and I want to know if they're secured 99% against hackers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果给定有效的数据库连接,
mysql_real_escape_string()
在所有情况下都应该是安全的字符串数据(除了 这个答案)。但是,字符串之外的任何内容,它都不会转义:
仍然容易受到攻击,因为您不必“突破”字符串来添加邪恶的附加命令。
If given a valid database connection,
mysql_real_escape_string()
is supposed to be safe for string data under all circumstances (with the rare exception described in this answer).However, anything outside a string, it won't escape:
is still vulnerable, because you don't have to "break out" of a string to add an evil additional command.
sql注入的方法并不多。它们总是由于输入没有被正确清理和转义造成的。因此,虽然 mysql_real_escape_string() 将使任何字符串安全地包含在数据库查询中,但您应该遵循以下避免技术来保护您的数据和用户免受 SQL 注入。
is_numeric()
验证数据,或使用settype()
默默地更改其类型另请参阅: 关于 SQL 注入的 PHP 页面
There are not many sql injection methods. They are always due to input not being sanitized and escaped properly. So, While
mysql_real_escape_string()
will make any string safe to be included in a database query, you should follow the following avoidance techniques to protect your data and users from sql injection.is_numeric()
, or silently change its type usingsettype()
mysql_real_escape_string()
will make all strings safe to be included in an SQL query to a mysql databaseSee also: PHP page on SQL injection
有很多东西可能无法受到标准方法的保护(例如字符串转义、整数转换),这也取决于您使用的软件版本。例如,utf-8 本身就是一个很大的问题,作为一个小例子(在许多例子中),您应该确保请求是有效的 utf-8(或将其转换为 utf-8)。请参阅示例。
作为网站的不死祸根,我认为 MySQL 注入保护不能被压缩到单个 SO 答案中,因此我将这些链接作为一般起点。
http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/< /a>
还有: 搜索mysql注入utf8
There are many things that may not get protected by standard methods (e.g. string escaping, int casting), also depending on the version of software you use. For example, utf-8 is quite an issue by itself, as a tiny example (among many) you should make sure the request is valid utf-8 (or convert it into utf-8). See an example.
As the undead bane of websites, I think that MySQL injection protection cannot be squeezed into a single SO answer, hence I'm including these links as general starting points.
http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/
And also : Search for mysql injection utf8