- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嗨,
我有一个查询字符串,例如“http://project/page1.aspx?userID=5”。如果手动更改了“userID”参数,则不会执行该操作。怎么可能呢?
最佳答案
大家好,谢谢您的协助...与其他网站相比,我得到了一些不同的解决方案。我不知道最好的解决方案。即使用加密和解密算法对值进行编码...示例代码已像这样编写...
<a href='Page1.aspx?UserID=<%= HttpUtility.UrlEncode(TamperProofStringEncode("5","F44fggjj")) %>'>
Click Here</a> <!--Created one anchor tag and call the function for TamperProofStringEncode-->
private string TamperProofStringEncode(string value, string key)
{
System.Security.Cryptography.MACTripleDES mac3des = new System.Security.Cryptography.MACTripleDES();
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
mac3des.Key = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(key));
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(value)) + "-" + Convert.ToBase64String(mac3des.ComputeHash(System.Text.Encoding.UTF8.GetBytes(value)));
}
In the page load of 'Page1' call the decode algorithm to decode the query string
try
{
string DataString = TamperProofStringDecode(Request.QueryString["UserID"], "F44fggjj");
Response.Write(DataString);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
private string TamperProofStringDecode(string value, string key)
{
string dataValue = "";
string calcHash = "";
string storedHash = "";
System.Security.Cryptography.MACTripleDES mac3des = new System.Security.Cryptography.MACTripleDES();
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
mac3des.Key = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(key));
try
{
dataValue = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(value.Split('-')[0]));
storedHash = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(value.Split('-')[1]));
calcHash = System.Text.Encoding.UTF8.GetString(mac3des.ComputeHash(System.Text.Encoding.UTF8.GetBytes(dataValue)));
if (storedHash != calcHash)
{
//'Data was corrupted
throw new ArgumentException("Hash value does not match");
// 'This error is immediately caught below
}
}
catch (Exception ex)
{
throw new ArgumentException("Invalid TamperProofString");
}
return dataValue;
}
关于asp.net - 如何防止篡改查询字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2809383/
大家好,我是沙漠尽头的狼。 本文首发于 Dotnet9 ,介绍使用 Lib.Harmony 库拦截第三方 .NET 库方法,达到不修改其源码并能实现修改方法逻辑、预期行为的效果,并
我有Helm Applciations使用 Terraform 的 helm_release 资源与 Terraform 一起部署。 有时由于以下一个或多个原因,我的 Kubernetes Pod 将
我有Helm Applciations使用 Terraform 的 helm_release 资源与 Terraform 一起部署。 有时由于以下一个或多个原因,我的 Kubernetes Pod 将
我们开发了一个 Javascript 文件供客户使用。 Javascript 片段对其运行的网站进行屏幕截图,然后通过 jQuery.post() 将其发送回我们的服务器 我们行业的性质意味着我们必须
我在本地主机上运行我的测试站点。 当我用 URL 加载它时: localhost/projects/forums/index.php 它看起来像这样(符合预期) 但是当 我给 URL: localho
我正在 中共同开发一个简单的网络应用程序 rails 3.0.9 我已经意识到可能通过恶意请求篡改 session_id。请注意,这是我的第一个 RoR 应用程序,所以我的概念可能完全错误。 当前的应
我返回了以下 JSON 数据,但由于某种原因,Javascript 或 jQuery ajax 似乎重新组织了项目列表。服务器返回按item.title字母顺序排序的数据(已验证)... 下面的 JS
背景 我是一名经验丰富的 Web 开发人员(主要使用 Python 和 CherryPy),之前从头开始实现过安全 session 管理,现在正在学习 Rails。我正在调查 session 暴露的
我正在使用 MVC3、.NET4.5、C#、Razor。 我在 Codeproject 之外重用了 Albin 的一些非常有用的代码,通过添加哈希来防止 URL 篡改。主要运行良好。 然而…… 我现在
我是一名优秀的程序员,十分优秀!