知識點
php強型別比較,可以通過 不同型別 達到繞過目的
php7.1以上版本 對類的型別定義不敏感
file_get_contents 偽協議檔案讀取
<?php
include
("flag.php");
highlight_file
(__file__);
class
filehandler
public
function
process()
elseif(
$this
->
op==
"2")
else
}private
function
write()
$res
=file_put_contents
($this
->
filename
,$this
->
content);
if($res
)$this
->
output
("successful!");
else
$this
->
output
("failed!");
}else
}private
function
read()
return
$res;}
private
function
output($s
)function
__destruct()
}function
is_valid($s
)if(isset
($_get))
}
將** 分段 分析。
function
is_valid($s
)if(isset
($_get))
}
get傳參,is_valid() 判斷字串的ascii值是否在32~~125之間。存在反序列化函式,呼叫析構函式。下一步檢視析構函式。
function
__destruct()
析構函式 判斷 op 強比較 是都 等於 字元型 2 如果等於 替換為 字元型 1.,將content替換為空。 呼叫process函式。
public
function
process()
elseif(
$this
->
op==
"2")
else
}private
function
output($s
)
process() 完成讀寫功能。 我們 應該要使用讀取操作 得到flag output() 是輸出字串
private
function
read()
return
$res
;}
利用 file_get_contents 來讀取 檔案 想到 偽協議。
構造序列化字串,讓op=2 並且 利用php偽協議 讀取 flag。
op=2 可以利用 強型別 比較 要比較 型別 2是int型 「2」是string型 可以繞過。
php偽協議:filename=php://filter/read=convert.base64-encode/resource=flag.php
最後 繞過 那個 ascii碼比較函式,因為protected私有化的時候會出現%00 他的ascii的值 是 0 不符合 可以使用php7.1以上版本 對類的型別定義不敏感 改為public繞過。
構造payload
網鼎盃 2020 青龍組 AreUSerialz
考點 php反序列化 原始碼 include flag.php highlight file file class filehandler public function process elseif this op 2 else private function write res file pu...
網鼎盃 2020 青龍組 notes wp
人生艱難,做了兩天。學到不少。給了js 第一次做js題,賊難受。var express require express var path require path const undefsafe require undefsafe const require child process expres...
網鼎盃 2020 青龍組 AreUSerialz
include flag.php highlight file file class filehandler public function process else if this op 2 else private function write res file put contents thi...