XSS Game level 3

Wargame/XSS Game 2018. 3. 30. 17:17


문제에 들어가보면 이전과 같이 alert를 띄우라고 한다. 근데 막상 기능을 살펴보면 서버랑 통신하는 구간이 없다. 즉 브라우저 API 단계에서 모든처리가 이루어지는 페이지이다. 문제자체는 어렵지 않았지만 그동안 XSS를 활용할 때 서버로 값을 전달하고 서버상에서 이를 받아 뿌려주는 구간에서만 공격이 가능하다는 고정관념에 갇혀있던 나에게 신선한 충격을 줬다.


문제에 접속 후 html,java script 코드를 확인해보면 다음과 같이 이미지 탭을 눌렀을때 넘기는 값들이 자바스크립트 함수내에서 이미지태그에 포함되어 동적으로 뿌려지고 있는걸 확인할 수 있었다.


<!doctype html>

<html>

  <head>

    <!-- Internal game scripts/styles, mostly boring stuff -->

    <script src="/static/game-frame.js"></script>

    <link rel="stylesheet" href="/static/game-frame-styles.css" />


    <!-- Load jQuery -->

    <script 

      src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">

    </script>


    <script>

      function chooseTab(num) {

        // Dynamically load the appropriate image.

        var html = "Image " + parseInt(num) + "<br>";

        html += "<img src='/static/level3/cloud" + num + ".jpg' />";

        $('#tabContent').html(html);


        window.location.hash = num;


        // Select the current tab

        var tabs = document.querySelectorAll('.tab');

        for (var i = 0; i < tabs.length; i++) {

          if (tabs[i].id == "tab" + parseInt(num)) {

            tabs[i].className = "tab active";

            } else {

            tabs[i].className = "tab";

          }

        }


        // Tell parent we've changed the tab

        top.postMessage(self.location.toString(), "*");

      }


      window.onload = function() { 

        chooseTab(unescape(self.location.hash.substr(1)) || "1");

      }


      // Extra code so that we can communicate with the parent page

      window.addEventListener("message", function(event){

        if (event.source == parent) {

          chooseTab(unescape(self.location.hash.substr(1)));

        }

      }, false);

    </script>


  </head>

  <body id="level3">

    <div id="header">

      <img id="logo" src="/static/logos/level3.png">

      <span>Take a tour of our cloud data center.</a>

    </div>


    <div class="tab" id="tab1" onclick="chooseTab('1')">Image 1</div>

    <div class="tab" id="tab2" onclick="chooseTab('2')">Image 2</div>

    <div class="tab" id="tab3" onclick="chooseTab('3')">Image 3</div>


    <div id="tabContent">&nbsp;</div>

  </body>

</html>


실제로 클릭해보면 다음과 같이 url상에서 #뒤에 인자값이 들어가는걸 확인할 수 있었다.


이미지 태그의 경로내에 값이 들어가고있어 형식을 맞춰서 페이로드 짜주면 된다.


payload = '%20onerror=alert(1)%20'


서버랑 통신없이 브라우저단에서 처리하는거라 Stored는 불가능하지만 취약점이 진짜 안터질때 Reflected로 시나리오 기반 모의해킹 수행할때 써먹으면 좋을 것 같다.





'Wargame > XSS Game' 카테고리의 다른 글

XSS Game level 6  (0) 2018.04.01
XSS Game level 5  (0) 2018.03.31
XSS Game level 4  (0) 2018.03.30
XSS Game level 2  (0) 2018.03.29
XSS Game Level 1  (0) 2018.03.29
블로그 이미지

JeonYoungSin

메모 기록용 공간

,