Web Hacking/Natas

[Natas] Level 23 > Level 24

SolB 2022. 11. 19. 13:54

위는 natas24의 초기화면이다.

 

아래 코드는 View sourcecode를 통해 확인해주었다.

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

Password:
<form name="input" method="get">
    <input type="text" name="passwd" size=20>
    <input type="submit" value="Login">
</form>

<?php
    if(array_key_exists("passwd",$_REQUEST)){
        if(!strcmp($_REQUEST["passwd"],"<censored>")){
            echo "<br>The credentials for the next level are:<br>";
            echo "<pre>Username: natas25 Password: <censored></pre>";
        }
        else{
            echo "<br>Wrong!<br>";
        }
    }
    // morla / 10111
?>  
<div id="viewsource"><a href="index-source.html">View sourcecode</a></div>
</div>
</body>
</html>
strcmp(문자열1, 문자열2)
문자열을 비교했을 때 문자열이 일치하면 0(true), 일치하지 않으면 1(false)를 반환, 대소문자를 구분

비밀번호와 $_REQUEST["passwd"]가 일치해야 비밀번호를 구할 수 있다.

 

strcmp 함수는 문자열 일치하면 0을 반환하는데, 배열과 비교하게 되면 무조건 0을 반환한다고 한다.

이를 적용해보자.

 

입력칸에 passwd[]= 을 입력해주었다.

이를 통해 문제를 해결할 수 있었다.

|O9QD9DZBDq1YpswiTM5oqMDaOtuZtAcx