ctfshow入门框架复现
web466 #Laravel5.4反序列化 Laravel5.4版本 ,提交数据需要base64编码 这种多半都是框架反序列化的漏洞,本地搭一个Laravel5.4来分析一下 部署环境 composer create-project laravel/laravel=5.4 Laravel5.4 --prefer-dist --ignore-platform-reqs --no-security-blocking cd Laravel5.4 php artisan key:generate php artisan serve 由于laravel5.4是比较老的版本且存在安全漏洞,所以composer会默认阻止安装,需要带上--ignore-platform-reqs --no-security-blocking 前面会有一个报错导致无法正常运行,这是因为加入上面两个参数后会导致composer自己下一些php8.x新版本的依赖包,需要修改 platform_check.php 文件 后面访问8000端口就可以了 在项目中添加一个反序列化路由和控制器 在routes/web.php中添加 Route::get('/seri',"SeriController@index"); 新建app/Http/Controllers/SeriController.php <?php namespace App\Http\Controllers; class SeriController extends Controller{ public function index(){ if(isset($_GET['ser'])){ $ser = $_GET['ser']; unserialize($ser); } else{ highlight_file(__FILE__); } return "Debug Laravel5.4 by yourself!"; } } ?> 配置一下xdebug,方便后面调试链子 漏洞分析 __destruct()方法寻找 先找找可用的__destruct()方法 看到\Illuminate\Broadcasting\PendingBroadcast::__destruct() public function __destruct() { $this->events->dispatch($this->event); } $this->events和$this->event两个参数都是可控的,找一个不存在dispatch方法的类可以触发__call() 链1 Generator::__call方法 全局搜索一下__call()方法,找到一个之前yii框架类似的\Faker\Generator::__call public function __call($method, $attributes) { return $this->format($method, $attributes); } 跟进format public function format($formatter, $arguments = array()) { return call_user_func_array($this->getFormatter($formatter), $arguments); } 看看getFormatter函数是干啥的 ...