class Tom{ public $stolenCheese; public $trap; public function __construct($file='cheesemap.php'){ $this->stolenCheese = $file; echo "Tom盯着你,想要守住他抢走的奶酪!"."<br>"; } public function revealCheeseLocation(){ if($this->stolenCheese){ $cheeseGuardKey = "cheesemap.php"; echo nl2br(htmlspecialchars(file_get_contents($this->stolenCheese))); $this->stolenCheese = str_rot3($cheeseGuardKey); } } public function __toString(){ if (!isset($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] !== "JerryBrowser") { echo "<h3>Tom 盯着你的浏览器,觉得它不太对劲……</h3>"; }else{ $this->trap['trap']->stolenCheese; return "Tom"; } } public function stoleCheese(){ $Messages = [ "<h3>Tom偷偷看了你一眼,然后继续啃奶酪...</h3>", "<h3>墙角的奶酪碎屑消失了,它们去了哪里?</h3>", "<h3>Cheese的香味越来越浓,谁在偷吃?</h3>", "<h3>Jerry皱了皱眉,似乎察觉到了什么异常……</h3>", ]; echo $Messages[array_rand($Messages)]; $this->revealCheeseLocation(); } }
class Jerry{ protected $secretHidingSpot; public $squeak; public $shout; public function searchForCheese($mouseHole){ include($mouseHole); } public function __invoke(){ $this->searchForCheese($this->secretHidingSpot); } }
class Cheese{ public $flavors; public $color; public function __construct(){ $this->flavors = array(); } public function __get($slice){ $melt = $this->flavors; return $melt(); } public function __destruct(){ unserialize($this->color)(); echo "Where is my cheese?"; } }
if (isset($_GET['cheese_tracker'])) { unserialize($_GET['cheese_tracker']); }elseif(isset($_GET["clue"])){ $clue = $_GET["clue"]; $clue = str_replace(["T", "h", "i", "f", "!"], "*", $clue); if (unserialize($clue)){ unserialize($clue)->squeak = "Thief!"; if(unserialize($clue)->shout === unserialize($clue)->squeak) echo "cheese is hidden in ".$where; else echo "OHhhh no!find it yourself!"; } }
?>
我们先认真观察这一段:
1 2 3 4 5 6 7 8 9 10
elseif(isset($_GET["clue"])){ $clue = $_GET["clue"]; $clue = str_replace(["T", "h", "i", "f", "!"], "*", $clue); if (unserialize($clue)){ unserialize($clue)->squeak = "Thief!"; if(unserialize($clue)->shout === unserialize($clue)->squeak) echo "cheese is hidden in ".$where; else echo "OHhhh no!find it yourself!"; }
目标是显示$where变量的值,用如下脚本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php class Jerry{ protected $secretHidingSpot; public $squeak; public $shout; }