CISCN 2019华北Day1 web1
一道很适合新手入门完整网站项目漏洞挖掘的题目,网上wp多半只讲了利用链和exp,我会从网站逻辑开始分析并写得尽量详细易懂,同样适合新手入门 复现靶场为nssctf,https://www.nssctf.cn/problem/2 搜题号应该也能搜到 文件获取 拿到页面后是个登录框,先注册一个账号登进去看看 进来后是个文件管理的界面 随便传个文件 这里就会涉及到一个任意文件读取的思路。一般一些制作并不是那么精良的网站都会直接使用文件名匹配的方式去读取文件内容从而达到下载的效果,所以我们点击下载的时候抓个包试一下看能不能通过修改文件名从而把原代码下载下来 成功读取。照着这个方法把几个已知页面的代码都读一遍 网站代码逻辑 因为代码比较多,所以这里我这里先介绍一下网站的主要实现逻辑 我的习惯是从主界面也就是index.php开始看调用,在index.php中可以发现下面这段 进入到class.php,查看一下Filelist类 class FileList { private $files; private $results; private $funcs; public function __construct($path) { $this->files = array(); $this->results = array(); $this->funcs = array(); $filenames = scandir($path); $key = array_search(".", $filenames); unset($filenames[$key]); $key = array_search("..", $filenames); unset($filenames[$key]); foreach ($filenames as $filename) { $file = new File(); $file->open($path . $filename); array_push($this->files, $file); $this->results[$file->name()] = array(); } } public function __call($func, $args) { array_push($this->funcs, $func); foreach ($this->files as $file) { $this->results[$file->name()][$func] = $file->$func(); } } public function __destruct() { $table = '<div id="container" class="container"><div class="table-responsive"><table id="table" class="table table-bordered table-hover sm-font">'; $table .= '<thead><tr>'; foreach ($this->funcs as $func) { $table .= '<th scope="col" class="text-center">' . htmlentities($func) . '</th>'; } $table .= '<th scope="col" class="text-center">Opt</th>'; $table .= '</thead><tbody>'; foreach ($this->results as $filename => $result) { $table .= '<tr>'; foreach ($result as $func => $value) { $table .= '<td class="text-center">' . htmlentities($value) . '</td>'; } $table .= '<td class="text-center" filename="' . htmlentities($filename) . '"><a href="#" class="download">下载</a> / <a href="#" class="delete">删除</a></td>'; $table .= '</tr>'; } echo $table; } } 从构造函数开始,会发现这里传入了一个path形参 ...