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

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...