微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 绕过MySQL查询

In MySQL, comments can be inserted within keywords themselves,
which provides another means of bypassing some input validation
filters while preserving the Syntax of the actual query. For example:

SEL/*foo*/ECT username,password FR/*foo*/OM users

但是如何在保留的单词之间注释掉东西呢?有什么好处?
为什么它是一种绕过?

看起来有点儿!

解决方法:

That quote is from a book from 2007 …对于早期版本的MysqL可能是这样,但我找不到MysqL版本,其中该语法不会返回错误.

这种语法背后的原始想法是,如果应用程序试图将某些sql关键字列入黑名单,那么这种攻击会欺骗应用程序.

例如……如果应用程序试图阻止攻击者使用sql Injection从数据库删除记录,则禁止使用的黑名单列表将过滤掉DELETE …但无法过滤掉DEL / ** / ETE.

但是,尝试在动态查询中创建一个不允许的术语黑名单是防止sql注入的一种可怕的,无效的方法……并且有一些更简单有效的方法可以防止sql注入攻击,例如参数化查询嵌入式注释语法即使仍然有效也没用.

From OWASP

As is almost always the case, blacklisting is riddled with loopholes
that make it ineffective at preventing sql injection attacks. For
example, attackers can:

  • Target fields that are not quoted
  • Find ways to bypass the need for certain escaped Meta-characters
  • Use stored procedures to hide the injected Meta-characters

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐