본문 바로가기
CTF Write-UP/suninatas.com

suninatas.com - 2번 문제

by CPU 2022. 11. 11.

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 버튼을 눌러보았지만,

에러가 발생하는것을 확인할수 있다.

코드를 다시 체크해보니 Join 버튼을 클리하면 chk_form() 함수를 실행하도록 되어 있다.

스크립트를 확인해보았다.

	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();
		}
	}

소스코드를 분석한 결과 id와 pw와 같은 값일시 아까 팝업창으로 보았던 You can't join! Try again 문구가 출력될 것이고, 다른 값일시문제가 풀리는 것이다.

 

아까 힌트에서는 id와 pw값이 같을 경우라고 했고 스크립트에서 다를경우 문제가 풀린다고 했다.

그러면 우회하는 방법을 통해서 문제를 풀이하여 한다.

 

우선 ID와 PW 값에 동일한 숫자(1)을 넣고 "Console"창에 document.web02.submit();를 입력하고 엔터를 눌러준다.

그 결과 키값을 구할수 있었다.

Authkey값을 입력하여 답을 제출하면 점수를 획득함과 동시에 문제가 풀렀음을 알수 있다.

'CTF Write-UP > suninatas.com' 카테고리의 다른 글

suninatas.com - 6번 문제  (0) 2022.11.20
suninatas.com - 5번 문제  (1) 2022.11.19
suninatas.com - 4번 문제  (0) 2022.11.18
suninatas.com - 3번 문제  (0) 2022.11.13
suninatas.com - 1번 문제  (0) 2022.11.09

댓글