ASP登陆验证页应做的安全问题

2006-03-23 程序代码 1020 阅读 0 评论

下面这一段代码是把username的非法字符过滤掉
username=trim(request.form("username"))
userpws=trim(request.form("password"))
if username="" or userpws="" or Instr(username,"=")>0 or Instr(username,"%")>0 or Instr(username,chr(32))>0 or Instr(username,"?")>0 or Instr(username,"&")>0 or Instr(username,";")>0 or Instr(username,",")>0 or Instr(username,"'")>0 or Instr(username,",")>0 or Instr(username,chr(34))>0 or Instr(username,chr(9))>0 or Instr(username,"")>0 or Instr(username,"$")>0 then
response.write('' 请正确输入用户名和密码'')
response.end
end if
%>
还有一种是通过地址栏输入非法字符的溢出漏洞
如 一有页面为newslist.asp一页面为newspage.asp

我们从newslist.asp传递newsid参数到newspage.asp
在newspage.asp接收参数时一般我们只用,
dim newsid
newsid=request(''newsid'')
....................
%>
为安全起见我们至少要加一句
dim newsid
newsid=tirm(request''id'')
if newsid='''' or Instr(newsid,"'")>0 or Instr(newsid,"%")>0 then
response.write(''非法参数'')
response.end
%>
我说的基本上就以上两点,如有不到之处请多多指教。
虽然在INTERNET中我们还存在着一些漏洞,但我们多输入几行代码就更好地增加了网站的安全性!

本文链接:https://blog.clang.cn/260.html

版权声明:转载请注明出处。

评论 (0)

评论已关闭