Hacking_study/해킹과제

워게임 만들기! (Lv0. process jump)

jin_li 2023. 4. 16. 23:05
코드 소스

 

1. index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>핵미사일 시스템</title>
    <style>
        .missile-button {
            display: inline-block;
            padding: 10px 20px;
            background-color: #f00;
            color: #fff;
            text-decoration: none;
            font-size: 18px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <h1>Nuclear Missile!</h1>
    <a class="missile-button" href="process1.php">퐈이어</a>
</body>
</html>
cs

 

 

2. process1.php

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>핵미사일 시스템</title>
    <style>
        .missile-button {
            display: inline-block;
            padding: 10px 20px;
            background-color: #f00;
            color: #fff;
            font-size: 18px;
            text-decoration: none;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <h1>Nuclear Missile!</h1>
    <h3>관리자만 이용가능합니다. 관리자인 경우만 확인 버튼을 클릭하고 계속 진행해주세요</h3>
    <a class="missile-button" href="process2.php">확인</a>
</body>
</html>
cs

 

 

3. process2.php

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>핵미사일 시스템</title>
    <style>
        button {
            display: inline-block;
            padding: 10px 20px;
            background-color: #f00;
            color: #fff;
            font-size: 18px;
            text-decoration: none;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <h1>Nuclear Missile!</h1>
    <h3>관리자 인증이 필요합니다.</h3>
    <p>
        <form action="login.php" method="post">
        <input type="password" id="password" name="admin-pass" placeholder="비밀번호를 입력해주세요.">
    </p>
    <p>
        <button type="submit">확인</button>
        </form>
    </p>
</body>
</html>
cs

 

 

4. process3.php

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>핵미사일 시스템</title>
    <style>
        .missile-button {
            display: inline-block;
            padding: 10px 20px;
            background-color: #f00;
            color: #fff;
            font-size: 18px;
            text-decoration: none;
            border-radius: 5px;
        }
    </style>
    <script>
        function launchMissile() {
            alert("done!");
        }
    </script>
</head>
<body>
    <h1>Nuclear Missile!</h1>
    <h3>발사를 원하시면 아래 버튼을 클릭하세요.</h3>
    <a class="missile-button" onclick="launchMissile()">퐈이어!</a>
</body>
</html>
cs

 

 

5. login.php

<?php
    
    $passwd = $_POST['password'];
 
    if(intval($passwd=== 1001) {
        $_SESSION['password'= $passwd;
        header('Location: process3.php');       
    } else {
        echo "<script>window.alert('로그인 실패')
            history.go(-1)</script>";
    }
?>
cs

 

 

 

 

 

풀이

 

핵미사일 쏴버리자

 

 

 

위에서 "퐈이어"를 클릭했을 때, process1.php로 이동된다.

 

 

 

 

확인을 클릭하면 패스워드를 입력해야 하는 폼이 나온다.

 

 

 

 

주소가 페이지 이동될 때마다 process1.php, process2.php,... 와 같이 바뀌고 있으니 인증 성공했을 때

이동될 페이지는 process3.php 일 것이다. 따라서 이 주소를 직접 입력해서 들어가면 된다.

 

 

 

process3.php 코드를 살펴보면, 세션을 검사하지 않고 있다.

 

로그인 성공했을 때 설정되는 세션이 아닌 경우 접속을 차단하는 코드가 필요하다.