当前位置: 首页 > wzjs >正文

新手学做网站相关书籍南阳微网站建设

新手学做网站相关书籍,南阳微网站建设,天津快速关键词排名,做视频网站技术壁垒在哪里Microsoft IIS 版本信息泄露 查看网页返回的 Header 信息&#xff0c;默认会包含 IIS&#xff0c;ASP.NET 版本信息&#xff1a; 隐藏 Server 标头 编辑 web.config 文件&#xff0c;在 system.webServer 节点中配置 requestFiltering 来移除Server标头&#xff1a; <sec…

Microsoft IIS 版本信息泄露

查看网页返回的 Header 信息,默认会包含 IIS,ASP.NET 版本信息:

隐藏 Server 标头

编辑 web.config 文件,在 system.webServer 节点中配置 requestFiltering 来移除Server标头:

<security>
+  <requestFiltering removeServerHeader ="true" />
</security>

隐藏 X-ASPNET-Version 标头

编辑 web.config 文件,在 system.web 节点, 添加以下配置代码:

<system.web>
+  <httpRuntime enableVersionHeader="false" />
</system.web>

隐藏 X-Powered-By 标头

编辑 web.config 文件,在 system.webServer.customeHeaders 节点, 添加以下代码:

<system.webServer><httpProtocol><customHeaders>
+	    <remove name="X-Powered-By" /></customHeaders></httpProtocol></system.webServer>

修改完响应 Header 如下所示:

未加密的__VIEWSTATE参数

编辑 web.config 文件,在 system.web 节点, 添加以下配置代码:

	<system.web>
+		<pages enableEventValidation="true" validateRequest="false" viewStateEncryptionMode="Always" enableViewStateMac="true"></system.web>

以上配置加密__VIEWSTATE 参数,并启用__EVENTVALIDATION;

HTML FORM 表单没有CSRF防护

通过全局向 注入隐藏域 CSRF 标签,即 , 服务端收到请求时,会验证 CSRFToken 是否正确,不正确则拒绝请求。

添加 App_code/CSRFInjectingFilter.cs

using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;public class CSRFInjectingFilter : Stream
{private Stream _responseStream;private StringBuilder _buffer = new StringBuilder();private string _csrfToken;public CSRFInjectingFilter(Stream responseStream, string csrfToken) {_responseStream = responseStream;_csrfToken = csrfToken;}public override void Write(byte[] buffer, int offset, int count) {string content = Encoding.UTF8.GetString(buffer, offset, count);content = InjectToken(content);byte[] outData = Encoding.UTF8.GetBytes(content);_responseStream.Write(outData, 0, outData.Length);}private string InjectToken(string html) {string hiddenInput = string.Format("<input type='hidden' name='CSRFToken' value='{0}' />", _csrfToken);return Regex.Replace(html, @"<form[^>]*>", match => match.Value + hiddenInput, RegexOptions.IgnoreCase);}// 其他 Stream 抽象成员实现public override bool CanRead { get { return false; } }public override bool CanSeek { get { return false; } }public override bool CanWrite { get { return true; } }public override void Flush() { _responseStream.Flush(); }public override long Length {get { throw new NotSupportedException(); }}public override long Position {get { throw new NotSupportedException(); }set { throw new NotSupportedException(); }}public override int Read(byte[] buffer, int offset, int count) { throw new NotSupportedException();}public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); }public override void SetLength(long value) { throw new NotSupportedException();}}

添加 App_code/CSRFModule.cs

using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;public class CSRFModule : IHttpModule
{public void Init(HttpApplication context) {context.AcquireRequestState += OnAcquireRequestState;context.PreRequestHandlerExecute += OnPreRequestHandlerExecute;}private void OnAcquireRequestState(object sender, EventArgs e) {var app = (HttpApplication)sender;var context = app.Context;// 对 POST 请求做校验if (context.Request.HttpMethod == "POST" && context.CurrentHandler is System.Web.UI.Page) {string tokenFromForm = context.Request.Form["CSRFToken"];string tokenFromSession = null;if (context.Session != null) {tokenFromSession = context.Session["CSRFToken"] as string;}if (string.IsNullOrEmpty(tokenFromForm) || tokenFromForm != tokenFromSession) {context.Response.StatusCode = 403;context.Response.Write("CSRF 验证失败");context.Response.End();}}}private void OnPreRequestHandlerExecute(object sender, EventArgs e){var app = (HttpApplication)sender;var context = app.Context;// 只处理 text/html 类型响应if (context.CurrentHandler is System.Web.UI.Page && context.Response.ContentType == "text/html") {if (context.Session["CSRFToken"] == null) {context.Session["CSRFToken"] = Guid.NewGuid().ToString();}context.Response.Filter = new CSRFInjectingFilter(context.Response.Filter, context.Session["CSRFToken"].ToString());}}public void Dispose() { }
}

配置 web.config , 添加以下配置

在 system.web/httpModules 节点中添加 CSRFModule

<system.web><httpModules>
+			<add name="CSRFModule" type="CSRFModule" />

在 system.webServer/modules 节点中添加 CSRFModule

<system.webServer><modules>
+			<add name="CSRFModule" type="CSRFModule" />

其他

增加 IP 地址黑名单

首先打开“服务器管理器”中,进入“管理”,点击“添加角色和功能”,在“服务器角色”的 Web服务器/Web服务器/安全性 中找到 “IP和域限制”,勾选并安装。

安装成功后,在 IIS 中点击对应的网站,右侧面板中找到 “IP和域限制”,

双击进入,右键添加拒绝条目即可。


文章转载自:

http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://00000000.jthjr.cn
http://www.dtcms.com/wzjs/610673.html

相关文章:

  • 昆明专业网站制作公司王妃貌美还狠凶
  • 北京网站建设优化广州网站开发服务
  • 外包网站建设是什么意思公关策划公司是干什么的
  • 给上市公司做网站有什么用wordpress设置网页缩略图
  • 东台网站制作wordpress添加广告联盟
  • 青岛做网站方案为什么高德地图没有外国位置信息
  • WordPress网站运行时间抖音代运营合作模式
  • 网站开发体会静态网站怎么优化
  • 做集团网站的宁夏做网站公司
  • 六安市网站建设哈尔滨门户网站建设
  • 商务网站建设中存在的问题中国哪家做网站的公司最大
  • 让网站不要保存密码怎么做线上运营推广是做什么的
  • 做水暖的网站猪八戒网可以做网站吗
  • 建网站 主流软件美食html网页代码模板
  • dede网站 异步生成沂水做网站
  • jsp网站开发 心得大连网站建设招聘网
  • 网站建站流程图建站素材网站模板
  • 城市门户网站模板少儿编程加盟费一般多少钱
  • 广州公司网站附近网站电脑培训班
  • 上海龙华医院的网站建设东莞seo 公司
  • 网站制作公司哪家好做网站接专线费用
  • 如何查网站域名备案wordpress 下载 主题
  • 自己在家做网站网站建设维护费摊销
  • 成都市建设局网站搭建网站教学
  • 网站建设加盟模式网站的风格设计
  • 餐饮酒店网站怎么做网站建设学什么书
  • asp做网站的步骤刷推广链接的网站
  • 服务好的专业建站公司深圳网站开发哪家专业
  • 四川省建设主管部门网站Wordpress有用么
  • 中国城乡住房和建设部网站首页网页制作与网站开发感想