当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp实现防止从外部提交数据的三种方法

ASP
asp下检查表中是否存在某个字段(列)函数
ASP批量更新代码
asp飞飞无限级分类v1.0 Asp+sql+存储过程+ajax提供下载
比较详细的ASP rs.open语句详细说明
可以应用到马克斯电影站生成Rss Feed的代码
ASP 无限级分类实现
从数据库中读取记录横向排列
ASP动态级联菜单实现代码
网上用的比较多的asp级联菜单效果代码
ASP提高数据显示效率-缓存探幽
asp经常被忽视的一种死循环
关于Asp代码与页面的分离模板技术
用GetString提高ASP的速度
用cookies实现闪电登录论坛方法
一个不太让人讨厌的自动弹出窗口
asp格式化日期时间格式的代码
ASP变量加变量实现代码
asp向数据库插入数据的方法rs
asp上传带显示的代码
asp防止垃圾留言代码

ASP 中的 asp实现防止从外部提交数据的三种方法


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

防止从外部提交数据的方法
第一种做法,屏蔽特殊字符和关键字
fqys=request.servervariables("query_string")
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)="%"
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 "<script language=""javascript"">"
response.write "parent.alert('很抱歉!你正在试图攻击本服务器或者想取得本服务器最高管理权!将直接转向首页..');"
response.write "self.location.href='default.asp';"
response.write "</script>"
response.end
end if

第二种可以防止客户从本地提交到网站上
<%
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
if mid(server_v1,8,len(server_v2))<>server_v2 then
response.write "<br><br><center><table border=1 cellpadding=20 bordercolor=black bgcolor=#EEEEEE width=450>"
response.write "<tr><td style=font:9pt Verdana>"
response.write "你提交的路径有误,禁止从站点外部提交数据请不要乱该参数!"
response.write "</td></tr></table></center>"
response.end
end if
%>

第三。这样可以防止在输入框上打上or 1=1 的字样
If Instr(request("username"),"=")>0 or
Instr(request("username"),"%")>0 or
Instr(request("username"),chr(32))>0 or
Instr(request("username"),"?")>0 or
Instr(request("username"),"&")>0 or
Instr(request("username"),";")>0 or
Instr(request("username"),",")>0 or
Instr(request("username"),"'")>0 or
Instr(request("username"),"?")>0 or
Instr(request("username"),chr(34))>0 or
Instr(request("username"),chr(9))>0 or
Instr(request("username")," ")>0 or
Instr(request("username"),"$")>0 or
Instr(request("username"),">")>0 or
Instr(request("username"),"<")>0 or
Instr(request("username"),"""")>0 then