728x90
http://natas21.natas.labs.overthewire.org/index.php
natas21/IFekPyrQXftziDEsUr3x21sYuahypdgJ로 로그인
화면에 표시된 링크와 같이 보아야 하는 문제다.
일단 링크를 타고 들어가보았다.
CSS style experimenter 페이지라고 한다.
이 두 웹페이지가 연동되니 세션 id도 공유될 것이라 생각했다.
소스코드를 살펴보았다.
메인 페이지
<html>
<head>
<!-- This stuff in the header has nothing to do with the level -->
<link rel="stylesheet" type="text/css" href="http://natas.labs.overthewire.org/css/level.css">
<link rel="stylesheet" href="http://natas.labs.overthewire.org/css/jquery-ui.css" />
<link rel="stylesheet" href="http://natas.labs.overthewire.org/css/wechall.css" />
<script src="http://natas.labs.overthewire.org/js/jquery-1.9.1.js"></script>
<script src="http://natas.labs.overthewire.org/js/jquery-ui.js"></script>
<script src=http://natas.labs.overthewire.org/js/wechall-data.js></script><script src="http://natas.labs.overthewire.org/js/wechall.js"></script>
<script>var wechallinfo = { "level": "natas21", "pass": "<censored>" };</script></head>
<body>
<h1>natas21</h1>
<div id="content">
<p>
<b>Note: this website is colocated with <a href="http://natas21-experimenter.natas.labs.overthewire.org">http://natas21-experimenter.natas.labs.overthewire.org</a></b>
</p>
<?
function print_credentials() { /* {{{ */
if($_SESSION and array_key_exists("admin", $_SESSION) and $_SESSION["admin"] == 1) {
print "You are an admin. The credentials for the next level are:<br>";
print "<pre>Username: natas22\n";
print "Password: <censored></pre>";
} else {
print "You are logged in as a regular user. Login as an admin to retrieve credentials for natas22.";
}
}
/* }}} */
session_start();
print_credentials();
?>
<div id="viewsource"><a href="index-source.html">View sourcecode</a></div>
</div>
</body>
</html>
눈여겨볼 부분은 세션 key에 admin이 포함되어 있고 value가 1인지 체크하는 부분이다.
experimenter 페이지
<html>
<head><link rel="stylesheet" type="text/css" href="http://www.overthewire.org/wargames/natas/level.css"></head>
<body>
<h1>natas21 - CSS style experimenter</h1>
<div id="content">
<p>
<b>Note: this website is colocated with <a href="http://natas21.natas.labs.overthewire.org">http://natas21.natas.labs.overthewire.org</a></b>
</p>
<?
session_start();
// if update was submitted, store it
if(array_key_exists("submit", $_REQUEST)) {
foreach($_REQUEST as $key => $val) {
$_SESSION[$key] = $val;
}
}
if(array_key_exists("debug", $_GET)) {
print "[DEBUG] Session contents:<br>";
print_r($_SESSION);
}
// only allow these keys
$validkeys = array("align" => "center", "fontsize" => "100%", "bgcolor" => "yellow");
$form = "";
$form .= '<form action="index.php" method="POST">';
foreach($validkeys as $key => $defval) {
$val = $defval;
if(array_key_exists($key, $_SESSION)) {
$val = $_SESSION[$key];
} else {
$_SESSION[$key] = $val;
}
$form .= "$key: <input name='$key' value='$val' /><br>";
}
$form .= '<input type="submit" name="submit" value="Update" />';
$form .= '</form>';
$style = "background-color: ".$_SESSION["bgcolor"]."; text-align: ".$_SESSION["align"]."; font-size: ".$_SESSION["fontsize"].";";
$example = "<div style='$style'>Hello world!</div>";
?>
<p>Example:</p>
<?=$example?>
<p>Change example values here:</p>
<?=$form?>
<div id="viewsource"><a href="index-source.html">View sourcecode</a></div>
</div>
</body>
</html>
두 페이지는 세션을 공유하기 때문에, admin 세션을 experimenter 페이지로 가져오게 하면 문제를 해결할 수 있을 것 같다.
먼저 burp suite로 experimenter 페이지의 쿠키값을 확인하고, POST 방식으로 admin=1을 추가해주었다.
위와 같이 변경하고 Forward를 눌러준 뒤, 메인 페이지를 가져왔다.
메인 페이지의 세션 아이디를 experimenter 페이지의 것으로 변경하고, GET 방식으로 전송했다.
메인 페이지를 확인해보니 아래와 같이 패스워드가 나와있다.
Password: chG9fbe1Tq2eWVMgjYYD1MsfIvN461kJ
728x90
'WEB > Natas' 카테고리의 다른 글
[Natas] Level 22 → Level 23 (0) | 2021.07.27 |
---|---|
[Natas] Level 21 → Level 22 (0) | 2021.07.21 |
[Natas] Level 19 → Level 20 (0) | 2021.07.08 |
[Natas] Level 18 → Level 19 (0) | 2021.06.25 |
[Natas] Level 17 → Level 18 (0) | 2021.06.24 |