1.使用 SQL 注入的认证旁路javascript
答: 登陆、注册页面输入信息,过滤sql关键字或关键字符;css
提交表单页面、查询页面的输入项,过滤sql关键字或关键字符。html
// 关键字java
string StrKeyWord = @"select|insert|delete|from|count\(|drop table|update|truncate|asc\(|mid\(|char\(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|""|or|and";web
//关键字符sql
string StrRegex = @"[-|;|,|/|\(|\)|\[|\]|}|{|%|\@|*|!|']";shell
2.已解密的登陆请求浏览器
答:一种说法是使用SSL证书,暂时没有解决。服务器
3.登陆错误消息凭证枚举cookie
答:用户登陆时,若是输入错误的用户信息,最好提示同一个错误消息提醒,好比:你的用户名或密码输入错误。提供枚举提示,容易被暴力破解。
4.会话标识未更新
答:登陆以后更改会话标识符,主要用于登陆页面。
参考方案: http://www.2cto.com/Article/201302/190228.html 测试没有效果
http://blog.itpub.net/12639172/viewspace-441971/ 测试ok
在登陆页面,添加红线加粗部分
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session.Abandon();
//清除SessionId
Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
txt_Fileld1.Focus();
}
}
5.跨站点请求伪造
答:每一个页面请求时,判断主机和端口与配置文件信息是否一致。
网上参考方法:
1,利用referer判断,
可是用户有可能设置浏览器使其在发送请求时不提供 Referer,这样的用户也将不能访问网站。
2,在请求中添加 token 并验证
关键在于在请求中放入黑客所不能伪造的信息,而且该信息不存在于 cookie 之中,
能够在服务器端生成一个随机码,而后放在form的hidden元素中,form提交的时候在服务器端检查。
6.Missing "Content-Security-Policy" header
答: 在web.config 配置文件中添加以下响应头
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Content-Type-Options" value="nosniff"/>
<add name="X-XSS-Protection" value="1;mode=block"/>
<add name="X-Frame-Options" value="SAMEORIGIN"/>
<add name="Content-Security-Policy" value="default-src 'self'"/>
</customHeaders>
</httpProtocol>
</system.webServer>
7.Missing "X-Content-Type-Options" header
答: 在web.config 配置文件中添加以下响应头,添加节点见 第6 个问题
<add name="X-Content-Type-Options" value="nosniff"/>
8.Missing "X-XSS-Protection" header
答: 在web.config 配置文件中添加以下响应头,添加节点见 第6 个问题<add name="X-XSS-Protection" value="1;mode=block"/>
9.查询中接受的主体参数
答:未解决
10.启用了 Microsoft ASP.NET 调试
答:应用程序发布后,修改配置文件节点compilation 的属性 debug为 false。<compilation debug="false" targetFramework="4.0"/>
11.缺乏跨帧脚本编制防护
答:在web.config 配置文件中添加以下响应头,添加节点见 第6 个问题<add name="Content-Security-Policy" value="default-src 'self'"/>
注意,添加以后,可能会出现不一样浏览器,出现兼容性问题,会有不一样的反应。好比,极速模式会出现页面内部css无效。
12.已解密的 __VIEWSTATE 参数
答:在web.config 配置文件中添加 pages 的属性viewStateEncryptionMode 为Always。<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" viewStateEncryptionMode="Always" />
13.检测到应用程序测试脚本
答: 在系统开发过程当中,添加的测试页面,在程序发布前须要“从项目中排除”后再发布。
14.应用程序错误
答:出现应用程序错误页面。如 :Server Error in '/' Application.
一是解决属于开发人员的应用程序错误问题,二是在配置文件添加默认出错页面
<customErrors mode="On" defaultRedirect="~/error.html" />15.整数溢出
答:状况一:针对请求的url中的参数, 检查其数据类型及边界范围。
如 /ApplyShow.aspx?id=99999999999999999999
状况二:登陆页面按钮参数,在请求正文里,未找到缘由???
http://localhost:83/login.aspx 实体: ImgbtnDl.y (Parameter)
16.WebResource.axd
WebResources.axd?d=xyz。WebResource.axd有一个特色,即是会对错误的密文(即d=xyz中的xyz)产生500错误,而对正确的密文产生404错误,这便造成了足够的提示
参考资料:http://www.2cto.com/Article/201009/75162.html
http://pan.baidu.com/share/link?shareid=3851057069&uk=2164275402
http://www.cnblogs.com/JeffreyZhao/archive/2010/09/25/things-about-padding-oracle-vulnerability-in-asp-net.html
http://www.cnblogs.com/shanyou/archive/2010/09/25/1834889.html Padding Oracle Attack 检测工具
解决方法: http://www.cnblogs.com/shanyou/archive/2010/09/24/1833757.html 中文版http://weblogs.asp.net/scottgu/important-asp-net-security- vulnerability 英文版
1.添加配置节点
.net 3.5 及之前版本,添加配置节点
<customErrors mode="On" defaultRedirect="~/error.html" />
.net 3.5 SP1 或 .net 4.0添加以下配置节点,注意加粗部分必须
<customErrors mode="On" defaultRedirect="~/error.aspx" redirectMode="ResponseRewrite" />
2.添加默认错误页面
<%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Security.Cryptography" %> <%@ Import Namespace="System.Threading" %> <script runat="server"> void Page_Load() { byte[] delay = new byte[1]; RandomNumberGenerator prng = new RNGCryptoServiceProvider(); prng.GetBytes(delay); Thread.Sleep((int)delay[0]); IDisposable disposable = prng as IDisposable; if (disposable != null) { disposable.Dispose(); } } </script> <html> <head runat="server"> <title>Error</title> </head> <body> <div> An error occurred while processing your request. </div> </body> </html>
若是谁有更好的解决方法 ,谢谢提供!
转载自:http://www.tuicool.com/articles/Ajqa2uj