Search

[xss-game] level 5

Tags
writeup
time
2022/01/10 14:21

1. 문제

1) 문제 확인
회원가입 링크가 있다. 눌러보자
이메일로 회원가입을 한다. 이메일을 누르고 Next를 누르면
요렇게 회원가입성공 문구와 함께 곧 리다이렉트 된다는 문구가 나온다. 그리고 쫌 기다리면 아까 첫 페이지로 돌아간다.

2. 접근방법

로직을 살펴보자
welcome.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="level5"> Welcome! Today we are announcing the much anticipated<br><br> <img src="/static/logos/level5.png" /><br><br> <a href="/level5/frame/signup?next=confirm">Sign up</a> for an exclusive Beta. </body> </html>
JavaScript
복사
첫페이지에서 아까 Sign up을 누르면 a태그의 href에 설정된 곳으로 이동된다. next에 confirm값이 담겨서 이동된다. signup을 누르면 signup.html로 이동된다.
signup.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="level5"> <img src="/static/logos/level5.png" /><br><br> <!-- We're ignoring the email, but the poor user will never know! --> Enter email: <input id="reader-email" name="email" value=""> <br><br> <a href="{{ next }}">Next >></a> </body> </html>
JavaScript
복사
이메일을 입력하고 Next를 누르면 아까 welcome에서 next에 담겼던 confrim 값이 href에 담겨서 이동되고, confirm.html 페이지로 이동한다.
confirm.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="level5"> <img src="/static/logos/level5.png" /><br><br> Thanks for signing up, you will be redirected soon... <script> setTimeout(function() { window.location = '{{ next }}'; }, 5000); </script> </body> </html>
JavaScript
복사
next에 담긴 값을 window.location을 이용해서 리다이렉션시킨다.

3. 풀이

window.location 가 호출되는데, 인자로 next에담긴 값이 들어간다. 필터링이 없기 때문에 해당 next에 inline js코드를 넣으면 된다. 정상적인 경우 저 next에는 welcome이 들어가고 메인 페이지로 리다이렉션된다. 그렇다면,
url에서 next에 inline js코드를 넣어주고 Go를 누른다. 그러면 저렇게 a 태그의 href가 next에 담긴 값을 가져오므로 js코드가 삽입이 되었고 이상태에서 Next를 누르면 저 코드가 실행된다.

4. 몰랐던 개념

<a href="javascript:alert(1)">dd</a>
JavaScript
복사
요게 되는지는 몰랐당.
질문 1
signup.html에서 next=에