从别的地方看到的一个防注入函数
来源:互联网 发布:淘宝手机端链接在哪里 编辑:程序博客网 时间:2024/05/16 23:59
这个函数还是比较全面的,先判断字符串,再过滤特殊字符
不过我认为防御最好的办法就是用数字传入再转换类型
function sqlcheck(Str)
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
Call Qcdn.Err_List("请不要在参数中包含非法字符尝试注入!",1)
Response.End
exit function
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
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
Call Qcdn.Err_List("请不要在参数中包含非法字符尝试注入!",1)
Response.End
exit function
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
- 从别的地方看到的一个防注入函数
- 别的地方看到的
- mysql创建函数(从别的地方复制过来)
- PHP防注入的函数
- 回调函数(从别的地方偷的)
- 从360提供的PHP防SQL注入代码改成的一个类
- 一个防SQL注入的小例子
- 高效的防SQL注入函数
- mysql防sql注入的php函数
- PHP的几个防SQL注入函数
- 防SQL注入函数
- php防注入函数
- mysql防注入函数
- mysql防注入函数
- 再别的地方看到的程序中启动外部程序的方法(觉得挺全的,分享下)
- Java中一些比较有用的东西(在别的地方看到的,觉得挺好的,就记录下来了)
- 从别的地方弄过来的 struts 模板方法,以后用
- 一个从别的网站抓取信息的例子(域名查询
- win 2003 +iis6的php配置
- VC无负担实现XP风格界面 选择自 goodname008 的 Blog
- asp.net中按时间自动刷新页面
- win2003上 IIS6 + php5.1 + mysql4.0.21 安装设置
- 心得
- 从别的地方看到的一个防注入函数
- 努力的奋斗!
- MS_Webcast系列之Windows启动的幕后过程
- Symbian 上的 GUI EXE 程序
- poj--题目分类(转)
- ACM-ICPC需要掌握的知识(转载)
- 一个链接TITLE的效果
- Asp.net 学习笔记01
- C#上传图片 并按尺寸新生成一张略缩图