zoukankan
html css js c++ java
.net 通用防注入代码
using
System;
namespace
web.comm
{
/**/
///
<summary>
///
ProcessRequest 的摘要说明。
///
</summary>
public
class
ProcessRequest
{
public
ProcessRequest()
{
//
//
TODO: 在此处添加构造函数逻辑
//
}
SQL注入式攻击代码分析
#region
SQL注入式攻击代码分析
/**/
///
<summary>
///
处理用户提交的请求
///
</summary>
public
static
void
StartProcessRequest()
{
//
System.Web.HttpContext.Current.Response.Write("<script>alert('dddd');</script>");
try
{
string
getkeys
=
""
;
//
string sqlErrorPage = System.Configuration.ConfigurationSettings.AppSettings["CustomErrorPage"].ToString();
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],
0
))
{
//
System.Web.HttpContext.Current.Response.Redirect (sqlErrorPage+"?errmsg=sqlserver&sqlprocess=true");
System.Web.HttpContext.Current.Response.Write(
"
<script>alert('请勿非法提交!');history.back();</script>
"
);
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],
1
))
{
//
System.Web.HttpContext.Current.Response.Redirect (sqlErrorPage+"?errmsg=sqlserver&sqlprocess=true");
System.Web.HttpContext.Current.Response.Write(
"
<script>alert('请勿非法提交!');history.back();</script>
"
);
System.Web.HttpContext.Current.Response.End();
}
}
}
}
catch
{
//
错误处理: 处理用户提交信息!
}
}
/**/
///
<summary>
///
分析用户请求是否正常
///
</summary>
///
<param name="Str">
传入用户提交数据
</param>
///
<returns>
返回是否含有SQL注入式攻击代码
</returns>
private
static
bool
ProcessSqlStr(
string
Str,
int
type)
{
string
SqlStr;
if
(type
==
1
)
SqlStr
=
"
exec |insert |select |delete |update |count |chr |mid |master |truncate |char |declare
"
;
else
SqlStr
=
"
'|and|exec|insert|select|delete|update|count|*|chr|mid|master|truncate|char|declare
"
;
bool
ReturnValue
=
true
;
try
{
if
(Str
!=
""
)
{
string
[] anySqlStr
=
SqlStr.Split(
'
|
'
);
foreach
(
string
ss
in
anySqlStr)
{
if
(Str.IndexOf(ss)
>=
0
)
{
ReturnValue
=
false
;
}
}
}
}
catch
{
ReturnValue
=
false
;
}
return
ReturnValue;
}
#endregion
}
}
查看全文
相关阅读:
【STM32】串行通信原理
【STM32】NVIC中断优先级管理
【Linux-驱动】RTC设备驱动架构
【Linux-驱动】在sysfs下创建对应的class节点---class_create
【Linux-驱动】将cdev加入到系统中去---cdev_add
【Linux-驱动】简单字符设备驱动结构和初始化
【Linux-驱动】printk的打印级别
【Linux 网络编程】REUSADDR
【Linux 网络编程】常用TCP/IP网络编程函数
linux定时重启tomcat脚本
原文地址:https://www.cnblogs.com/Spring/p/1209077.html
最新文章
微信小程序自定义tabbar的实现
创建Npm脚手架
Git 分支代码管理日记备注
微信小程序 自定义顶部状态栏
FCC-学习笔记 Spinal Tap Case
FCC-学习笔记 Convert HTML Entities
FCC-学习笔记 Sorted Union
FCC-学习笔记 Boo who
FCC-学习笔记 Missing letters
linux-cento os学习笔记3
热门文章
Cento Os7 下配置java 出现-bash: /usr/bin/java: 没有那个文件或目录
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):IDEA太坑啦
计算机网络面试知识总结3
计算机网络面试知识总结2
计算机网络面试知识总结1
排序算法思路总结
python2安装Flask-MySQLdb出现 fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
静觅爬虫学习笔记8-爬取猫眼电影
git学习笔记
【STM32】STM32串口配置的一般步骤(库函数)
Copyright © 2011-2022 走看看