zoukankan
html css js c++ java
.net中SQL防注入代码
在网站里新建
Global.asax,添加
void Application_BeginRequest(object source, EventArgs e)
{
COMP.ProcessRequest pr = new COMP.ProcessRequest();
pr.StartProcessRequest();
}
comp里面有文件
ProcessRequest.cs代码如下
public
class
ProcessRequest
{
SQL注入式攻击代码分析
#region
SQL注入式攻击代码分析
/**/
///
<summary>
///
处理用户提交的请求
///
</summary>
public
void
StartProcessRequest()
{
try
{
string
getkeys
=
""
;
string
sqlErrorPage
=
"
/
"
;
if
(System.Web.HttpContext.Current.Request.QueryString
!=
null
)
{
for
(
int
i
=
0
; i
<
System.Web.HttpContext.Current.Request.QueryString.Count; i
++
)
{
getkeys
=
System.Web.HttpContext.Current.Request.QueryString.Keys[i];
if
(
!
ProcessSqlStr(System.Web.HttpContext.Current.Request.QueryString[getkeys].ToLower()))
{
System.Web.HttpContext.Current.Response.Redirect(sqlErrorPage);
System.Web.HttpContext.Current.Response.End();
}
}
}
//
if (System.Web.HttpContext.Current.Request.Form != null)
//
{
//
for(int i=0;i<System.Web.HttpContext.Current.Request.Form.Count;i++)
//
{
//
getkeys = System.Web.HttpContext.Current.Request.Form.Keys[i];
//
if (!ProcessSqlStr(System.Web.HttpContext.Current.Request.Form[getkeys].ToLower()))
//
{
//
System.Web.HttpContext.Current.Response.Redirect (sqlErrorPage);
//
System.Web.HttpContext.Current.Response.End();
//
}
//
}
//
}
}
catch
{
//
错误处理: 处理用户提交信息!
}
}
/**/
///
<summary>
///
分析用户请求是否正常
///
</summary>
///
<param name="Str">
传入用户提交数据
</param>
///
<returns>
返回是否含有SQL注入式攻击代码
</returns>
private
bool
ProcessSqlStr(
string
Str)
{
bool
ReturnValue
=
true
;
try
{
if
(Str
!=
""
&&
Str
!=
null
)
{
string
SqlStr
=
""
;
if
(SqlStr
==
""
||
SqlStr
==
null
)
{
SqlStr
=
"
'|and|exec|insert|select|delete|update|count|*|chr|mid|master|truncate|char|declare
"
;
}
string
[] anySqlStr
=
SqlStr.Split(
'
|
'
);
foreach
(
string
ss
in
anySqlStr)
{
if
(Str.IndexOf(ss)
>=
0
)
{
ReturnValue
=
false
;
}
}
}
}
catch
{
ReturnValue
=
false
;
}
return
ReturnValue;
}
#endregion
}
comp下载地址:
点此
查看全文
相关阅读:
jsp 页面获取当前路径
html5 页面音频
微信关于网页授权access_token和普通access_token的区别
Texlive source
vscode 快捷键
vscode setting
vscode extension 插件管理
what
linux manual
java tool type
原文地址:https://www.cnblogs.com/SALIN/p/1196657.html
最新文章
smsService接口(dubbo接口)
【Python045-魔法方法:属性访问】
【Python044--魔法方法:简单定制】
【Python043-魔法方法:算术方法2】
Python面向对象编程指南(第10章)用Shelve保存和获取对象
PythonCookbook第4章(迭代器和生成器)良好完成
python -O 有意思的一个信号,Python -的各种模式
PythonCookbook第七章(函数)【透彻完结】
python普通装饰器为什么能够给方法装饰,定义成类的话必须要定义__get__
PythonCookbook第九章(元编程)【持续更新】
热门文章
Linux命令行与shell脚本编程大全(笔记)
流畅的python,Fluent Python 第二十一章笔记 (类元编程)
PythonCookbook第八章(类与对象)【马虎完结】
流畅的python,Fluent Python 第二十章笔记 (属性描述符)
tomcat 启动失败 和闪退 和 启动成功却没有页面显示
java urlEncode 和urlDecode的用法
ibatis 的sqlMap 的xml 关注点
web.xml 加载顺序
applicationContext.getBean(“loginEntity”)
struts2 源码地址
Copyright © 2011-2022 走看看