从 hisiphp 中 getshell
项目简介
HisiPHP V2版 基于ThinkPHP5.1 + layui开发的一套开源PHP快速开发框架,默认集成了权限管理、模块管理、插件管理、钩子管理、数据库管理等常用功能,以方便开发者快速构建自己的应用,我们在发布第一个版本就为您集成了一键升级框架的功能,扩展的模块、插件、模板均可独立在线升级。为了让您开发的应用获得更多的使用者,HisiPHP在发布之初就上线了PHP应用市场(http://store.hisiphp.com)。
环境搭建
项目下载地址 https://gitee.com/hisi/hisiphp 下载最新版本的 hisiphp v2.0.12 从中寻找可能存在的漏洞
利用 phpstudy 来搭建环境,选择 Apache2.4.39 + MySQL5.7.26+ php5.6.9 ,同时利用 PhpStorm 来实现对项目的调试

漏洞复现与分析
插件导入_RCE
创建文件夹 shell 并创建文件 shell.php 写入恶意代码 打包为 shell.zip

登录后台地址,找到系统扩展 -> 本地插件 ->导入插件

将 shell.zip 上传

发现返回结果提示上传失败
scandir(./upload/temp/file/25\ecf62dab37c05b9f20dda43dbd5f38/upload/plugins/,./upload/temp/file/25\ecf62dab37c05b9f20dda43dbd5f38/upload/plugins/)

但是发现文件已经上传的临时目录中了,这是因为上传压缩包与原本设定的插件目录不同,所以抛出异常了
访问路径 /upload/temp/file/25/ecf62dab37c05b9f20dda43dbd5f38/shell/shell.php

\app\system\admin\Plugins::import


应该是再获取插件名是因为路径不对,函数传入参数不匹配导致异常抛出,绕过了之后的校验
