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
查看全文
相关阅读:
java面试总结之框架问题
数据库设计三大范式
js 一些技巧
el 和 fmt 常用
iframe自适应高度
MySQL基础
任意精度整数算法 (BigInteger) 和任意精度小数算法 (BigDecimal)
hibernate
Struts2
Servlet、Cookie、Session
原文地址:https://www.cnblogs.com/yiki/p/784219.html
最新文章
docker制作node程序镜像:
mongodb use db show dbs
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Restarting network (via systemctl): Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
linux 配置集群需要修改的东西
VMware 无法为处于开启或挂起状态的去你及或快照创建克隆
-bash: nignx: 未找到命令
centos更改mac
VMare 设置固定IP和网段
centos一些mysql常用命令
热门文章
CentOS Docker 安装
linux服务配置IP或者说可以远程连接
JVM介绍及参数调优
java线程同步的两个练习(两个线程)
Linux常见面试题
jsp 九大内置对象和四大作用域
SpringMVC 运行原理
spring常用注解
代理设计模式
java面试题及答案
Copyright © 2011-2022 走看看