Tag Archives: JS注入

使用MitmProxy绕过Content Security Policy (CSP)

这几天测试用Selenium 和 Chrome插件都无法在 谷歌插件商店https://chrome.google.com/webstore/category/extensions?hl=en 实现JS注入 检查发现响应头里面有一个 ‘content-security-policy’,错误提示: "Refused to execute inline script because it violates the following Content Security Policy directive: "script-src ‘report-sample’ ‘nonce-wNKF1pjNhZent+g6jyFL9g’ ‘unsafe-inline’ ‘unsafe-eval’". Note that ‘unsafe-inline’ is ignored if either a hash or nonce value is present in the source list." CSP全称Content Security Policy ,可以直接翻译为内容安全策略,说白了,就是为了页面内容安全而制定的一系列防护策略. 通过CSP所约束的的规责指定可信的内容来源(这里的内容可以指脚本、图片、iframe、fton、style等等可能的远程的资源)。通过CSP协定,让WEB处于一个安全的运行环境中. 我这里使用MitmProxy绕过CSP执行JS注入 脚本如下 from bs4 import BeautifulSoup… Read More »