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
查看全文
相关阅读:
grep如何忽略.svn目录,以及如何忽略多个目录
CSS写的提示框(兼容火狐IE等各大浏览器)
校验IPv4和IPv6地址和URL地址
input框设置onInput事件只能输入数字,能兼容火狐IE9
$(function(){})、$(document).ready(function(){})....../ ready和onload的区别
jQuery EasyUI 教程-Tooltip(提示框)
小知识随手记(一)
自动换行效果对比
getComputedStyle与currentStyle获取样式(style/class)
弹出层框架layer快速使用
原文地址:https://www.cnblogs.com/yiki/p/784219.html
最新文章
Android Handler处理机制 ( 三 ) ——Handler,Message,Looper,MessageQueue
Android Handler处理机制 ( 二 ) ——Handler,Message,Looper,MessageQueue
A Fast Priority Queue Implementation of the Dijkstra Shortest Path Algorithm
Peer to Peer File Sharing Through WCF
交易的成功 = 60%的资金管理 + 40%出入场信号 zt
mysql 交叉表
sql 统计用的sql
Month Calendar
SourceGrid zt
文件 转换 二进制
热门文章
算法 后减前最大值,zt
yahoo 交易数据
linux vi 中按了ctrl+s后没法退出
C --gettimeofday===获取某个程序经历的时间
volatile和const
volatile和const
volatile和const
TCP UDP 协议的区别和联系
mysql 得到重复的记录
nfs server的配置 Starting NFS daemon: [FAILED]
Copyright © 2011-2022 走看看