MySQL允许在SQL 代码中使用注释。这对于说明存放在文件中的查询很有用处。可用两个方式编写注释。以“ #”号开头直到行尾的所有内容都认为是注释。另一种为C 风格的注释。即,以“/ *”开始,以“* /”结束的所有内容都认为是注释。C 风格的注释可跨多行.
自MySQL3.23 版以来,可在C 风格的注释中“隐藏” MySQL特有的关键字,注释以“/ * !”而不是以“ / *”起头。MySQL可以查看这种特殊类型注释的内部并使用这些关键字,但其他数据库服务器将这些关键字作为注释的一部分忽略。这样有助于编写由MySQL执 行时利用MySQL特有功能的代码,而且该代码也可以不用修改就用于其他数据库服务器。
自MySQL3.23.3 以来,除了刚才介绍的注释风格外,还可以用两个短划线和一个空格(“– ”)来开始注释;从这两个短划线到行的结束的所有内容都作为注释处理。有的数据库以双短划线作为注释的起始。MySQL也允许这样,但需要加一个空格以免 产生混淆。例如,带有如像5–7 这样的表达式的语句有可能被认为包含一个注释,但不可能写5– 7这样的表达式,因此,这是一个很有用的探索。然而,这仅仅是一个探索,最好不用这种风格的注释。
——————————————————————————————————-
Mysql利用/*!select*/ 突破防注入
昨天在检测一个外国PHP网站时
在id=255后加’出现forbidden
于是我and 1=1正常 and 1=2出错
说明肯定有注入
接着我order by猜出字段
然后union select 1,2,3,4 //悲剧的又出现了forbidden
肯定是做了过滤了
后来构造了语句id=-255+union+/*!select*/+1,2,3,4
引用MySQL Server supports some variants of C-style comments. These enable you to write code that includes MySQL extensions, but is still portable, by using comments of the following form:
/*! MySQL-specific code */
In this case, MySQL Server parses and executes the code within the comment as it would any other SQL statement, but other SQL servers will ignore the extensions. For example, MySQL Server recognizes the STRAIGHT_JOIN keyword in the following statement, but other servers will not:
SELECT /*! STRAIGHT_JOIN */ col1 FROM table1,table2 WHERE …
If you add a version number after the “!” character, the syntax within the comment is executed only if the MySQL version is greater than or equal to the specified version number. The TEMPORARY keyword in the following comment is executed only by servers from MySQL 3.23.02 or higher:
CREATE /*!32302 TEMPORARY */ TABLE t (a INT);
The comment syntax just described applies to how the mysqld server parses SQL statements. The mysql client program also performs some parsing of statements before sending them to the server. (It does this to determine statement boundaries within a multiple-statement input line.)
+———–+
| 1 |
+———–+
| 1 |
| 5.0.82sp1 |
+———–+
2 rows in set (0.00 sec)
参考文章:
1、http://yangbinuestc.blog.163.com/blog/static/312199020071127111135745/ mysql注释(– 、/*!*/、#)
2、http://www.myhack58.com/Article/html/3/7/2011/28886.htm Mysql利用/*!select*/ 突破防注入
转载请注明:jinglingshu的博客 » mysql注释(# — /**/ /*! */)与利用/*! */突破防注入