gpt4 book ai didi

javascript - 为什么javascript代码没有被执行?

转载 作者:行者123 更新时间:2023-12-02 14:36:00 25 4
gpt4 key购买 nike

我正在尝试在某些网站上测试 XSS 漏洞的安全级别,但我无法弄清楚为什么下一页中注入(inject)的脚本没有被执行。基本上,我在输入表单中插入一些值,然后服务器回复此响应

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" conent="IE-edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NECSTFeedback</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link href="/static/css.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="header clearfix">
<h3 class="text-muted">The NECSTFeedback</h3>
</div>

<h1>Report</h1>
<p><b>Subject: </b>sk</p>
<p><b>Sender: </b>as</p>
<div class="rpt-content">
<p><b>Message: </b></p>
<!-- This is my script -->
<script> alert('Hi')</script>
</div>

<p><b>Attachment: </b><a href="/attachment/58224c5bd967459c925a88eb21799384"></a></p>

</div>
</body>
</html>

我怀疑这是因为 CSP header ,但我不太确定。顺便说一句,这里是标题列表。

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 25 May 2016 19:18:31 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Security-Policy: default-src 'self'; style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/; font-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/

最佳答案

I have the suspicion that it's because of the CSP header, but I'm not too sure.

Content-Security-Policy: default-src 'self'; style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/; font-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/

确实是的。

内容安全策略规范 says here :

如果“unsafe-inline”不在 allowed script sources 的列表中[…]:每当用户代理从 <script> element 执行内联脚本时[…],相反,用户代理不得执行脚本 […]。

那个self header 中确实不允许内联脚本。

关于javascript - 为什么javascript代码没有被执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37445932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com