Search

[xss-game] level 4

Tags
writeup
time
2022/01/10 14:21

1. 문제

1) 문제 확인
타이머 문제이다. 타이머 시간을 입력하고 버튼을 누르면 입력한 시간만큼 기달리다가,
이렇게 나온다.

2. 접근방법

저 로직을 살펴보자.
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>
JavaScript
복사
입력값이 timer라는 변수에 담겨서 get으로 넘어가는데 이는 timer.html으로 넘어간다
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>
JavaScript
복사
로딩 이미지 태그에 onload 이벤트가 등록되어있다. startTimer함수가 호출되는데, 인자로 아까 index.html에서 timer에 담긴 값이다. 여기서 필터링이 존재하지 않기 때문에, onload에 starTimer 함수를 ; 로 닫고 alert() 을 추가해주면 된다.

3. 풀이

payload = '); alert(1); ('

4. 몰랐던 개념

none