当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP上两个防止SQL注入式攻击Function

ASP
分享一段代码show.asp?id=26变成show/?26的形式
多域名一网站时如果返回最原来的域名
[原创]完美解决ASP 不能更新。数据库或对象为只读。
5天学会asp
TSYS中生成静态页时溢出: ''CInt''
对象标记具有无效的 ''MSWC.MyInfo'' ProgID
[原创]随机增加网站点击的一个不错的方法
Microsoft JET Database Engine 错误 ''80004005'' 未指定的错误的完美解决方法
反SPAM新思路—换Z-BLOG的验证码!
七步倒┈→专用asp后门
asp下实现代码的“运行代码”“复制代码”“保存代码”功能源码
使用ASP实现网站的“目录树”管理的代码
ShowPage 显示“上一页 下一页”等信息的封装代码
[原创]站长感慨asp编程究竟何去何从
响应对象 错误 ''ASP 0185 : 80020003'' 缺少默认属性
[原创]asp下用实现模板加载的的几种方法总结
[原创]asp获取URL参数的几种方法分析总结
Access数据库中“所有记录中均未找到搜索关键字”的解决方法
ASP程序中输出Excel文件实例一则
ASP应用中如何限制同一表单被多次提交

ASP上两个防止SQL注入式攻击Function


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 78 ::
收藏到网摘: n/a

'==========================
'过滤提交表单中的SQL
'==========================
function ForSqlForm()
 dim fqys,errc,i,items
 dim nothis(18)
 nothis(0)="net user"

 nothis(1)="xp_cmdshell"

 nothis(2)="/add"

 nothis(3)="exec%20master.dbo.xp_cmdshell"

 nothis(4)="net localgroup administrators"

 nothis(5)="select"

 nothis(6)="count"

 nothis(7)="asc"

 nothis(8)="char"

 nothis(9)="mid"

 nothis(10)="'"

 nothis(11)=":"

 nothis(12)=""""

 nothis(13)="insert"

 nothis(14)="delete"

 nothis(15)="drop"

 nothis(16)="truncate"

 nothis(17)="from"

 nothis(18)="%"
 
 'nothis(19)="@" 

 errc=false

 for i= 0 to ubound(nothis)
  for each items in request.Form
  if instr(request.Form(items),nothis(i))<>0 then
   response.write("<div>")
   response.write("你所填写的信息:" & server.HTMLEncode(request.Form(items))
& "<br>含非法字符:" & nothis(i))
   response.write("</div>")
   response.write("对不起,你所填写的信息含非法字符!
<a href=""#"" onclick=""history.back()"">返回</a>")
   response.End()
  end if
  next
 next
end function
'==========================
'过滤查询中的SQL
'==========================
function ForSqlInjection()
 dim fqys,errc,i
 dim nothis(19)
 fqys = request.ServerVariables("QUERY_STRING")
 nothis(0)="net user"

 nothis(1)="xp_cmdshell"

 nothis(2)="/add"

 nothis(3)="exec%20master.dbo.xp_cmdshell"

 nothis(4)="net localgroup administrators"

 nothis(5)="select"

 nothis(6)="count"

 nothis(7)="asc"

 nothis(8)="char"

 nothis(9)="mid"

 nothis(10)="'"

 nothis(11)=":"

 nothis(12)=""""

 nothis(13)="insert"

 nothis(14)="delete"

 nothis(15)="drop"

 nothis(16)="truncate"

 nothis(17)="from"

 nothis(18)="%"
 
 nothis(19)="@" 

 errc=false

 for i= 0 to ubound(nothis)

 if instr(FQYs,nothis(i))<>0 then

 errc=true

 end if

 next

 if errc then
 response.write "查询信息含非法字符!<a href=""#"" onclick=""history.back()"">返回</a>"
 response.end

 end if

end function