2020蓝帽杯CTF Web 题

2020蓝帽杯CTF Web 题

这是一个空白页面 别找了小hacker, 这里什么都没有

http://127.0.0.1/blueCTF/?file=php://filter/read=convert.base64-encode/resource=./try.php


<?php
class Seri{
    public $alize;
    public function __construct($alize) {
        $this->alize = $alize;
    }
    public function __destruct(){
        $this->alize->getFlag();
    }
}

class Flag{
    public $f;
    public $t1;
    public $t2;

    function __construct($file){
        echo "Another construction!!";
        $this->f = $file;
        $this->t1 = $this->t2 = md5(rand(1,10000));
    }

    public function getFlag(){
        $this->t2 = md5(rand(1,10000));
        echo $this->t1;
        echo $this->t2;
        if($this->t1 === $this->t2)
        {
            if(isset($this->f)){
                echo @highlight_file($this->f,true);
            }
        }
    }
}

?>

看到序列化,寻找序列化触发点,先去读index查看

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css.css">
<title>空白页面</title>
</head>
<div class="overlay">
    <div class="hero">
        <h1>这是一个<span>空白页面</span></h1>
        <h3>别找了小hacker, 这里什么都没有</h3>
    </div>
</div>
</html>
<?php
error_reporting(0);
$file = $_GET["file"];
$p = $_GET["p"];
if (isset($file)) {
    echo 'NONONO' . '<br>';

    if (preg_match("/flag/", $file)) {
        die('HACKER GOGOGO!!!');
    }
    @include($file);

    if (isset($p)) {
        $p = unserialize($p);
    } else {
        echo "NONONO";
    }
}
?>

通过参数file进行文件包含,包含try.php文件,然后通过参数p进行反序列化

我们需要用Seri 调用 Flag类中的getFlag方法,构造序列化

  • 生成序列化 Payload

  • 我们可以通过序列化覆盖t1的值

t1,t2 最后需要相等, rand范围较小,所以我们可以爆破一下

更多的详情,和渗透实战技巧,SRC挖洞经验,安全武器库 可以关注公众号

原文地址:https://www.cnblogs.com/0xdd/p/13452766.html