【发布时间】:2022-11-10 18:00:51
【问题描述】:
我想创建一个简单的 XSS。下面是我的代码
<body>
<script>
function update(){
const message = document.getElementById("message").value;
document.getElementById("show_message").innerHTML = message
}
</script>
<h1 class="title">Cross-Site Scripting</h1>
<div class="input">
<input type="text" id="message"/><br/>
<button type="button" onclick="update()">submit</button>
</div>
<hr/>
<div id="root">
You typed :
<span id="show_message">
</span>
</div>
</body>
然后我尝试输入<script>alert(1);</script>。但它不起作用。
问题出在哪里?
【问题讨论】:
-
现在的浏览器不是在运动某种xss protection吗?最简单的测试是做一个stored xss,由于浏览器的反xss,好的旧反射(就像你做的那样)很少起作用。
-
.innerHTML不执行<script></script>内的代码,考虑使用document.write()执行
标签: javascript html xss