보안을 그리다, 훈이

[Web Hacking] 써니나타스(SuNiNaTaS) 2번 문제 Write Up 본문

Security/Wargame

[Web Hacking] 써니나타스(SuNiNaTaS) 2번 문제 Write Up

HooNeee 2021. 11. 15. 21:35

 

2번 문제도 마찬가지로 asp 파일로 구성된 Web 분야 문제이다.

 

 

Game 02

 

suninatas.com

 

[SuNiNaTaS] Challenge 2

 

ID와 PW 텍스트박스와 Join 버튼만 주어져 있을 뿐 아무런 단서가 없기에 페이지 소스코드를 보기로 했다.

 

<!DOCTYPE html>

<html>
<head>
    <title>Game 02</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="shortcut icon" href="/static/img/game.ico" />
</head>
<body>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <form method="post" name="web02">
        <table width="240" cellpadding="0" cellspacing="0" align="center">
            <tr height="30">
                <td colspan="2" bgcolor="cccccc" align="center"><b>LEVEL 2</b></td>
            </tr>
            <tr height="30">
                <td colspan="2" width="100%" class="table_top" align="right">
                    <input type="button" name="main_btn" value="main" style="width: 60" onclick="location.href = '/'">&nbsp<input type="button" name="main_btn" value="Back" style="width: 60" onclick="history.back()"></td>
            </tr>
            <tr height="30" class="table_main">
                <td width="90" align="center" bgcolor="cccccc"><font size="2"><b>ID</b></font></td>
                <td width="150" align="center" bgcolor="cccccc">
                    <input type="text" name="id" style="width: 140"></td>
            </tr>
            <tr height="30" class="table_main">
                <td width="90" align="center" bgcolor="cccccc"><font size="2"><b>PW</b></font></td>
                <td width="150" align="center" bgcolor="cccccc">
                    <input type="password" name="pw" style="width: 140"></td>
            </tr>
            <tr height="30">
                <td colspan="2" align="center" class="table_top">
                    <input type="button" value="Join" style="width: 60" onclick="chk_form()">
            </tr>
            <tr height="30" class="table_main">
                <td colspan="2" align="center" bgcolor="cccccc">Authkey : ?????</td>
            </tr>
        </table>
</body>
</html>
<script>
	function chk_form(){
		var id = document.web02.id.value ;
		var pw = document.web02.pw.value ;
		if ( id == pw )
		{
			alert("You can't join! Try again");
			document.web02.id.focus();
			document.web02.id.value = "";
			document.web02.pw.value = "";
		}
		else
		{
			document.web02.submit();
		}
	}
</script>
<!-- Hint : Join / id = pw -->
<!-- M@de by 2theT0P -->

 

마지막 주석 부분을 보니 id와 pw가 같다는 힌트를 주길래 ID와 PW 텍스트박스에 각각 1을 넣고 Join 버튼을 눌러보았지만,

 

[SuNiNaTaS] Alert

 

입장할 수 없으니 다시 시도하라는 팝업창이 튀어나왔다!

 

역시나 쉽게 줄리가 없지ㅋㅋ 기대도 안 했다.

 

그래서 본격적으로 소스코드를 분석해보았다.

 

너무 길어서 중요한 부분만 긁어와봄.

 

<tr height="30">
	<td colspan="2" align="center" class="table_top">
	<input type="button" value="Join" style="width: 60" onclick="chk_form()">
</tr>

 

Join 버튼을 클릭하면 chk_form() 함수를 실행하도록 되어 있다.

 

함수명을 보니 뭔가를 검증하는 역할을 하는 것 같다.

 

어떤 역할을 수행하는지는 아래 script문을 보면 된다.

 

<script>
	function chk_form(){
		var id = document.web02.id.value ;
		var pw = document.web02.pw.value ;
		if ( id == pw )
		{
			alert("You can't join! Try again");
			document.web02.id.focus();
			document.web02.id.value = "";
			document.web02.pw.value = "";
		}
		else
		{
			document.web02.submit();
		}
	}
</script>

 

id와 pw 값이 같으면 아까 튀어나왔던 입장이 불가하니 재시도하라는 팝업창을 띄우고, 다르면 document.web02.submit(); 함수를 실행한다.

 

즉, id와 pw 값이 달라야 한다는 말인데 아니.. 힌트에서는 같아야 한다고 해 놓고 완전 딴판이다.

 

어쨌든 우리는 우회를 해서 document.web02.submit(); 함수를 실행시켜야 한다.

 

[SuNiNaTaS] Solution

 

위 그림과 같이 ID, PW 텍스트박스에 서로 같은 값(1)을 입력한 후 실행하고자 하는 함수를 Console 창 입력하고 엔터키를 누르면 Authkey가 바로 나온다!

 

 

 

이제 두 문제 풀었다..

 

Comments