在练习DVWA中的sql注入时,在注入1’ union select table_name,table_schema from information_schema.tables where table_schema=‘dvwa’#时,遇到了 llegal mix of collations for operation 'UNION’报错的问题。
报错显示union的排序组合混乱,后来从https://blog.csdn.net/qq_43665434/article/details/114088565?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-114088565-blog-123549107.t5_eslanding_download_v1&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-114088565-blog-123549107.t5_eslanding_download_v1&utm_relevant_index=1查询到
发现是排序规则的问题。
首先通过cmd命令进入mysql,这里环境是phpstudy。
然后我们选择dvwa数据库。
查看下first_name和last_name的collate为utf8_unicode_ci
show create table users;
然后选择mysql数据库,查询collation。
可知发现union两端字段的collate不同。
最后选择dvwa数据库;修改排序。
alter table users modify first_name varchar(15) character set utf8 collate utf8_general_ci;
alter table users modify last_name varchar(15) character set utf8 collate utf8_general_ci;
最后进行slq注入发现没有报错。