Over the Wire/natas

[OvertheWire:natas] level 9 → 10

ruming 2021. 5. 16. 19:48

저번과 비슷한 화면이 나왔다. 어떤 글자를 필터링하는 것 같다.

 

소스코드 확인

<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": "natas10", "pass": "<censored>" };</script></head>
<body>
<h1>natas10</h1>
<div id="content">

For security reasons, we now filter on certain characters<br/><br/>
<form>
Find words containing: <input name=needle><input type=submit name=submit value=Search><br><br>
</form>


Output:
<pre>
<?
$key = "";

if(array_key_exists("needle", $_REQUEST)) {
    $key = $_REQUEST["needle"];
}

if($key != "") {
    if(preg_match('/[;|&]/',$key)) {
        print "Input contains an illegal character!";
    } else {
        passthru("grep -i $key dictionary.txt");
    }
}
?>
</pre>

<div id="viewsource"><a href="index-source.html">View sourcecode</a></div>
</div>
</body>
</html>

if문을 보니 ; | & 을 필터링한다. 저번처럼 풀 수는 없겠다. 

 

근데 모든 특수문자를 필터링 하는 게 아니라서 필터링 하지 않는 특수문자로 풀 수도 있을 것 같다.

저번 문제를 풀다가 .를 입력하면 모든 단어가 나온다는 것을 알았는데, 다음과 같이 입력하니 비밀번호를 획득할 수 있었다.

. /etc/natas_webpass/natas11

U82q5TCMMQ9xuFoI3dYX61s7OZD9JKoK

 

더보기

저번문제처럼 명령어에 따라 푸는 방법이 여러가지라 다른 풀이도 첨부한다.

 

'[a-z]' /etc/natas_webpass/natas11

비밀번호가 숫자와 문자로 이루어져 있으므로 이런 방식으로 찾을 수가 있다.

[0-9]로 숫자도 검색 가능하다.

 

^ /etc/natas_webpass/natas11

 

필자랑 비슷한 방법으로 풀었는데 추측이지만 설명이 나온 블로그가 있어 첨부한다.

https://overthewire.org/wargames/natas/natas10.html

 

'Over the Wire > natas' 카테고리의 다른 글

[OvertheWire:natas] natas 11 → 12  (0) 2021.05.23
[OvertheWire:natas] natas 10 → 11  (0) 2021.05.18
[natas] level 8 → 9  (0) 2021.05.09
[natas] level 7 → 8  (0) 2021.05.09
[natas] level 6 → 7  (0) 2021.04.10