我正在遵循一个教程,其中一个用PHP编写的web应用程序将输入( 'id‘参数)中的空格列入黑名单。任务是添加其他字符,这基本上绕过了这个黑名单,但仍然由后端的MySQL数据库解释。考虑到nbsp字符没有被列入黑名单,我构造了一个类似so - http://192.168.2.15/sqli-labs/Less-26/?id=1'%C2%A0||%C2A0'1的URL,其中C2A0是nbsp字符的UTF8表示。但是,这会抛出一个MySQL错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' || '1' LIMIT 0,1' at line 1
我将在数据库上运行的SQL查询字符串反射回页面
SELECT * FROM users WHERE id='1' || '1' LIMIT 0,1
这个查询对我来说似乎没问题,它不应该抛出错误。我怀疑这可能与字符集有关。但我对MySQL中的字符集以及字符集在什么情况下适用的了解非常有限。
运行show variables like 'char%';时看到的内容
+--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | gbk | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
发布于 2015-07-04 08:47:12
MySQL语法无法识别utf8 C2A0。
在此测试中,请注意规则空格(20)和NO-BREAK SPACE (C2A0):
mysql> select UNHEX('53454C45435420313B'), UNHEX('53454C454354C2A0323B');
+-----------------------------+-------------------------------+
| UNHEX('53454C45435420313B') | UNHEX('53454C454354C2A0323B') |
+-----------------------------+-------------------------------+
| SELECT 1; | SELECT 2; |
+-----------------------------+-------------------------------+
1 row in set (0.00 sec)然后我复制了这两条语句:
mysql> SELECT 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
mysql> SELECT 2;
ERROR 1064 (42000): You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version
for the right syntax to use near 'SELECT 2' at line 1https://stackoverflow.com/questions/31199679
复制相似问题