해당 게시물은 공부를 목적으로 작성하였습니다.
부족한 부분이나 추가할 내용이 있다면 언제든 알려주시면 감사하겠습니다!
- war game site : https://xss-game.appspot.com/
XSS game
Welcome, recruit! Cross-site scripting (XSS) bugs are one of the most common and dangerous types of vulnerabilities in Web applications. These nasty buggers can allow your enemies to steal or modify user data in your apps and you must learn to dispatch the
xss-game.appspot.com
level 4.
Mission Description
Every bit of user-supplied data must be correctly escaped for the context of the page in which it will appear.
This level shows why.
create timer를 클릭해보면,
get파라미터 timer=3이 되어있고 3초가 지난후에 Time is up! 팝업이 뜨게된다.
해당 문제를 풀기위해 봐야하는 코드는 다음과 같다.
<!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>
위에서 버튼을 클릭한 뒤 봤던 팝업은 startTimer함수를 통해 발생되었던 것이고 <img>태그의 onload속성에서 사용되는 함수이다.
get파라미터로 작성한 값이 인자로 사용되기에 onload 속성의 startTimer함수가 사용될때 javascript injection으로 alert를 띄워버리면 된다.
문제 설명에서 봤던 것과 같이 escaped를 생각해야 한다.
');alert(1
;를 이용해 multiple function이 가능하다.
하지만 url에 직접 입력할 경우, 인코딩을 고려하여 %3b 혹은 -로 입력해야한다.
다음번에는 javascipt injection에 대해 정리해보겠습니당
'Web Hacking' 카테고리의 다른 글
[Dreamhack] node-seriali (0) | 2024.03.29 |
---|---|
[Dreamhack] Mango (1) | 2024.03.27 |
XSS GAME - level 6 (0) | 2024.03.07 |
XSS GAME - level 5 (0) | 2024.03.07 |
XSS GAME - level 1 ~ 3 (0) | 2024.03.05 |