豫商杯web的WP

題目一

1.variable --提示:something about php

http://ctf3.shiyanbar.com/web/variable/ 打開題目發現

源碼可以下載下來,於是我們下載源碼打開

<?php
include("secret.php");

?>
<html>
    <head>
        <title>The Ducks</title>
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
    </head>
    <body>
        <div class="container">
            <div class="jumbotron">
                <center>
                    <h1>The Ducks</h1>
                    <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { ?>
                        <?php
                        extract($_POST);
                        if ($pass == $thepassword_123) { ?>
                            <div class="alert alert-success">
                                <code><?php echo $theflag; ?></code>
                            </div>
                        <?php } ?>
                    <?php } ?>
                    <form action="." method="POST">
                        <div class="row">
                            <div class="col-md-6 col-md-offset-3">
                                <div class="row">
                                    <div class="col-md-9">
                                        <input type="password" class="form-control" name="pass" placeholder="Password" />
                                    </div>
                                    <div class="col-md-3">
                                        <input type="submit" class="btn btn-primary" value="Submit" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </center>
            </div>
            <p>
                <center>
                    source at <a href="source.phps" target="_blank">/source.php</a>
                </center>
            </p>
        </div>
    </body>
</html>

定位到關鍵函數:extract() 這個函數通過百度我們可以知道:extract()函數從數組中將變量導入到當前的符號表。該函數使用數組鍵名作爲變量名,使用數組鍵值作爲變量值。針對數組中的每個元素,將在當前符號表中創建對應的一個變量。第二個參數 type 用於指定當某個變量已經存在,而數組中又有同名元素時,extract() 函數如何對待這樣的衝突。該函數返回成功導入到符號表中的變量數目。

於是看到關鍵代碼if ($pass == $thepassword_123)這裏可以用變量覆蓋,重新post兩個相同名字不同值的變量上去就可以覆蓋 payload:http://ctf3.shiyanbar.com/web/variable/ 需要post的數據:pass=123&thepassword_123=123 flag{f1c6edcdc3f1c291eea3f266600439aa}

題目二

2.md5 --提示:md5算法的漏洞?

http://ctf3.shiyanbar.com/web/md5/ 打開看到源碼

please input a
source code:
<?php
$md51 = md5("QNKCDZO");
$a = @$_GET["a"];
$md52 = @md5($a);
if(isset($a)){
if ($a != "QNKCDZO" && $md51 == $md52) {
    echo "flag{*****************}";
} else {
    echo "false!!!";
}}
else{echo "please input a";}
?>

直接想到php黑魔法:和QNKCDZOMD5相等的數是240610708 payload:http://ctf3.shiyanbar.com/web/md5/?a=240610708 flag{56f008ff31c89382e15915a8ad78f209}

題目三

3.無論你輸入什麼都是錯的

http://ctf3.shiyanbar.com/web/wrong/ 打開輸入任何東西都錯誤於是查看源代碼,發現右鍵被禁用 用最古老的姿勢:view-source:http://ctf3.shiyanbar.com/web/wrong/ 看到有個not.js

function stop(){
alert('其實破解我很簡單,加油哦!');
return false;
}
document.oncontextmenu=stop;

function SymError()
{
  return true;
}
window.onerror = SymError;
{% endcodeblock %}
看出來這是禁用右鍵,於是我們修改爲:
{% codeblock %}
function stop(){
return true;
}
document.oncontextmenu=stop;

function SymError()
{
  return true;
}
window.onerror = SymError;

發現可以右鍵審查元素,發現一個da.html直接訪問,F12審查元素得到flag flag{a37b3a66-172f-434d-9105-aada3aed5bdc}

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