最近林林总总收到客户投诉,说是app被植入广告代码了,无奈,上了劫持上报工具,检测发现,有的客户web被植入大量广告信息,无意中发现了一个比较不错的解决方案,那就是使用CSP(Content-Security-Policy),内容安全策略:

CSP 全称为 Content Security Policy,即内容安全策略。主要以白名单的形式配置可信任的内容来源,在网页中,能够使白名单中的内容正常执行(包含 JS,CSS,Image 等等),而非白名单的内容无法正常执行,从而减少跨站脚本攻击(XSS),当然,也能够减少运营商劫持的内容注入攻击。

在 HTML 的 Head 中添加如下 Meta 标签,将在符合 CSP 标准的浏览器中使非同源的 script 不被加载执行。不支持 CSP 的浏览器将自动会忽略 CSP 的信息,不会有什么影响。具体兼容性可在本文末尾参考资料中找到

  1. <meta http-equiv="Content-Security-Policy" content="default-src 'self'">
  1. Content-Security-Policy:
  2. default-src 'unsafe-inline' 'unsafe-eval' 'self'  *.vincentguo.cn *.yunetidc.com *.baidu.com *.cnzz.com *.c-cnzz.com *.duoshuo.com *.jiathis.com;report-uri /error/csp

需要说明的的是:多个域名中间要有空格;report-uri /error/csp 的作用为:遇到劫持,直接上报到地址:/error/csp

更多详细参考资料:

  1. XSS终结者-CSP理论与实践 

  2. 普遍的HTTP劫持

  3. CSP浏览器支持列表

  4. CSP策略指令

感谢:vincentguo

posted @ 2017-01-06 14:42 zhangsir 阅读(1) 评论(0) 推荐(0) 编辑
摘要: Session的几种存储方式就不在这里赘述了,直接切入正题: 由于X5内核有一套独立的处理cookie的机制,当前进程结束时,会去检测cookie有效期,当检测不到的时候,会杀掉这个cookie。 介于以上原因,在服务器端,设置session后(.net 会自动产生一个cookie:ASP.NET_ 阅读全文
posted @ 2016-10-21 17:43 zhangsir 阅读(689) 评论(0) 推荐(0) 编辑
摘要: 项目运行好好的,增加并更新WebService后,出错,捕获异常信息为:对操作“xxx”的回复消息正文进行反序列化时出错。解决方案。 认真分析异常信息后,得到关键提醒: 根据这个重要提醒,修改配置文件,修改报错服务的相应节点就OK了。修改后的节点如下: 以上配置仅供参考。 阅读全文
posted @ 2016-07-07 18:08 zhangsir 阅读(3458) 评论(0) 推荐(0) 编辑
摘要: 若页面需默认用ie兼容内核,增加标签:若页面需默认用ie标准内核,增加标签:--> 页面标题 阅读全文
posted @ 2014-07-03 17:16 zhangsir 阅读(180) 评论(0) 推荐(0) 编辑
摘要: ALTER PROCEDURE [dbo].[sp_pager]/****************************************************************** 千万数量级分页存储过程 **************************************... 阅读全文
posted @ 2014-05-22 15:57 zhangsir 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 在正确设置好net.tcp WCF服务并发布到IIS后,客户端还是不能引用服务出现类似如下错误:该问题并不一定设置MaxNameTableCharCount能解决,即便设置一个很大的数字还是不能正确引用,其实这个问题是由于VS的环境引起,需要修改一下配置文件:C:\Program Files\Mic... 阅读全文
posted @ 2014-05-13 15:40 zhangsir 阅读(184) 评论(0) 推荐(0) 编辑
摘要: //获取一个对象function getByid(id) { if (document.getElementById) { return document.getElementById(id); } else if (document.all) { return document.all[id]; } else if (document.layers) { return document.layers[id]; } else { return null; }}//运行框操作function creatID(D... 阅读全文
posted @ 2014-02-27 11:17 zhangsir 阅读(961) 评论(0) 推荐(0) 编辑
摘要: getRegions file1 file2 file3 file4 file5 file6 file7 file8 file9 file10 file11 file12 file13 file14 file15 file16 file17 file18 file19 file20 file21 file22 file23 file24 file25 file26 file27 file28 file29 file30 file31 file32 file33 file34 file35 file36 file37 file38 file39 ... 阅读全文
posted @ 2014-02-27 11:13 zhangsir 阅读(594) 评论(0) 推荐(0) 编辑
摘要: CREATE PROC [dbo].[usp_spFactorial]@InputValue INT,@OuputValue INT OUTPUTASBEGIN DECLARE @InValue INT; DECLARE @OutValue INT; IF(@InputValue!=0) BEGIN SET @InValue = @InputValue - 1; EXEC usp_spFactorial @InValue,@OutValue OUTPUT; ... 阅读全文
posted @ 2014-01-25 11:29 zhangsir 阅读(400) 评论(0) 推荐(0) 编辑
摘要: --查找父,包括自己CREATE PROC [dbo].[usp_spGetParentsID]@InputID INT--@ParentID UNIQUEIDENTIFIER OUTPUTASBEGIN DECLARE @strResult Nvarchar; set @strResult=''; with cte as(select ID,ParentID from Zitian_Categories where id=@InputIDunion allselect a.id,a.ParentID from Zitian_Categories a join cte b .. 阅读全文
posted @ 2014-01-25 11:28 zhangsir 阅读(181) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示