ScriptResource错误:我被黑了吗?

Pau*_*aul 7 .net scriptresource.axd

我一直在我的网站上收到这样的错误.它往往会在一天中随机发生,直到我不希望网站上的用户.

它始终来自不同的IP地址

System.Web.HttpException:无效的viewstate.System.Web.UI.Page.DecryptString(String s)上的System.Web.UI.Page.DecryptStringWithIV(String s,IVType ivType)

要么

System.Security.Cryptography.CryptographicException:填充无效,无法删除.在System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte [] inputBuffer,Int32 inputOffset,Int32 inputCount,Byte []&outputBuffer,Int32 outputOffset,PaddingMode paddingMode,Boolean fLast)at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte [ ] System.Security.Cryptography.CryptoStream.FlushFinalBlock()处于System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt,Byte [] buf,Byte []修饰符,Int32 start,Int32长度的inputBuffer,Int32 inputOffset,Int32 inputCount) ,IVType ivType,Boolean useValidationSymAlgo)在System.Web.UI.Page.DecryptString(String s)的System.Web.UI.Page.DecryptStringWithIV(String s,IVType ivType)

它们发生在这个页面中:

 ScriptResource.axd?d=VVe1O4rzLSI9hB5nRzBXZxUYTQz6ylDTL9djGR
Run Code Online (Sandbox Code Playgroud)

该站点用户使用Ajax并在.NET 3上运行.

这个人是否试图入侵该网站?这是网站上的HTML错误吗?

有任何想法吗?

Pau*_*art 5

我相信这个错误是由您的ViewState使用过时的ViewStateUserKey解密引起的.

删除这些错误分为两步:

  1. 确保您具有特定于站点的验证密钥.您可以使用多个在线资源为您生成一个,例如这个.
  2. 确保页面的ViewStateUserKey始终保持一致.从MSDN文档:

设置ViewStateUserKey属性可以帮助您防止恶意用户对您的应用程序的攻击.它通过允许您为单个用户的视图状态变量分配标识符来实现此目的,这样他们就无法使用该变量来生成攻击.您可以将此属性设置为任何字符串值,例如用户的会话ID或用户的经过身份验证的名称.

您可以通过自己设置(可能在您的Page或基页的Init事件中)来完成此操作:

if (Session["ViewStateUserKey"] == null)
{
    Session["ViewStateUserKey"] = new Guid().ToString();
}    
this.Page.ViewStateUserKey = Session["ViewStateUserKey"].ToString();
Run Code Online (Sandbox Code Playgroud)

不,我不认为你被黑了.