【PHP代码审计】站帮主CMS漏洞挖掘——这种类型的cms直接到cnvd里去搜漏洞即可

直接到cnvd里去搜站帮主关键字,有啥漏洞都出来了。

https://www.cnvd.org.cn/flaw/list.htm?flag=true 可以看到很多:

漏洞标题危害级别点击数评论关注时间↓
 站帮主CMS存在文件上传漏洞(CNVD-2021-552... 60 0 0 2021-08-25
 站帮主CMS存在文件上传漏洞(CNVD-2021-552... 54 0 0 2021-08-25
 站帮主CMS存在文件上传漏洞(CNVD-2021-490... 57 0 0 2021-08-13
 站帮主CMS存在文件上传漏洞(CNVD-2021-490... 51 0 0 2021-08-13
 站帮主CMS存在SQL注入漏洞(CNVD-2021-3735... 46 0 0 2021-07-01
 站帮主CMS存在SQL注入漏洞(CNVD-2021-3735... 49 0 0 2021-07-01
 站帮主CMS存在XSS漏洞 44 0 0 2021-07-01
 站帮主CMS存在SQL注入漏洞 45 0 0 2021-07-01
 站帮主CMS存在任意文件删除漏洞 45 0 0 2021-07-01
 站帮主CMS存在文件上传漏洞 48 0 0 2021-07-01

 

【PHP代码审计】站帮主CMS漏洞挖掘

PHP代码审计
专栏收录该内容
9 篇文章2 订阅
订阅专栏
文章目录
任意文件删除
SQL注入漏洞
任意文件删除
这里随便挑了一个cnvd上最新发布的cms漏洞

查找unlink函数,任意文件删除常见函数

看到一个return unlink($path);感觉自己看到了结局

双击发现是delDirAndFile函数的功能

function delDirAndFile($path, $delDir = FALSE) {
if($path=='' || $path=='/' || $path=='./' || $path=='../' || $path=='../../' || $path=='../../../'){
exit('严禁该操作');
}
$handle = opendir($path);
if ($handle) {
while (false !== ( $item = readdir($handle) )){
if ($item != "." && $item != "..")
is_dir("$path/$item") ? delDirAndFile("$path/$item", $delDir) : unlink("$path/$item");
}
closedir($handle);
if ($delDir)
return rmdir($path);
}else {
if (file_exists($path)) {
return unlink($path);
} else {
return false;
}
}
}
发现此函数可以对传入的$path进行删除操作

跟进函数使用位置

if($run=='delpath'){
$path=$_POST['path'];
delDirAndFile($path, $delDir = true);
}

发现如果变量run等于delpath,就可以通过post传递的参数path来删除文件

看怎么给变量run赋值

if(!isset($_GET['run'])){
exit("参数有误");
}

发现是get请求传递的run参数

这个时候我们可以看一下首页文件

<?php
error_reporting(0);
header("Content-type: text/html; charset=utf-8");
if(count($_GET)<=0 and file_exists('index.html')){
echo "<script>window.location='index.html';</script>";
exit;
}
else if(!file_exists('cms/cms/install/install.txt')){
echo "<script>window.location='cms/cms/install/index.php';</script>";
exit;
}
else{
echo "<script>window.location='search.php?index';</script>";
}
?>

是通过cms/cms/install/install.txt是否存在,来判断是否跳转到安装界面的

我们安装网站后尝试直接访问安装界面

可以看到,如果需要重新安装,请把install.txt文件删除
通过上面的存在任意文件删除漏洞处构造payload

发现文件被删除系统需要重装


SQL注入漏洞
通过查找select字段发现如下字段

可以看到未经过任何安全函数之类的进行过滤

<?php
include('c_top.php');
if(isset($_GET['aid'])){
$aid=$_GET['aid'];
$arts=$c_sql->select("select * from art where id={$aid}");
$arts=$arts[0];
$tid=$arts['tid'];
}

直接http://192.168.80.158/zbzcms/cms/cms/admin/art.php?aid=1放到sqlmap跑

得到账号密码
这里其他的漏洞基本上都差不多,还是比较简单的,适合我这样的新手学习,这里就不写了,基本就是查一下危险函数,黑白盒一起很容易发现的
————————————————
版权声明:本文为CSDN博主「SanSs敲利码」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_44978149/article/details/118403113

posted @ 2022-02-04 12:04  bonelee  阅读(471)  评论(0编辑  收藏  举报