zoukankan
html css js c++ java
[转]ASP.net防SQL注入
一,验证方法
/**/
///
<summary>
///
SQL注入过滤
///
</summary>
///
<param name="InText">
要过滤的字符串
</param>
///
<returns>
如果参数存在不安全字符,则返回true
</returns>
public
static
bool
SqlFilter2(
string
InText)
{
string
word
=
"
and|exec|insert|select|delete|update|chr|mid|master|or|truncate|char|declare|join
"
;
if
(InText
==
null
)
return
false
;
foreach
(
string
i
in
word.Split(
'
|
'
))
{
if
((InText.ToLower().IndexOf(i
+
"
"
)
>-
1
)
||
(InText.ToLower().IndexOf(
"
"
+
i)
>-
1
))
{
return
true
;
}
}
return
false
;
}
二,Global.asax 事件
/**/
///
<summary>
///
当有数据时交时,触发事件
///
</summary>
///
<param name="sender"></param>
///
<param name="e"></param>
protected
void
Application_BeginRequest(Object sender, EventArgs e)
{
//
遍历Post参数,隐藏域除外
foreach
(
string
i
in
this
.Request.Form)
{
if
(i
==
"
__VIEWSTATE
"
)
continue
;
this
.goErr(
this
.Request.Form[i].ToString());
}
//
遍历Get参数。
foreach
(
string
i
in
this
.Request.QueryString)
{
this
.goErr(
this
.Request.QueryString[i].ToString());
}
}
三,Global中的一个方法
/**/
///
<summary>
///
校验参数是否存在SQL字符
///
</summary>
///
<param name="tm"></param>
private
void
goErr(
string
tm)
{
if
(WLCW.Extend.CValidity.SqlFilter2(tm))
this
.Response.Redirect(
"
/error.html
"
);
}
//Trackback: http:
//
tb.blog.csdn.net/TrackBack.aspx?PostId=1627805
查看全文
相关阅读:
玩转Android之手摸手教你DIY一个抢红包神器!
NetWork——关于TCP协议的三次握手和四次挥手
请保持心情快乐,请保持情绪稳定
第八节:Task的各类Task<TResult>返回值以及通用线程的异常处理方案。
第七节:利用CancellationTokenSource实现任务取消和利用CancellationToken类检测取消异常。
第六节:深入研究Task实例方法ContinueWith的参数TaskContinuationOptions
第五节:Task构造函数之TaskCreationOptions枚举处理父子线程之间的关系。
第四节:Task的启动的四种方式以及Task、TaskFactory的线程等待和线程延续的解决方案
第三节:ThreadPool的线程开启、线程等待、线程池的设置、定时功能
第二节:深入剖析Thread的五大方法、数据槽、内存栅栏。
原文地址:https://www.cnblogs.com/yiki/p/784219.html
最新文章
(1)架构和目录结构
lua实现单例模式
php之isset empty is_null的区别
LeetCode:翻转二叉树【226】
LeetCode:二叉树的后序遍历【145】
LeetCode:N叉树的前序遍历【589】
LeetCode:N叉树的后序遍历【590】
LeetCode:括号的分数【856】
LeetCode:比较含退格字符串【844】
LeetCode:棒球比赛【682】
热门文章
LeetCode:下一个更大元素I【31】
LeetCode:每日温度【739】
LeetCode:逆波兰表达式求值【150】
执行力:蜀鄙二僧欲之南海
执行力:蜀鄙二僧欲之南海
VR中为什么需要把游戏音频放在聚光灯里?
Eclipse安装Java Class反编译插件
Eclipse安装Java Class反编译插件
设计模式——观察者模式详解
Java线程和多线程(十二)——线程池基础
Copyright © 2011-2022 走看看