ASP

本类阅读TOP10

·asp常用数据库连接方法和技巧
·VisualStudio.NET_2003及其 MSDN 下载地址
·session的用法具体解说
·MD5加密算法 ASP版
·JavaScript实现的数据表格:冻结列、调整列宽和客户端排序
·无组件生成BMP验证码
·一些常用的辅助代码 (网络收藏)
·ASP.net中md5加密码的方法
·ASP模拟MVC模式编程
·ASP.NET编程中的十大技巧

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
自己写一个防止SQL注入函数

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

<%
function sqlcheck(Str,errtype)
if Instr(LCase(Str),"select ") > 0 or Instr(LCase(Str),"insert ") > 0 or Instr(LCase(Str),"delete ") > 0 or Instr(LCase(Str),"delete from ") > 0 or Instr(LCase(Str),"count(") > 0 or Instr(LCase(Str),"drop table") > 0 or Instr(LCase(Str),"update ") > 0 or Instr(LCase(Str),"truncate ") > 0 or Instr(LCase(Str),"asc(") > 0 or Instr(LCase(Str),"mid(") > 0 or Instr(LCase(Str),"char(") > 0 or Instr(LCase(Str),"xp_cmdshell") > 0 or Instr(LCase(Str),"exec master") > 0 or Instr(LCase(Str),"net localgroup administrators") > 0  or Instr(LCase(Str),"and ") > 0 or Instr(LCase(Str),"net user") > 0 or Instr(LCase(Str),"or ") > 0 then
 Response.write("<script language=javascript>" & vbcrlf & "window.location.href ='ShowError.asp?errtype=" & errtype & "'" & vbcrlf & "</script>")
 Response.End
end if
Str=Replace(Str,"_","")     '过滤SQL注入_
Str=Replace(Str,"*","")     '过滤SQL注入*
Str=Replace(Str," ","")     '过滤SQL注入空格
Str=Replace(Str,chr(34),"")   '过滤SQL注入"
Str=Replace(Str,chr(39),"")            '过滤SQL注入'
Str=Replace(Str,chr(91),"")            '过滤SQL注入[
Str=Replace(Str,chr(93),"")            '过滤SQL注入]
Str=Replace(Str,chr(37),"")            '过滤SQL注入%
Str=Replace(Str,chr(58),"")            '过滤SQL注入:
Str=Replace(Str,chr(59),"")            '过滤SQL注入;
Str=Replace(Str,chr(43),"")            '过滤SQL注入+
Str=Replace(Str,"{","")            '过滤SQL注入{
Str=Replace(Str,"}","")            '过滤SQL注入}
sqlcheck=Str            '返回经过上面字符替换后的Str
end function
%>



相关文章

相关软件




月光软件程序下载编程文档电脑教程网站设计网址导航网络文学游戏天地幽默笑话生活休闲写作范文安妮宝贝
电脑技术编程开发网络专区谈天说地情感世界游戏元素分类游戏热门游戏体育运动手机专区业余爱好影视沙龙
音乐天地数码广场教育园地科学大观古今纵横谈股论金人文艺术医学保健动漫图酷二手专区地方风情各行各业

月光软件站·版权所有