用户名: 密码: 免费注册 忘记密码? 网站地图 | 加入收藏 | 设为首页
首页 | 新闻 | 工具 | 系统 | 办公 | 聊天 | 多媒体 | 网页 | 运营 | 平面 | 欣赏 | 数据库 | 程序 | 服务器 | 组网
网页 | 3dmax | Ghost | Windows Xp| Dreamweaver | photoshop | Flash | office | Alexa | Css | QQ | Asp | PHP | Jsp | Access
Flash MX 2004入门 | 网站推广策略 | CorelDRAW入门 | ASP学习 | 网站建设大师功 | Word入门
  iTbulo.com > 学院 > 网页制作教程 > 网页制作技巧 > 文章正文
网页脚本攻击防范全攻略
iTbulo.COM 2005-8-31 原野()

程序体(5)

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 ""
response.end
end if

我要做点声明的是:以上的程序只是对GET方式提交的数据进行的过滤,千万不要盲目套用。

像其他一些来自 ASP request 对象 (Reques、Request.QueryString、Request.Form、Request.Cookies和 Request.ServerVariables) 的用户输入的攻击方法的方法,大致都集中在脚本期望的输入变量是数字变量 (ID) 上,当然我们不能只看数字变量,比如:

http://127.0.0.1/systembbs/showtopic.asp?tid=99&name=abc' and left(userpasswor d,1)='a

http://127.0.0.1/systembbs/addtopic.asp?tid=99&name=abc' and userpasswor d=’or’’=’

另外,如何单一的防止类似这样的注入错误?

http://127.0.0.1/systembbs/addtopic.asp?tid=99’ ;delete forum_forum;--&page=33 防范程序: 程序体(6)

……addtopic.asp?action=add……
……addtopic.asp?action=delect……
Action1=trim(Request.QueryString())
if left(action1,7)<>"action=" then '限定querystring必须为 action=
error(err01)'错误处理
else
action=Request.querystring("action")'取得querystring的值
end if
select case action'对querystring进行处理
case "add"
.....
case "delete"
......
case else '如果querystring没有这个值则进行错误处理
error(err02)
end select

程序体(6)

出现这样的攻击,使我们的站长们不得不又再次头痛,这里我可以给出大家一个解决最好办法,一般的来说,用户名长度字符数不会超过15个字符,大都为14字符。那么我们从长度出发,来进行过滤:如程序体(7)

Name=replace(name,”’”,””)
If len(name)>16 then
Response.write “ 你要做什么?”
Response.end
End if

程序体(7)

为什么我们这里以及过滤了单引号,怎么还要再次取一个长度限制呢?不多说了,看看4ngel的文章先<<饶过'限制继续射入>> .别问我怎么转数字格式,我不会,嘿嘿…^_^!

还继续回到我们的主题,” 脚本期望的输入变量是数字变量 (ID)”.怎样进行注入防范,天呐,方法太多了,最直接的就是判断是否是数字整型,还有一些比较个性的验证办法,我们一一介绍一下 如:程序体(8)

一,判断数字是否是整型

p_lngID = CLng(Request("ID"))

二 取字长 这一点我相信一般的数据长度不会大于8位所以:

If len(ID)>8 then
response.write “bedpost”
response end
end if

上一页  [1] [2] [3] [4] [5] [6] 下一页

文章搜索
相关资讯
相关文章 相关下载
没有相关文章
焦点信息