为什么XSS在创建的HTML页面上不起作用?

问题描述 投票:0回答:1

您好,我正在我创建的HTML页面中使用XSS-Attack进行练习,但是它不适用于我。这是HTML页面:

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Try to XSS this!</title>
    <script language="javascript" type="text/javascript">
        var send = function () {
            var data = document.getElementById("msg").value;
            document.getElementById("demo").innerHTML = data;
        }
    </script>
</head>
<body>
    <p>Enter an XSS exploit here:</p>
    <textarea id="msg" rows="10" cols="20"></textarea>
    <br />
    <input type="button" id="send" onclick="send();"/>
    <br>
    <p id="demo"></p>
</body>
</html>

这是XSS-Exploit(我在<textarea>中写了它:]

hello</p>
<script>alert("XSS");</script>
<p>

这是结果(我显示<p id="demo"></p>部分:]]

<p id="demo">
    "hello"
    <p></p>
    <script>alert("XSS");</script>
    <p></p>
</p>

并且命令alert("XSS");不起作用。我做错了什么?

您好,我正在我创建的HTML页面中使用XSS-Attack进行练习,但是它不适用于我。这是HTML页面:&...

javascript html xss
1个回答
0
投票

脚本标记仅在页面加载时运行;当您将它们动态注入页面时,不会运行脚本标记。常见的绕过方法是使用onerroronload,例如<img src=x onerror='alert(1)'><svg onload='alert(1)'></svg>

© www.soinside.com 2019 - 2024. All rights reserved.